arduino / nicla-sense-me-fw

Arduino Nicla Sense ME resources (libraries, bootloader, host pc utilities)
GNU Affero General Public License v3.0
46 stars 27 forks source link

add a flag to indicate if a new data is available #108

Closed bstbud closed 1 year ago

bstbud commented 1 year ago

Description

add a flag to indicate if a new data is available so that no dummy data is printed

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Breaking change
github-actions[bot] commented 1 year ago

Memory usage change @ 2aa90fc4ad2199a588afebcd1ad76a3744d7b277

Board flash % RAM for global variables %
arduino:mbed_nicla:nicla_sense :grey_question: -64 - +64 -0.01 - +0.01 :small_red_triangle: 0 - +8 0.0 - +0.01
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A
arduino:samd:mkrgsm1400 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrnb1500 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwan1310 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwifi1010 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrzero 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table Board|`Arduino_BHY2/examples/App`
flash|%|`Arduino_BHY2/examples/App`
RAM for global variables|%|`Arduino_BHY2/examples/AppLowDelay`
flash|%|`Arduino_BHY2/examples/AppLowDelay`
RAM for global variables|%|`Arduino_BHY2/examples/BHYFirmwareUpdate`
flash|%|`Arduino_BHY2/examples/BHYFirmwareUpdate`
RAM for global variables|%|`Arduino_BHY2/examples/DataHarvester`
flash|%|`Arduino_BHY2/examples/DataHarvester`
RAM for global variables|%|`Arduino_BHY2/examples/Fail_Safe_flasher`
flash|%|`Arduino_BHY2/examples/Fail_Safe_flasher`
RAM for global variables|%|`Arduino_BHY2/examples/ReadSensorConfiguration`
flash|%|`Arduino_BHY2/examples/ReadSensorConfiguration`
RAM for global variables|%|`Arduino_BHY2/examples/ShowSensorList`
flash|%|`Arduino_BHY2/examples/ShowSensorList`
RAM for global variables|%|`Arduino_BHY2/examples/Standalone`
flash|%|`Arduino_BHY2/examples/Standalone`
RAM for global variables|%|`Arduino_BHY2/examples/StandaloneFlashStorage`
flash|%|`Arduino_BHY2/examples/StandaloneFlashStorage`
RAM for global variables|%|`Arduino_BHY2Host/examples/Accelerometer`
flash|%|`Arduino_BHY2Host/examples/Accelerometer`
RAM for global variables|%|`Arduino_BHY2Host/examples/Orientation`
flash|%|`Arduino_BHY2Host/examples/Orientation`
RAM for global variables|%|`Arduino_BHY2Host/examples/Temperature`
flash|%|`Arduino_BHY2Host/examples/Temperature`
RAM for global variables|%|`Arduino_BHY2Host/examples/Nicla_IoT_Bridge`
flash|%|`Arduino_BHY2Host/examples/Nicla_IoT_Bridge`
RAM for global variables|%|`Arduino_BHY2Host/examples/Portenta_BLE_Bridge`
flash|%|`Arduino_BHY2Host/examples/Portenta_BLE_Bridge`
RAM for global variables|% -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|- `arduino:mbed_nicla:nicla_sense`|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|8|0.01|0|0.0|0|0.0|64|0.01|8|0.01|-64|-0.01|8|0.01 `arduino:mbed_portenta:envie_m7`|||||||||||||||||||||||||||||||||||||N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A `arduino:samd:mkrgsm1400`|||||||||||||||||||||||||||||||||||||0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|||||||| `arduino:samd:mkrnb1500`|||||||||||||||||||||||||||||||||||||0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|||||||| `arduino:samd:mkrwan1310`|||||||||||||||||||||||||||||||||||||0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|||||||| `arduino:samd:mkrwifi1010`|||||||||||||||||||||||||||||||||||||0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|||| `arduino:samd:mkrzero`|||||||||||||||||||||||||||||||||||||0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0||||||||
Click for full report CSV ``` Board,Arduino_BHY2/examples/App
flash,%,Arduino_BHY2/examples/App
RAM for global variables,%,Arduino_BHY2/examples/AppLowDelay
flash,%,Arduino_BHY2/examples/AppLowDelay
RAM for global variables,%,Arduino_BHY2/examples/BHYFirmwareUpdate
flash,%,Arduino_BHY2/examples/BHYFirmwareUpdate
RAM for global variables,%,Arduino_BHY2/examples/DataHarvester
flash,%,Arduino_BHY2/examples/DataHarvester
RAM for global variables,%,Arduino_BHY2/examples/Fail_Safe_flasher
flash,%,Arduino_BHY2/examples/Fail_Safe_flasher
RAM for global variables,%,Arduino_BHY2/examples/ReadSensorConfiguration
flash,%,Arduino_BHY2/examples/ReadSensorConfiguration
RAM for global variables,%,Arduino_BHY2/examples/ShowSensorList
flash,%,Arduino_BHY2/examples/ShowSensorList
RAM for global variables,%,Arduino_BHY2/examples/Standalone
flash,%,Arduino_BHY2/examples/Standalone
RAM for global variables,%,Arduino_BHY2/examples/StandaloneFlashStorage
flash,%,Arduino_BHY2/examples/StandaloneFlashStorage
RAM for global variables,%,Arduino_BHY2Host/examples/Accelerometer
flash,%,Arduino_BHY2Host/examples/Accelerometer
RAM for global variables,%,Arduino_BHY2Host/examples/Orientation
flash,%,Arduino_BHY2Host/examples/Orientation
RAM for global variables,%,Arduino_BHY2Host/examples/Temperature
flash,%,Arduino_BHY2Host/examples/Temperature
RAM for global variables,%,Arduino_BHY2Host/examples/Nicla_IoT_Bridge
flash,%,Arduino_BHY2Host/examples/Nicla_IoT_Bridge
RAM for global variables,%,Arduino_BHY2Host/examples/Portenta_BLE_Bridge
flash,%,Arduino_BHY2Host/examples/Portenta_BLE_Bridge
RAM for global variables,% arduino:mbed_nicla:nicla_sense,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,8,0.01,0,0.0,0,0.0,64,0.01,8,0.01,-64,-0.01,8,0.01 arduino:mbed_portenta:envie_m7,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A arduino:samd:mkrgsm1400,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,,,, arduino:samd:mkrnb1500,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,,,, arduino:samd:mkrwan1310,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,,,, arduino:samd:mkrwifi1010,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,, arduino:samd:mkrzero,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,,,, ```
aliphys commented 1 year ago

Hello,

Following the result from tests with multiple boards / firmware I can share that:

Note: The loop was set to run continuously, with the following if statement commented out in all tests:

if (millis() - printTime >= 1000) {
printTime = millis();
//call sensors
}

Thanks @jacobhylen for the helpful discussions 🌟

bstbud commented 1 year ago

Hello,

Following the result from tests with multiple boards / firmware I can share that:

  • For the accelerometer, gyroscope, gas and rotation values included in the modified standalone.ino sketch, values are NOT printed when zero. However, the temperature is still printed when it is zero, indicating that temperature data is sent even when not available.

    Serial Output with previous Standalone.ino sketch

    acceleration: XYZ values - X: 0   Y: 0   Z: 0
    
    gyroscope: XYZ values - X: 0   Y: 0   Z: 0
    
    temperature: 0.000
    gas: 0.000
    rotation: Quaternion values - X: 0.000   Y: 0.000   Z: 0.000   W: 0.000   Accuracy: 0.000

    Serial Output with modified Standalone.ino sketch

    acceleration: XYZ values - X: -1123   Y: -287   Z: 4099
    
    gyroscope: XYZ values - X: 1   Y: 15   Z: -3
    
    temperature: 0.000
    acceleration: XYZ values - X: -1130   Y: -288   Z: 4117
    
    gyroscope: XYZ values - X: 2   Y: 16   Z: -1
    
    acceleration: XYZ values - X: -1132   Y: -283   Z: 4099
    
    gyroscope: XYZ values - X: -1   Y: -14   Z: -4
    
    acceleration: XYZ values - X: -1116   Y: -295   Z: 4091
    
    gyroscope: XYZ values - X: 0   Y: 3   Z: -2
    
    temperature: 24.430
    acceleration: XYZ values - X: -1138   Y: -281   Z: 4104
    
    ...
    
    rotation: Quaternion values - X: -0.032   Y: 0.134   Z: -0.000   W: 0.990   Accuracy: 3.142
    
    acceleration: XYZ values - X: -1132   Y: -268   Z: 4120
    
    gyroscope: XYZ values - X: 1   Y: 6   Z: 0
    
    rotation: Quaternion values - X: -0.032   Y: 0.134   Z: -0.000   W: 0.990   Accuracy: 3.142
    
    acceleration: XYZ values - X: -1126   Y: -289   Z: 4090
    
    gyroscope: XYZ values - X: 0   Y: 5   Z: -2
    
    gas: 812613.000
    rotation: Quaternion values - X: -0.032   Y: 0.134   Z: -0.000   W: 0.990   Accuracy: 3.142
  • When the quaternion data is displayed, the accuracy is always set to 3.142. What does this refer to?

  • The firmware must be updated (via the BHYFirmwareUpdate.ino sketch), otherwise the quaternion data may not be visible on the terminal.

  • The quaternion sensor values are delivered on two out of the four boards tested.

Note: The loop was set to run continuously, with the following if statement commented out in all tests:

if (millis() - printTime >= 1000) {
printTime = millis();
//call sensors
}

Thanks @jacobhylen for the helpful discussions 🌟

hi @aliphys, did you use the Standalone.ino from the examples w/o modifications? could you post the sketch you used? It could be because of missing initialization of _dataAvail member causing the _dataAvail to be random when the Sensor object is dynamically created, which has been fixed in the new commit (please checkout and see if the issue is resolved but pls share your sketch still to confirm ).

github-actions[bot] commented 1 year ago

Memory usage change @ b7dc6a60308093febddabf5082360dfbee1045b0

Board flash % RAM for global variables %
arduino:mbed_nicla:nicla_sense :small_red_triangle: 0 - +64 0.0 - +0.01 :small_red_triangle: 0 - +8 0.0 - +0.01
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A
arduino:samd:mkrgsm1400 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrnb1500 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwan1310 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwifi1010 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrzero 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table Board|`Arduino_BHY2/examples/App`
flash|%|`Arduino_BHY2/examples/App`
RAM for global variables|%|`Arduino_BHY2/examples/AppLowDelay`
flash|%|`Arduino_BHY2/examples/AppLowDelay`
RAM for global variables|%|`Arduino_BHY2/examples/BHYFirmwareUpdate`
flash|%|`Arduino_BHY2/examples/BHYFirmwareUpdate`
RAM for global variables|%|`Arduino_BHY2/examples/DataHarvester`
flash|%|`Arduino_BHY2/examples/DataHarvester`
RAM for global variables|%|`Arduino_BHY2/examples/Fail_Safe_flasher`
flash|%|`Arduino_BHY2/examples/Fail_Safe_flasher`
RAM for global variables|%|`Arduino_BHY2/examples/ReadSensorConfiguration`
flash|%|`Arduino_BHY2/examples/ReadSensorConfiguration`
RAM for global variables|%|`Arduino_BHY2/examples/ShowSensorList`
flash|%|`Arduino_BHY2/examples/ShowSensorList`
RAM for global variables|%|`Arduino_BHY2/examples/Standalone`
flash|%|`Arduino_BHY2/examples/Standalone`
RAM for global variables|%|`Arduino_BHY2/examples/StandaloneFlashStorage`
flash|%|`Arduino_BHY2/examples/StandaloneFlashStorage`
RAM for global variables|%|`Arduino_BHY2Host/examples/Accelerometer`
flash|%|`Arduino_BHY2Host/examples/Accelerometer`
RAM for global variables|%|`Arduino_BHY2Host/examples/Orientation`
flash|%|`Arduino_BHY2Host/examples/Orientation`
RAM for global variables|%|`Arduino_BHY2Host/examples/Temperature`
flash|%|`Arduino_BHY2Host/examples/Temperature`
RAM for global variables|%|`Arduino_BHY2Host/examples/Nicla_IoT_Bridge`
flash|%|`Arduino_BHY2Host/examples/Nicla_IoT_Bridge`
RAM for global variables|%|`Arduino_BHY2Host/examples/Portenta_BLE_Bridge`
flash|%|`Arduino_BHY2Host/examples/Portenta_BLE_Bridge`
RAM for global variables|% -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|- `arduino:mbed_nicla:nicla_sense`|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|8|0.01|0|0.0|0|0.0|64|0.01|8|0.01|0|0.0|8|0.01 `arduino:mbed_portenta:envie_m7`|||||||||||||||||||||||||||||||||||||N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A `arduino:samd:mkrgsm1400`|||||||||||||||||||||||||||||||||||||0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|||||||| `arduino:samd:mkrnb1500`|||||||||||||||||||||||||||||||||||||0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|||||||| `arduino:samd:mkrwan1310`|||||||||||||||||||||||||||||||||||||0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|||||||| `arduino:samd:mkrwifi1010`|||||||||||||||||||||||||||||||||||||0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|||| `arduino:samd:mkrzero`|||||||||||||||||||||||||||||||||||||0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0||||||||
Click for full report CSV ``` Board,Arduino_BHY2/examples/App
flash,%,Arduino_BHY2/examples/App
RAM for global variables,%,Arduino_BHY2/examples/AppLowDelay
flash,%,Arduino_BHY2/examples/AppLowDelay
RAM for global variables,%,Arduino_BHY2/examples/BHYFirmwareUpdate
flash,%,Arduino_BHY2/examples/BHYFirmwareUpdate
RAM for global variables,%,Arduino_BHY2/examples/DataHarvester
flash,%,Arduino_BHY2/examples/DataHarvester
RAM for global variables,%,Arduino_BHY2/examples/Fail_Safe_flasher
flash,%,Arduino_BHY2/examples/Fail_Safe_flasher
RAM for global variables,%,Arduino_BHY2/examples/ReadSensorConfiguration
flash,%,Arduino_BHY2/examples/ReadSensorConfiguration
RAM for global variables,%,Arduino_BHY2/examples/ShowSensorList
flash,%,Arduino_BHY2/examples/ShowSensorList
RAM for global variables,%,Arduino_BHY2/examples/Standalone
flash,%,Arduino_BHY2/examples/Standalone
RAM for global variables,%,Arduino_BHY2/examples/StandaloneFlashStorage
flash,%,Arduino_BHY2/examples/StandaloneFlashStorage
RAM for global variables,%,Arduino_BHY2Host/examples/Accelerometer
flash,%,Arduino_BHY2Host/examples/Accelerometer
RAM for global variables,%,Arduino_BHY2Host/examples/Orientation
flash,%,Arduino_BHY2Host/examples/Orientation
RAM for global variables,%,Arduino_BHY2Host/examples/Temperature
flash,%,Arduino_BHY2Host/examples/Temperature
RAM for global variables,%,Arduino_BHY2Host/examples/Nicla_IoT_Bridge
flash,%,Arduino_BHY2Host/examples/Nicla_IoT_Bridge
RAM for global variables,%,Arduino_BHY2Host/examples/Portenta_BLE_Bridge
flash,%,Arduino_BHY2Host/examples/Portenta_BLE_Bridge
RAM for global variables,% arduino:mbed_nicla:nicla_sense,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,8,0.01,0,0.0,0,0.0,64,0.01,8,0.01,0,0.0,8,0.01 arduino:mbed_portenta:envie_m7,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A arduino:samd:mkrgsm1400,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,,,, arduino:samd:mkrnb1500,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,,,, arduino:samd:mkrwan1310,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,,,, arduino:samd:mkrwifi1010,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,, arduino:samd:mkrzero,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,,,, ```
aliphys commented 1 year ago

Hello @bstbud ,


TLDR: With latest firmware/checkout, the temperature and gas data are inaccurate upon device startup even when .dataAvaliable() is used to check virtual sensor status.


Modified Standalone sketch with delay removed

could you post the sketch you used?

This is the sketch I used. Note that the initial one second delay is commented out.

Standalone.ino sketch with 1 second delay commented out ``` /* * This sketch shows how nicla can be used in standalone mode. * Without the need for an host, nicla can run sketches that * are able to configure the bhi sensors and are able to read all * the bhi sensors data. */ #include "Arduino.h" #include "Arduino_BHY2.h" SensorXYZ accel(SENSOR_ID_ACC); SensorXYZ gyro(SENSOR_ID_GYRO); Sensor temp(SENSOR_ID_TEMP); Sensor gas(SENSOR_ID_GAS); SensorQuaternion rotation(SENSOR_ID_RV); void setup() { Serial.begin(115200); while(!Serial); BHY2.begin(); accel.begin(); gyro.begin(); temp.begin(); gas.begin(); rotation.begin(); } void loop() { static auto printTime = millis(); // Update function should be continuously polled BHY2.update(); // if (millis() - printTime >= 1000) { // printTime = millis(); if(accel.dataAvailable()) { Serial.println(String("acceleration: ") + accel.toString()); accel.clearDataAvailFlag(); } if(gyro.dataAvailable()) { Serial.println(String("gyroscope: ") + gyro.toString()); gyro.clearDataAvailFlag(); } if (temp.dataAvailable()) { Serial.println(String("temperature: ") + String(temp.value(),3)); temp.clearDataAvailFlag(); } if (gas.dataAvailable()) { Serial.println(String("gas: ") + String(gas.value(),3)); gas.clearDataAvailFlag(); } if (rotation.dataAvailable()) { Serial.println(String("rotation: ") + rotation.toString()); rotation.clearDataAvailFlag(); } // } } ```

This is the Serial Monitor output:

acceleration: XYZ values - X: -246   Y: -136   Z: 4216

gyroscope: XYZ values - X: 0   Y: 4   Z: 0

temperature: 0.000
acceleration: XYZ values - X: -249   Y: -129   Z: 4212

gyroscope: XYZ values - X: 0   Y: -3   Z: 0

acceleration: XYZ values - X: -238   Y: -139   Z: 4199

gyroscope: XYZ values - X: 0   Y: -5   Z: -3

rotation: Quaternion values - X: -0.016   Y: 0.030   Z: 0.000   W: 0.999   Accuracy: 3.142

acceleration: XYZ values - X: -241   Y: -145   Z: 4223

gyroscope: XYZ values - X: -1   Y: 12   Z: 0

temperature: 32.110
rotation: Quaternion values - X: -0.016   Y: 0.030   Z: 0.000   W: 0.999   Accuracy: 3.142

Temperature Values

Following tests with the latest commit temperature values are still reported as zero initially: temperature: 0.000. To show this more clearly, here is a sketch to only output tempertature values.

Sketch to only output temperature values ``` #include "Arduino.h" #include "Arduino_BHY2.h" Sensor temp(SENSOR_ID_TEMP); void setup() { Serial.begin(115200); while(!Serial); BHY2.begin(); temp.begin(); } void loop() { // Update function should be continuously polled BHY2.update(); if (temp.dataAvailable()) { Serial.println(String(temp.value(),3)); temp.clearDataAvailFlag(); } } ```

The first value for this sketch is zero in both devices.

Nicla Sense ME A

0.000
32.310
32.320
32.300
32.270
32.250
32.220
32.170
32.130

Nicla Sense ME B

0.000
31.100
31.110
31.100
31.080
31.070
31.080
31.070
31.060

Gas Values

Sketch to only output gas values ``` #include "Arduino.h" #include "Arduino_BHY2.h" Sensor gas(SENSOR_ID_GAS); void setup() { Serial.begin(115200); while(!Serial); BHY2.begin(); gas.begin(); } void loop() { // Update function should be continuously polled BHY2.update(); if (gas.dataAvailable()) { Serial.println(String(gas.value(),3)); gas.clearDataAvailFlag(); } } ```

You can see that the initial value is about two orders of magnitude higher, then drops down before settling at about 20,000 for Nicla Sense ME A or 10,000 for Nicla Sense ME B. Note that both sensor were on for over five minutes, before they were reset and data collected.

Nicla Sense ME A

1181898.000
6240.000
11753.000
15872.000
18306.000
20072.000
21422.000
22262.000
23094.000
24014.000
24404.000
24734.000

Nicla Sense ME B

447114.000
2568.000
4039.000
5539.000
6619.000
7381.000
7883.000
8316.000
8632.000
8950.000
9178.000
9410.000
9644.000
9891.000
10082.000
10301.000
10403.000

Please let me know if I can provide more info and thanks again for looking into this @bstbud ! 😄

bstbud commented 1 year ago

@aliphys Thanks for the info provided. tried to reproduce using the sketch for the temperature sensor output only and unfortunately, with 10+ times of resetting the device, the 1st temperature sensor output are always valid (non-zero).

so would like to learn more:

  1. how often could you reproduce the issue (1st temperature value is zero)
  2. did you update the BHI260 Firmware to the latest (simply use the example sketch BHY2FirmwareUpdate for this commit)
aliphys commented 1 year ago

Regarding both comments, the answer is yes.

bstbud commented 1 year ago

@aliphys it was found that the old BHI260 firmware presents this issue and the new BHI260 firmware will eradicate this issue. Would you like to try the new BHI260 firmware from: https://github.com/arduino/nicla-sense-me-fw/pull/85

bstbud commented 1 year ago

@the latest BHI260 FW from fea_bsec2 branch is copied to this branch and with the new BHI260 FW (fw.h), you should see the issue of initial 0-values gone. You could give it a shot, simply check out the latest code, update the BHI260 fw and then use your sketch to verify the issues.

github-actions[bot] commented 1 year ago

Memory usage change @ e4b435adc05c20fd3afc63e8c04eebab7dfde0ba

Board flash % RAM for global variables %
arduino:mbed_nicla:nicla_sense :grey_question: -2180 - +64 -0.41 - +0.01 :small_red_triangle: 0 - +8 0.0 - +0.01
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A
arduino:samd:mkrgsm1400 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrnb1500 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwan1310 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwifi1010 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrzero 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table Board|`Arduino_BHY2/examples/App`
flash|%|`Arduino_BHY2/examples/App`
RAM for global variables|%|`Arduino_BHY2/examples/AppLowDelay`
flash|%|`Arduino_BHY2/examples/AppLowDelay`
RAM for global variables|%|`Arduino_BHY2/examples/BHYFirmwareUpdate`
flash|%|`Arduino_BHY2/examples/BHYFirmwareUpdate`
RAM for global variables|%|`Arduino_BHY2/examples/DataHarvester`
flash|%|`Arduino_BHY2/examples/DataHarvester`
RAM for global variables|%|`Arduino_BHY2/examples/Fail_Safe_flasher`
flash|%|`Arduino_BHY2/examples/Fail_Safe_flasher`
RAM for global variables|%|`Arduino_BHY2/examples/ReadSensorConfiguration`
flash|%|`Arduino_BHY2/examples/ReadSensorConfiguration`
RAM for global variables|%|`Arduino_BHY2/examples/ShowSensorList`
flash|%|`Arduino_BHY2/examples/ShowSensorList`
RAM for global variables|%|`Arduino_BHY2/examples/Standalone`
flash|%|`Arduino_BHY2/examples/Standalone`
RAM for global variables|%|`Arduino_BHY2/examples/StandaloneFlashStorage`
flash|%|`Arduino_BHY2/examples/StandaloneFlashStorage`
RAM for global variables|%|`Arduino_BHY2Host/examples/Accelerometer`
flash|%|`Arduino_BHY2Host/examples/Accelerometer`
RAM for global variables|%|`Arduino_BHY2Host/examples/Orientation`
flash|%|`Arduino_BHY2Host/examples/Orientation`
RAM for global variables|%|`Arduino_BHY2Host/examples/Temperature`
flash|%|`Arduino_BHY2Host/examples/Temperature`
RAM for global variables|%|`Arduino_BHY2Host/examples/Nicla_IoT_Bridge`
flash|%|`Arduino_BHY2Host/examples/Nicla_IoT_Bridge`
RAM for global variables|%|`Arduino_BHY2Host/examples/Portenta_BLE_Bridge`
flash|%|`Arduino_BHY2Host/examples/Portenta_BLE_Bridge`
RAM for global variables|% -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|- `arduino:mbed_nicla:nicla_sense`|0|0.0|0|0.0|0|0.0|0|0.0|-2180|-0.41|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|8|0.01|0|0.0|0|0.0|64|0.01|8|0.01|0|0.0|8|0.01 `arduino:mbed_portenta:envie_m7`|||||||||||||||||||||||||||||||||||||N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A `arduino:samd:mkrgsm1400`|||||||||||||||||||||||||||||||||||||0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|||||||| `arduino:samd:mkrnb1500`|||||||||||||||||||||||||||||||||||||0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|||||||| `arduino:samd:mkrwan1310`|||||||||||||||||||||||||||||||||||||0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|||||||| `arduino:samd:mkrwifi1010`|||||||||||||||||||||||||||||||||||||0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|||| `arduino:samd:mkrzero`|||||||||||||||||||||||||||||||||||||0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0||||||||
Click for full report CSV ``` Board,Arduino_BHY2/examples/App
flash,%,Arduino_BHY2/examples/App
RAM for global variables,%,Arduino_BHY2/examples/AppLowDelay
flash,%,Arduino_BHY2/examples/AppLowDelay
RAM for global variables,%,Arduino_BHY2/examples/BHYFirmwareUpdate
flash,%,Arduino_BHY2/examples/BHYFirmwareUpdate
RAM for global variables,%,Arduino_BHY2/examples/DataHarvester
flash,%,Arduino_BHY2/examples/DataHarvester
RAM for global variables,%,Arduino_BHY2/examples/Fail_Safe_flasher
flash,%,Arduino_BHY2/examples/Fail_Safe_flasher
RAM for global variables,%,Arduino_BHY2/examples/ReadSensorConfiguration
flash,%,Arduino_BHY2/examples/ReadSensorConfiguration
RAM for global variables,%,Arduino_BHY2/examples/ShowSensorList
flash,%,Arduino_BHY2/examples/ShowSensorList
RAM for global variables,%,Arduino_BHY2/examples/Standalone
flash,%,Arduino_BHY2/examples/Standalone
RAM for global variables,%,Arduino_BHY2/examples/StandaloneFlashStorage
flash,%,Arduino_BHY2/examples/StandaloneFlashStorage
RAM for global variables,%,Arduino_BHY2Host/examples/Accelerometer
flash,%,Arduino_BHY2Host/examples/Accelerometer
RAM for global variables,%,Arduino_BHY2Host/examples/Orientation
flash,%,Arduino_BHY2Host/examples/Orientation
RAM for global variables,%,Arduino_BHY2Host/examples/Temperature
flash,%,Arduino_BHY2Host/examples/Temperature
RAM for global variables,%,Arduino_BHY2Host/examples/Nicla_IoT_Bridge
flash,%,Arduino_BHY2Host/examples/Nicla_IoT_Bridge
RAM for global variables,%,Arduino_BHY2Host/examples/Portenta_BLE_Bridge
flash,%,Arduino_BHY2Host/examples/Portenta_BLE_Bridge
RAM for global variables,% arduino:mbed_nicla:nicla_sense,0,0.0,0,0.0,0,0.0,0,0.0,-2180,-0.41,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,8,0.01,0,0.0,0,0.0,64,0.01,8,0.01,0,0.0,8,0.01 arduino:mbed_portenta:envie_m7,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A arduino:samd:mkrgsm1400,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,,,, arduino:samd:mkrnb1500,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,,,, arduino:samd:mkrwan1310,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,,,, arduino:samd:mkrwifi1010,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,, arduino:samd:mkrzero,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,,,, ```
aliphys commented 1 year ago

The new firmware does indeed solve the problem. Tested on multiple Nicla Sense ME boards:

Temperature Values

user@user-laptop:~/github/nicla-sense-me-fw$ arduino-cli monitor -p /dev/ttyACM0 -c baudrate=115200
Monitor port settings:
baudrate=115200
Connected to /dev/ttyACM0! Press CTRL-C to exit.
29.590
29.600
29.610
29.620
29.640
29.660
29.680
29.690

Gas Values

user@user-laptop:~/github/nicla-sense-me-fw$ arduino-cli monitor -p /dev/ttyACM0 -c baudrate=115200
Monitor port settings:
baudrate=115200
Connected to /dev/ttyACM0! Press CTRL-C to exit.
5684.000
5684.000
5684.000
5684.000
5684.000
5684.000