Using LM35 in ESP32

Hello Friends,

I'm trying to print ina oled display the temperature value obtained by a LM35 connected to an analog port on an ESP32 Devboard.

I have connected an DHT11 sensor to make a comparison with the value measured by the LM35 and unfortunately those values are wrong despite the voltage in LM35 is correct (stable in a room temperature and increase with the heat of my finger). The resolution in 10mV/ºC, thus, the respective values found were 250 mV and 360 mV respectively.

The LM35 is charged with 5V (minimum value)and the analog reference tension in ESP32 is 3.3V.

In this case, what is the right way to read the values. Is there something related with the analogReference?

Thanks in advance!

Check this project instructions
https://create.arduino.cc/projecthub/infoelectorials/project-003-arduino-lm35-temperature-sensor-project-0a43ba
Hope this helps :slight_smile:

Hi,

How can you measure an output voltage off a DHT11?
It is a one wire comms system that returns humidity and temperature values.

Tom... :smiley: :+1: :coffee: :australia:

I would venture to say that the LM35 is the wrong thing to use with a ESP32 unless some adjustments are made. If one was to look at a LM35 data sheet one would find that the input voltage is from 4V <<<<

One would find the output voltage to be between -1 to 6 V <<<<

The ESP32 is a 3.3V device. The output of the LM35 can exceed the 3.3V limits of the ESP32.

Hi,
I think we need a schematic.

Tom... :smiley: :+1: :coffee: :australia:

Dear Colleagues,

I have found this code and it seems to work. Any suggestion?

https://esp32io.com/tutorials/esp32-lm35-temperature-sensor

I Just changed the ADC_VREF_mV to 5000 and the PIN_LM35 to 35.

/*

#define ADC_VREF_mV 5000.0 // in millivolt
#define ADC_RESOLUTION 4095.0
#define PIN_LM35 35

void setup() {
Serial.begin(9600);
}

void loop() {
// get the ADC value from the temperature sensor
int adcVal = analogRead(PIN_LM35);
// convert the ADC value to voltage in millivolt
float milliVolt = adcVal * (ADC_VREF_mV / ADC_RESOLUTION);
// convert the voltage to the temperature in Celsius
float tempC = milliVolt / 10;
// convert the Celsius to Fahrenheit
float tempF = tempC * 9 / 5 + 32;

// print the temperature in the Serial Monitor:
Serial.print("Temperature: ");
Serial.print(tempC); // print the temperature in Celsius
Serial.print("°C");
Serial.print(" ~ "); // separator between Celsius and Fahrenheit
Serial.print(tempF); // print the temperature in Fahrenheit
Serial.println("°F");

delay(1000);
}

Response in Serial:

18:56:07.475 -> Temperature: 27.47°C ~ 81.45°F
18:56:08.456 -> Temperature: 27.35°C ~ 81.23°F
18:56:09.436 -> Temperature: 27.23°C ~ 81.01°F
18:56:10.466 -> Temperature: 27.11°C ~ 80.79°F
18:56:11.449 -> Temperature: 27.23°C ~ 81.01°F
18:56:12.475 -> Temperature: 26.98°C ~ 80.57°F
18:56:13.457 -> Temperature: 27.11°C ~ 80.79°F
18:56:14.442 -> Temperature: 27.35°C ~ 81.23°F
18:56:15.472 -> Temperature: 27.35°C ~ 81.23°F
18:56:16.454 -> Temperature: 27.11°C ~ 80.79°F
18:56:17.480 -> Temperature: 27.35°C ~ 81.23°F
18:56:18.460 -> Temperature: 27.11°C ~ 80.79°F

The mean room temperature is 26.3 ºC (measured with thermometer)


Dear Tom, I had connected both. The DHT11 had been used to compare its temperature with the temperature value read in the LM35.

Calculate what temperature would produce an output of 3.3V and make sure the device never gets any hotter than that.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.