Page 1 of 1

Grove (Seeed Studio) temp sensor 101020015 compatibility issue

Posted: Thu Feb 17, 2022 2:26 am
by EdtheWino
Evidently the ADC module w/ the ESP32 does not properly extrapolate the conversion algorithm
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?
  1.   #include <math.h>
  2.  
  3.   #define ONBOARD_LED  2  
  4.  
  5.  
  6.     const int switchPin = 4;    // Board Digital Input GPIO4
  7.     int switchState = 0;
  8.  
  9.     const int B = 4275;               // B value of the thermistor;  +- 275 = .6 C (1.0 F)
  10.     const uint32_t R0 = 100000;            // R0 = 100k; int type uint32_t required (unsigned 32 bit)
  11.     const int tmp_adj_1 = 4;                      // sensor 1 calibration adjustment
  12.      
  13.     float space_temp_1;                      //    Grove - Temperature Sensor connect to (GPIO) input pin
  14.     float sp_temp_1;
  15.     float sp_temp_1F;
  16.     float Low_Tmp_Alm = 38.00;      // Low Alarm Setpoint  
  17.  
  18. void loop()
  19. {
  20.   digitalWrite(ONBOARD_LED,HIGH);            //  Blink for run indicator
  21.      delay(200);
  22.      digitalWrite(ONBOARD_LED, LOW);
  23.      
  24.      switchState = digitalRead(switchPin);       //Pressure Input Pin Read
  25.      space_temp_1 = analogRead(39);            // Space Temp Input Read
  26.      
  27.      delay(500);
  28.                  //  ***************** Low Alarm Function ***************
  29.  
  30.       float R1 = 1023.0 / space_temp_1 - 1.0;
  31.       R1 = R0 * R1;
  32.            
  33.       float sp_temp_1 = 1.0 / (log(R1 / R0) / B + 1 / 298.15) - 273.15;   //  convert to temperature via datasheet
  34.       float sp_temp_1F = (sp_temp_1 * 9 / 5) + 32 - tmp_adj_1;            // convert C to F    
  35.      
  36.                                      
  37.       Serial.println("........");
  38.       Serial.println("                  Space Temp =     ");
  39.       Serial.print(sp_temp_1);
  40.       Serial.println();
  41.       Serial.println("........");
  42.  //     Serial.println("                 Pressure Alarm input =     ");
  43.  //     Serial.print(switchState);
  44.       Serial.println();
  45.  
  46.  
  47. }

Re: Grove (Seeed Studio) temp sensor 101020015 compatibility issue

Posted: Thu Feb 17, 2022 6:55 pm
by lbernstone
I'm actually surprised you aren't getting division by zero errors.
You need to set the pinMode in your setup (or at the top of your loop).

Code: Select all

pinMode(39, INPUT);

Re: Grove (Seeed Studio) temp sensor 101020015 compatibility issue

Posted: Thu Feb 17, 2022 10:34 pm
by EdtheWino
deleted

Re: Grove (Seeed Studio) temp sensor 101020015 compatibility issue

Posted: Thu Feb 17, 2022 10:35 pm
by EdtheWino
lbernstone wrote:
Thu Feb 17, 2022 6:55 pm
I'm actually surprised you aren't getting division by zero errors.
You need to set the pinMode in your setup (or at the top of your loop).

Code: Select all

pinMode(39, INPUT);
Ibernstone,

I inadvertently failed to copy the void setup() into the original post. The pinMode is defined there.