Let me introduce you to the LM35 temperature sensor with ESP32. It is an integrated calibrated temperature sensor that offers an output of 10mV/ºC. All of that in the range of -55 to +150ºC; you can find its datasheet here.
Mechanically it is housed in a TO-92 case, not really very useful when one needs contact measurements. But a nice case for when one needs to measure “free air” on a circuit board and the likes.
As stated above, its sensitivity is 10mV per degree Celsius, meaning it will output (for example) 250mV @ 25 degrees Celsius.
The assembly
Below you can see the schematic diagram for our test. Notice how simple it is, just the LM35 connected to the ESP32-C6 development board.
Then the assembly on a breadboard is seen below, notice how diminute the sensor is.
Code and testing
The code below was written by myself, no help and no copying from the internet. It is simple enough, all you do is read the analog channel A1 and divide the result by ten. This allow the value in milivolts to be converted to degrees Celsius.
Then I present it on the Arduino IDE serial monitor, via Serial.print() to be seen on your computer screen.
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
int analogVolts = analogReadMilliVolts(A1);
long temperature = analogVolts / 10.0;
Serial.print("temperature= ");
Serial.print(temperature);
Serial.println(" oC");
delay(2000);
}
Results can be seen in the neat video below, where I explain everything I have written above. Enjoy!
Final words
LM35 is a cheap little temperature sensor, which is factory-calibrated and very precise. It can be used to read temperatures in “free air” while soldered to a print circuit board.
Do you want to know more temperature sensors? read this article about NTC thermistors.
Leave a Reply