sparkfun / SparkFun_SCD4x_Arduino_Library

An Arduino library for the Sensirion SCD4x (SCD40 and SCD41) family of CO2 sensors
Other
10 stars 8 forks source link

Running Example 6 (Signal Compensation, Sensor Altitude is reported as a binary number #1

Closed MattMills closed 3 years ago

MattMills commented 3 years ago
21:58:28.811 -> SCD40::begin: got serial number 0x98EA5F073B62
21:58:29.332 -> Periodic measurement is disabled!
21:58:29.332 -> Temperature offset is currently: 5.00
21:58:29.332 -> Temperature offset is now: 5.00
21:58:29.332 -> Sensor altitude is currently: 1111101000
21:58:29.332 -> Sensor altitude is now: 1111101000
21:58:29.332 -> setAmbientPressure was successful

1111101000 == 1000 so I guess it's technically right?

PaulZC commented 3 years ago

Hi @MattMills ,

Thanks for reporting this. Clearly I didn't test that example thoroughly enough!

Removing the ,2 after the mySensor.getSensorAltitude() will fix that. The altitude is returned as an integer, not a float, so the ,2 is making it print in binary, not to two decimal places.

That part of the example should be:

  Serial.print(F("Sensor altitude is currently: "));
  Serial.println(mySensor.getSensorAltitude()); // Print the sensor altitude
  mySensor.setSensorAltitude(1000); // Set the sensor altitude to 1000m
  Serial.print(F("Sensor altitude is now: "));
  Serial.println(mySensor.getSensorAltitude()); // Print the sensor altitude

Best wishes, Paul

PaulZC commented 3 years ago

Corrected in v1.0.2 Closing...