0% found this document useful (0 votes)
29 views2 pages

Iot Exp 7

The document outlines an IoT experiment involving the interfacing of an LM35 temperature sensor with an ESP32 microcontroller. It includes a code snippet that reads the temperature in both Celsius and Fahrenheit and prints it to the Serial Monitor. The experiment is conducted by Raj Shah, with a focus on temperature measurement using ADC values from the sensor.

Uploaded by

Raj Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views2 pages

Iot Exp 7

The document outlines an IoT experiment involving the interfacing of an LM35 temperature sensor with an ESP32 microcontroller. It includes a code snippet that reads the temperature in both Celsius and Fahrenheit and prints it to the Serial Monitor. The experiment is conducted by Raj Shah, with a focus on temperature measurement using ADC values from the sensor.

Uploaded by

Raj Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

IOT Experiment 7

Name : Raj Shah Sap Id:60019210056


Batch: A2
________________________________________________________________

Aim: Interfacing of LM35 using ESP32.

Code:

#define ADC_VREF_mV 3300.0 // in millivolt


#define ADC_RESOLUTION 4096.0
#define PIN_LM35 13 // ESP32 pin D13 connected to LM35

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

void loop() {
// read 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 °C
float tempC = milliVolt / 10;
// convert the °C to °F
float tempF = tempC * 9 / 5 + 32;

// print the temperature in the Serial Monitor:


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

delay(500);
}
IOT Experiment 7

Conclusion:

You might also like