A project that builds an asynchronous web server using ESP32 or ESP8266 to display real-time sensor data (temperature, humidity, pressure) on interactive charts. The web interface uses the Highcharts library to graph data collected from a BME280 sensor, with easy modification for other sensors.
- Introduction
- Prerequisites
- Parts Required
- Wiring Diagram
- File Organization
- Uploading Code and Files
- Project Structure
- How to Use
- License
In this project, we will build an asynchronous web server using the ESPAsyncWebServer library, which will serve HTML pages stored in the ESP32 or ESP8266 filesystem (LittleFS). The project reads sensor data from a BME280 sensor and displays it on a web interface, updating in real-time with interactive charts.
You can modify this project to use any other sensor readings, such as a temperature sensor, humidity sensor, etc.
Before you start, make sure to have the following setup:
-
Install ESP Board in Arduino IDE:
- Install the ESP32 or ESP8266 add-on for Arduino IDE.
- Follow these tutorials for installation:
-
Filesystem Uploader Plugin:
To upload the HTML file to the ESP32 or ESP8266 flash memory, install the Filesystem Uploader plugin: -
Libraries Required:
- ESP32: Install
ESPAsyncWebServer
andAsyncTCP
libraries. - ESP8266: Install
ESPAsyncWebServer
andESPAsyncTCP
libraries. - BME280 Sensor: Install
Adafruit BME280
andAdafruit Unified Sensor
libraries.
- ESP32: Install
Go tho this page for more information
- ESP32 or ESP8266
- BME280 sensor
- Breadboard
- Jumper wires
- HT7333 LDO
The BME280 sensor uses I2C communication, and the wiring for the ESP8266 is as follows:
BME280 | ESP8266 |
---|---|
SCK (SCL) | GPIO 5 |
SDI (SDA) | GPIO 4 |
Make sure to connect the sensor to the correct I2C pins based on your specific board.
To structure your project, the Arduino sketch and HTML file must be organized as follows:
- ESP_Chart_Web_Server.ino (Arduino sketch)
- data (folder containing the HTML file)
Follow these steps to upload your project to the ESP32 or ESP8266:
- Save your Arduino sketch as
ESP_Chart_Web_Server.ino
or download all project files. - Create a folder called
data
in the sketch folder and place your HTML file inside. - To upload the HTML file to the ESP filesystem:
- Open Arduino IDE and press [Ctrl] + [Shift] + [P] (Windows) or [⌘] + [Shift] + [P] (MacOS).
- Search for the Upload LittleFS to ESP32/ESP8266 command and execute it.
- Ensure the Serial Monitor is closed during the upload process.
- Upload the Arduino code to your ESP board.
- Insert your network credentials (Wi-Fi SSID and password) in the code.
- Once uploaded, open the Serial Monitor at 115200 baud rate. Press the “EN/RST” button on the board to print the IP address.
ESP32-ESP8266-Real-Time-Sensor-Data-Plotting/
│
├── ESP32-ESP8266-Real-Time-Sensor-Data-Plotting.ino # Arduino Sketch
└── data/ # Folder containing HTML file
└── index.html # HTML file for the web interface
- Open the ESP_Chart_Web_Server.ino in Arduino IDE.
- Install the required libraries and plugins.
- Configure your Wi-Fi credentials in the code.
- Upload the HTML file using the Filesystem Uploader plugin.
- Upload the Arduino sketch to your ESP32 or ESP8266 board.
- Open the Serial Monitor to get the IP address and navigate to it in your browser to view the real-time sensor data.
This project is licensed under the MIT License - see the LICENSE file for details.