File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -162,17 +162,18 @@ float SCD30::getTemperatureOffset(void)
162
162
return (((float )signedUnsigned.signed16 ) / 100.0 );
163
163
}
164
164
165
- // Set the temperature offset. See 1.3.8.
165
+ // Set the temperature offset to remove module heating from temp reading
166
166
bool SCD30::setTemperatureOffset (float tempOffset)
167
167
{
168
- union
169
- {
170
- int16_t signed16;
171
- uint16_t unsigned16;
172
- } signedUnsigned; // Avoid any ambiguity casting int16_t to uint16_t
173
- signedUnsigned.signed16 = tempOffset * 100 ;
168
+ // Temp offset is only positive. See: https://github.com/sparkfun/SparkFun_SCD30_Arduino_Library/issues/27#issuecomment-971986826
169
+ // "The SCD30 offset temperature is obtained by subtracting the reference temperature from the SCD30 output temperature"
170
+ // https://www.sensirion.com/fileadmin/user_upload/customers/sensirion/Dokumente/9.5_CO2/Sensirion_CO2_Sensors_SCD30_Low_Power_Mode.pdf
171
+
172
+ if (tempOffset < 0.0 ) return (false );
173
+
174
+ uint16_t value = tempOffset * 100 ;
174
175
175
- return sendCommand (COMMAND_SET_TEMPERATURE_OFFSET, signedUnsigned. unsigned16 );
176
+ return sendCommand (COMMAND_SET_TEMPERATURE_OFFSET, value );
176
177
}
177
178
178
179
// Get the altitude compenstation. See 1.3.9.
You can’t perform that action at this time.
0 commit comments