Pages

Sunday 15 September 2019

ESP32-TEMPERATURE SENSOR

ESP32-TEMPERATURE SENSOR

Aim:
To extract information from temperature sensor.

Description:

To learn how to read values from a temperature sensor connected to analog pin using ESP32- Microcontroller.

Hardware required:

ESP32-Microcontroller Development board Temperature sensor.

Pin connection:

Pin Mapping:

TEMPERARUTE SENSOR
ESP32
5V
5V
GND
GND
A/O
IO35

Procedure:
1.        The above pin connection shows how to read values from a sensor using ESP32 board.
2.        Do the connections as shown in the pin diagram and pin mapping.
3.        Connect the USB cable to the board.
4.        Open Arduino IDE .Select DOIT ESP32 DEVKIT V1in boards and select COM port.
5.        Verify the program and Upload it.
6.        Now you can see the output on the serial monitor.

PROGRAM:

float temp; 
float value; 
float valuec;
int tempPin = 35;

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

void loop() {
temp = analogRead(tempPin);
// read analog volt from sensor and save to variable temp 
value=( temp/2048.0)*3300;
valuec=value*0.1;                      //converts to degree celsius
// convert the analog volt to its temperature equivalent Serial.print("temperature in C = "); 
Serial.println(valuec); // display temperature value Serial.println();
Serial.print("temperature = ");
Serial.println(value);
delay(1000); // update sensor reading each one second
}

Output:


No comments:

Post a Comment