ESP32 Weather Machine #2
Overview
This project demonstrates a simple temperature monitoring system using ESP32 and a digital temperature sensor.
The system reads temperature data and prints it to the Serial Monitor every 2 seconds.
Components Used
- ESP32 Dev Module
- DS18B20 Temperature Sensor
- 4.7k Pull-up Resistor
- Breadboard
- Jumper Wires
Working Principle
The DS18B20 sensor communicates with the ESP32 using the OneWire protocol.
The ESP32 reads temperature data and processes it in real-time.
Circuit Connection
- VCC → 3.3V
- GND → GND
- Data → GPIO 4
- 4.7k resistor between Data and VCC
Code Snippet
“`cpp
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup() {
Serial.begin(115200);
sensors.begin();
}
void loop() {
sensors.requestTemperatures();
Serial.println(sensors.getTempCByIndex(0));
delay(2000);
}
Results
The temperature values are printed continuously on the Serial Monitor.
The system can be extended to log data or send readings over WiFi.