File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 11// Package scd4x provides a driver for the scd4x I2C envrironment sensor.
22//
3- // Datasheet: https://sensirion.com/media/documents/C4B87CE6/61652F80/Sensirion_CO2_Sensors_SCD4x_Datasheet .pdf
3+ // Datasheet: https://sensirion.com/media/documents/C4B87CE6/627C2DCD/CD_DS_SCD40_SCD41_Datasheet_D1 .pdf
44//
55// This driver is heavily influenced by the scd4x code from Adafruit for CircuitPython:
66// https://github.com/adafruit/Adafruit_CircuitPython_SCD4X
@@ -115,7 +115,8 @@ func (d *Device) ReadTemperature() (temperature int32, err error) {
115115 if ok {
116116 err = d .ReadData ()
117117 }
118- return (- 1 * 45 ) + 175 * (int32 (d .temperature )/ 0x100000 )* 1000 , err
118+ // temp = -45 + 175 * value / 2¹⁶
119+ return (- 1 * 45000 ) + (21875 * (int32 (d .temperature )) / 8192 ), err
119120}
120121
121122// ReadTempC returns the value in the temperature value in Celsius.
@@ -138,7 +139,8 @@ func (d *Device) ReadHumidity() (humidity int32, err error) {
138139 if ok {
139140 err = d .ReadData ()
140141 }
141- return (100 * int32 (d .humidity ) / 0x100000 ), err
142+ // humidity = 100 * value / 2¹⁶
143+ return (25 * int32 (d .humidity )) / 16384 , err
142144}
143145
144146func (d * Device ) sendCommand (command uint16 ) error {
You can’t perform that action at this time.
0 commit comments