|  | 
|  | 1 | +# 🌡️ Arduino Sketch: DS18B20 Sensor via Wi-Fi (REST Endpoints & Dashboard) | 
|  | 2 | + | 
|  | 3 | +This **example Sketch** demonstrates how to use the [Arduino Temperature Control Library](https://github.com/milesburton/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: | 
|  | 4 | + | 
|  | 5 | +1. **REST Endpoints** - Ideal for Node-RED, Home Assistant, or other automation platforms. | 
|  | 6 | +2. **A Human-Friendly Dashboard** - A simple web interface, powered by [Chart.js](https://www.chartjs.org/) and [Tailwind CSS](https://tailwindcss.com/), displaying current and historical temperatures. | 
|  | 7 | + | 
|  | 8 | +--- | 
|  | 9 | + | 
|  | 10 | +## 🔎 Features | 
|  | 11 | +- Reads from one or more **DS18B20** temperature sensors | 
|  | 12 | +- Configurable **polling interval** (in milliseconds) and **history length** (number of readings) | 
|  | 13 | +- **Lightweight dashboard** that visualizes the last N readings | 
|  | 14 | +- **REST endpoints** for easy integration: | 
|  | 15 | +  - `/temperature` - current readings | 
|  | 16 | +  - `/sensors` - sensor addresses | 
|  | 17 | +  - `/history` - historical data | 
|  | 18 | + | 
|  | 19 | +--- | 
|  | 20 | + | 
|  | 21 | +## 📚 Potential Use Cases | 
|  | 22 | +- **Node-RED** automation flows: Perform regular HTTP GET requests against `/temperature` or `/history` | 
|  | 23 | +- **Home Assistant** integrations: Use built-in REST sensors to track temperature over time | 
|  | 24 | +- **Extensible to other sensor types** (humidity, light, pressure, etc.) by following the same approach | 
|  | 25 | + | 
|  | 26 | +--- | 
|  | 27 | + | 
|  | 28 | +## 🛠️ Getting Started | 
|  | 29 | +1. **Clone or download** this repository | 
|  | 30 | +2. **Open the Sketch** (the `.ino` file) in the Arduino IDE (or other environment) | 
|  | 31 | +3. **Install dependencies**: | 
|  | 32 | +   - [Arduino Temperature Control Library](https://github.com/milesburton/Arduino-Temperature-Control-Library) | 
|  | 33 | +   - ESP8266 or ESP32 core for Arduino | 
|  | 34 | +4. **Set your Wi-Fi credentials** in the code: | 
|  | 35 | +```cpp | 
|  | 36 | +const char* ssid = "YourNetwork"; | 
|  | 37 | +const char* password = "YourPassword"; | 
|  | 38 | +``` | 
|  | 39 | +5. **Adjust** the interval and history: | 
|  | 40 | +```cpp | 
|  | 41 | +// Configuration | 
|  | 42 | +const unsigned long READ_INTERVAL = 10000; // e.g. 10 seconds | 
|  | 43 | +const int HISTORY_LENGTH = 360; // 1 hour at 10-second intervals | 
|  | 44 | +``` | 
|  | 45 | +6. **Connect** the DS18B20 sensor(s) to the ESP, using OneWire with a pull-up resistor | 
|  | 46 | +7. **Upload** the Sketch to your device | 
|  | 47 | +8. **Check** the serial monitor for the IP | 
|  | 48 | +9. **Navigate** to that IP in your browser to see the chart-based interface | 
|  | 49 | + | 
|  | 50 | +--- | 
|  | 51 | + | 
|  | 52 | +## ❓ Questions & Support | 
|  | 53 | +- **Library Matters**: If you have issues with the **Arduino Temperature Control Library** itself, please open a ticket in the [official repository](https://github.com/milesburton/Arduino-Temperature-Control-Library/issues) | 
|  | 54 | +- **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](https://forum.arduino.cc/). You will find many friendly developers there ready to help. | 
|  | 55 | + | 
|  | 56 | +--- | 
|  | 57 | + | 
|  | 58 | +## 📜 License | 
|  | 59 | +This project is distributed under the [MIT License](https://opensource.org/licenses/MIT). | 
|  | 60 | + | 
|  | 61 | +> We hope you find this Sketch useful for monitoring temperatures - both in a machine-readable (REST) and human-friendly (web dashboard) format. Happy hacking! 🚀 | 
0 commit comments