Hello,
I am programming an ESP-32 WROOM to accept a Grove (101020015) temp sensor input.
I am using the translation algorithm provided by Seeed that works fine with the Uno Wifi Rev2 I have. With the ESP32 the analog input follows the last part of the formula: -300. I changed it from -273.15 to -300 and the output changed to that value. Am I missing a library file possibly?
See the screenshot.
// Test ESP32 inputs
#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 setup()
{
pinMode(ONBOARD_LED,OUTPUT); // Blink LED function
pinMode(space_temp_1,INPUT);
pinMode(switchPin,INPUT); // Pressure Alarm Input
Serial.println("Begin loop top..");
// initialize serial:
Serial.begin(115200);
}
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) - 300;
// [ original value: -273.15 ] convert to temperature via datasheet
float sp_temp_1F = (sp_temp_1 * 9 / 5) + 32 - tmp_adj_1;
Serial.println("........");
Serial.println(" Space Temp = ");
Serial.print(sp_temp_1);
Serial.println();
Serial.println("........");
Serial.println();
}