offered by Seeed. The analog value displayed is always: -273.15; the last parameter used in the 1st line of the algorithm.
Is there a workaround for this issue?
- #include <math.h>
- #define ONBOARD_LED 2
- const int switchPin = 4; // Board Digital Input GPIO4
- int switchState = 0;
- const int B = 4275; // B value of the thermistor; +- 275 = .6 C (1.0 F)
- const uint32_t R0 = 100000; // R0 = 100k; int type uint32_t required (unsigned 32 bit)
- const int tmp_adj_1 = 4; // sensor 1 calibration adjustment
- float space_temp_1; // Grove - Temperature Sensor connect to (GPIO) input pin
- float sp_temp_1;
- float sp_temp_1F;
- float Low_Tmp_Alm = 38.00; // Low Alarm Setpoint
- void loop()
- {
- digitalWrite(ONBOARD_LED,HIGH); // Blink for run indicator
- delay(200);
- digitalWrite(ONBOARD_LED, LOW);
- switchState = digitalRead(switchPin); //Pressure Input Pin Read
- space_temp_1 = analogRead(39); // Space Temp Input Read
- delay(500);
- // ***************** Low Alarm Function ***************
- float R1 = 1023.0 / space_temp_1 - 1.0;
- R1 = R0 * R1;
- float sp_temp_1 = 1.0 / (log(R1 / R0) / B + 1 / 298.15) - 273.15; // convert to temperature via datasheet
- float sp_temp_1F = (sp_temp_1 * 9 / 5) + 32 - tmp_adj_1; // convert C to F
- Serial.println("........");
- Serial.println(" Space Temp = ");
- Serial.print(sp_temp_1);
- Serial.println();
- Serial.println("........");
- // Serial.println(" Pressure Alarm input = ");
- // Serial.print(switchState);
- Serial.println();
- }