3.1 KiB
3.1 KiB
🌡️ Arduino Sketch: DS18B20 Sensor via Wi-Fi (REST Endpoints & Dashboard)
This example Sketch demonstrates how to use the Arduino Temperature Control Library on an ESP8266 or ESP32 to read temperature data from Maxim (Dallas) DS18B20 sensors. The Sketch publishes the readings via Wi-Fi in two ways:
- REST Endpoints - Ideal for Node-RED, Home Assistant, or other automation platforms.
- A Human-Friendly Dashboard - A simple web interface, powered by Chart.js and Tailwind CSS, displaying current and historical temperatures.
🔎 Features
- Reads from one or more DS18B20 temperature sensors
- Configurable polling interval (in milliseconds) and history length (number of readings)
- Lightweight dashboard that visualizes the last N readings
- REST endpoints for easy integration:
/temperature- current readings/sensors- sensor addresses/history- historical data
📚 Potential Use Cases
- Node-RED automation flows: Perform regular HTTP GET requests against
/temperatureor/history - Home Assistant integrations: Use built-in REST sensors to track temperature over time
- Extensible to other sensor types (humidity, light, pressure, etc.) by following the same approach
🛠️ Getting Started
- Clone or download this repository
- Open the Sketch (the
.inofile) in the Arduino IDE (or other environment) - Install dependencies:
- Arduino Temperature Control Library
- ESP8266 or ESP32 core for Arduino
- Set your Wi-Fi credentials in the code:
const char* ssid = "YourNetwork";
const char* password = "YourPassword";
- Adjust the interval and history:
// Configuration
const unsigned long READ_INTERVAL = 10000; // e.g. 10 seconds
const int HISTORY_LENGTH = 360; // 1 hour at 10-second intervals
- Connect the DS18B20 sensor(s) to the ESP, using OneWire with a pull-up resistor
- Upload the Sketch to your device
- Check the serial monitor for the IP
- Navigate to that IP in your browser to see the chart-based interface
❓ Questions & Support
- Library Matters: If you have issues with the Arduino Temperature Control Library itself, please open a ticket in the official repository
- This Sketch: For help customizing this example, dealing with Wi-Fi issues, or setting up the chart dashboard, and other device-specific tweaks, please visit the Arduino Forum. You will find many friendly developers there ready to help.
📜 License
This project is distributed under the MIT License.
We hope you find this Sketch useful for monitoring temperatures - both in a machine-readable (REST) and human-friendly (web dashboard) format. Happy hacking! 🚀