Digital thermostat with ESPDUINO
Автор: Mark Harrington
Загружено: 2025-10-21
Просмотров: 15
#esp8266 ,#espduino , #IOT, #thermostat ,#weppages ,#embedded,#arduino,#css, #html, #javascript ,#json , #php, #heating , #www.doit.am, #temu, #bangood,# ,#amazon , #programming , #webservers
This code turns an ESP8266 NodeMCU/Wemos D1 Mini into a Wi-Fi-controlled smart thermostat with a simple web interface.
Here’s a brief explanation of how it works — broken down into key parts
Overall Purpose
• It reads temperature from a DS18B20 sensor.
• Controls a heater (simulated by the onboard LED).
• Hosts a Wi-Fi web page where you can view and adjust temperature and mode (auto/manual).
1. Setup and Configuration
WiFiServer server(80);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
Sets up communication with:
• Wi-Fi network.
• DS18B20 temperature sensor via OneWire and DallasTemperature libraries.
• A local web server on port 80.
Connects the ESP8266 to your Wi-Fi with a static IP (192.168.0.249).
2. Reading Temperature
Reads the current temperature (°C) from the first connected DS18B20 sensor.
• Every 2 seconds in loop(), it updates the reading:
3. Heater Control Logic
In AUTO mode, it turns the heater ON when the room is cold and OFF when it’s warm.
• The built-in LED on D0 shows heater status:
• LOW (ON) → heater active
• HIGH (OFF) → heater off
Web Server Control
The ESP8266 serves a web interface accessible at
http://192.168.0.249/
You can control it with simple HTTP GET requests:
URL
Action
/on
Turn heater ON (manual mode)
/off
Turn heater OFF (manual mode)
/auto
Return to automatic mode
/set?t=23.5
Set target temperature
/data
Get JSON data for AJAX updates
5. Web Interface (HTML + JS)
The code sends an HTML page with:
• Live temperature display.
• Buttons: ON, OFF, AUTO.
• A circular knob for adjusting target temperature (10–30 °C).
• JavaScript for:
◦ Fetching live /data every 3 s.
◦ Sending updates when the user interacts with the controls.
6. LED and Heater Status
LED shows when heater is ON.
• Printed debug info (via Serial Monitor):
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: