I’m working with two Nicla Sense ME boards, trying to read the values from the BMP390 pressure sensor. I have uploaded the same example sketch for pressure provided by the BHY2 library to both boards.
Here’s the problem: in the serial monitor, one of the boards provides reasonable data, such as 984.25 hPa, which is very similar to the readings from my iPhone. Meanwhile, the other board returns anomalous values like 98636.23 hPa. This value, when considered in hPa, doesn’t make sense. If interpreted in Pascal, 98636.23 Pa would be equivalent to 986.3623 hPa , but this still leads to different results between the two boards.
I have attached a screenshot of what I observed for your reference.
I wonder what could be causing this difference in the data printed in the serial monitor, both in terms of values and order of magnitude. Has anyone encountered a similar issue or have suggestions on how to resolve it?
The sensors are not calibrated and exhibit random noise, so all other things being equal, you should expect two different sensors to almost always produce somewhat different readings.
/*
* This example shows how to use the access the pressure data and send it over serial.
*
* Every 1 second, this sketch will send the pressure in hPa over serial.
* SensorID 129 (SENSOR_ID_BARO) is read with the Sensor class from the BMP390.
*
* Instructions:
* 1. Upload this sketch to your Nicla Sense ME board.
* 2. Open the Serial Monitor at a baud rate of 115200.
* 3. The pressure will be printed to the serial monitor.
*
* Initial author: @mcmchris
*/
#include "Nicla_System.h"
#include "Arduino_BHY2.h"
unsigned long previousMillis = 0; // will store last time the sensor was updated
const long interval = 1000;
Sensor pressure(SENSOR_ID_BARO);
SensorConfig cfg;
void setup() {
Serial.begin(9600);
nicla::begin();
BHY2.begin(NICLA_I2C);
pressure.begin();
}
void loop() {
BHY2.update();
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
Serial.println(String(pressure.value()) + " hPa");
cfg = pressure.getConfiguration();
Serial.println(String("Pressure configuration - rate: ") + cfg.sample_rate + String("Hz - latency: ") + cfg.latency + String("ms - range: ") + cfg.range + String("Hz - sensitivity: ") + cfg.sensitivity);
}
}
The sketch you linked does not printout the "Pressure configuration".
The configurations are different.
Since you stated the two data outputs were a screenshot, its not clear how this was configured, are you trying to run two sensors at the same time? If so, how?
I've not used the BMP390, however in my experience Bosch sensors meet their published specifications.
I suggest you run the example on one board, then disconnect it and run the same code (without any changes) on the other board.
No, I didn't use the two boards at the same time, I simply left the serial monitor open to be able to view the differences between the two.
I run the example on one board, disconnected it, connected the other board and run the example, in order to see the difference between the datas.
I added the lines relating to the configurations out of curiosity. could the different configuration be the problem?
Probably far outside my area of knowledge but I'm a little confused.
When you refer to "two boards", are you referring two Nicla Sense ME boards and one sensor that you swap around? Or two different sensors each connected to their own Nicla Sense ME? Or ...