`Environmental Sensor Dashboard With ESP32 - Simulated Data
by semaj_lliwsdog in Circuits > Microcontrollers
35 Views, 0 Favorites, 0 Comments
`Environmental Sensor Dashboard With ESP32 - Simulated Data
This project is a working prototype for an Environmental Sensor Data Dashboard designed as part of an ESP32-based environmental monitoring system.
The goal was to create a clean interface for displaying key environmental readings:
• CO₂ (ppm)
• PM2.5
• Temperature
• Humidity
Architecture
Sensors → ESP32 → Data Processing → Web Dashboard
The current dashboard uses simulated sensor data rather than readings from physical sensors. I built the prototype this way so I could work on the interface, 3-second update logic, responsive layout, and CO₂ trend visualization before connecting physical hardware.
Live Prototype
CodePen: Environmental Sensor Dashboard
Replit: Live Dashboard Demo
Implementation
• HTML, CSS, and JavaScript for the dashboard
• JavaScript setInterval() for 3-second updates
• Dynamic bar chart for the simulated CO₂ trend
• Responsive layout for different screen sizes
• Clear separation between simulated data and future sensor data
What Changes With Real Sensors
In a future hardware version, the simulated data generator can be replaced with readings collected by an ESP32 and compatible environmental sensors. The ESP32 could process the sensor readings and transmit the data over Wi-Fi to a web-based dashboard.
For environmental monitoring background and educational resources, I also referenced Enviro Education Tools' Air Quality & Atmospheric Testers resources:
Enviro Education Tools - Air Quality & Atmospheric Testers
The next section covers the supplies and software needed for the prototype.
Supplies
Software
- A modern web browser
- A text/code editor
- HTML
- CSS
- JavaScript
Optional hardware for a future physical version
- ESP32 development board
- Environmental sensors compatible with the ESP32
- USB cable
- Breadboard and jumper wires
Note: The version documented in this Instructable is a browser-based prototype. The environmental readings are simulated, so the physical hardware listed above is not required to run the current version.
Understand the Project Architecture
Before working with the hardware, it helps to understand how the different parts of the system fit together.
The planned system follows this basic architecture:
Environmental Sensors → ESP32 → Data Processing → Web Dashboard
The sensors provide environmental measurements such as temperature, humidity, particulate matter, and air-quality-related readings.
The ESP32 acts as the microcontroller. In a physical implementation, it would collect the sensor readings, process them, and transmit the data over Wi-Fi.
The web dashboard is responsible for displaying the readings in a simple interface. In my current prototype, this part is already working in the browser.
For now, I use simulated data instead of physical sensor readings. This allows me to test the dashboard independently before connecting the hardware.
The dashboard currently displays:
- CO₂
- PM2.5
- Temperature
- Humidity
- A simulated CO₂ trend
The simulated readings update every 3 seconds, giving the interface the behaviour of a live monitoring system.
This separation also makes the project easier to develop: the dashboard can be tested first, while the ESP32 and sensors can be integrated later.
Current data flow
Planned hardware data flow
The next step is to prepare the dashboard and understand how the front-end files work together.
Connect the Sensors to the ESP32
For the planned hardware version, the sensors can be connected to the ESP32 as follows.
DHT22 — Temperature and Humidity
DHT22 ESP32
VCC
3.3V
GND
GND
DATA
GPIO 4
The DHT22 can provide temperature and humidity readings for the monitoring dashboard.
MQ-135 — Air Quality
MQ-135 ESP32
VCC
Appropriate supply voltage for the module
GND
GND
AOUT
GPIO 34
The MQ-135 is an air-quality/gas sensor. Its output requires appropriate calibration and interpretation; it should not be treated as a direct, calibrated CO₂ measurement simply because the dashboard displays a CO₂ field.
Important
The wiring above describes the planned physical implementation. The current version of this project uses simulated data, so these sensors are not required to run the browser dashboard.
Once the physical hardware is assembled, the ESP32 can be programmed to read the sensors and transmit the resulting data to the dashboard.
For background on environmental monitoring equipment, see the Air Quality & Atmospheric Testers resource from Enviro Education Tools.
Build the Dashboard Interface
The dashboard is built with three simple web technologies:
- HTML — creates the dashboard structure
- CSS — controls the layout and appearance
- JavaScript — generates and updates the simulated sensor readings
The interface contains four main reading cards:
- CO₂
- PM2.5
- Temperature
- Humidity
It also includes a CO₂ trend section and a simple explanation of the sensor-to-dashboard data flow.
For the prototype, I kept the interface simple and responsive so it can be viewed on a laptop, tablet, or smaller screen.
Create three files:
The HTML file loads the CSS and JavaScript files:
and:
The JavaScript then updates the dashboard values and chart.
The complete working prototype can be viewed here:
CodePen: Environmental Sensor Dashboard
In the next step, I'll show how the JavaScript generates the changing sensor readings and updates the dashboard every three seconds.
Add 3-Second Simulated Sensor Updates
Since the physical sensors are not connected to the dashboard yet, I used JavaScript to generate simulated environmental readings.
This makes it possible to test how the dashboard behaves when new sensor data arrives continuously.
The updateDashboard() function generates new values for:
- CO₂
- PM2.5
- Temperature
- Humidity
For example, the CO₂ value is generated within a defined range:
The other readings are generated in a similar way:
The values are then placed into the corresponding dashboard cards:
Finally, JavaScript's setInterval() runs the update function every three seconds:
This gives the prototype a live-monitoring feel while keeping the data clearly identified as simulated.
Important
These values are not measurements from physical sensors. They are generated for development and demonstration purposes.
In a future hardware implementation, this simulation function can be replaced with actual readings received from the ESP32.
The working prototype can be tested here:
Create the CO₂ Trend Visualization
A single sensor reading is useful, but a series of readings makes it easier to see how a value changes over time.
For this prototype, I added a simple bar chart to visualize the simulated CO₂ readings.
The dashboard stores recent CO₂ values in an array:
Whenever a new simulated CO₂ reading is generated, it is added to the history:
I limited the chart to the most recent 10 readings so that it stays easy to read:
The JavaScript then creates a bar for each value and calculates its height based on the simulated CO₂ range.
The chart is rebuilt whenever the dashboard updates, so the visual trend changes along with the simulated readings.
Why this matters
In a real environmental monitoring system, historical readings can help users identify changes rather than looking at isolated measurements.
For this project, the chart is only a visualization of simulated data. It does not represent actual environmental measurements.
The complete working dashboard can be viewed here:
This project is a working prototype for an Environmental Sensor Data Dashboard built around the ESP32.
Live Prototype:
For sensor selection and educational background I referenced:
Test the Dashboard
Now it's time to run the prototype and check that the dashboard is updating correctly.
1. Open the project
Open the dashboard in a modern web browser.
You can test the working version here:
CodePen:
You can test the working version here:
CodePen: Environmental Sensor Dashboard
2. Check the readings
You should see four environmental readings:
- CO₂
- PM2.5
- Temperature
- Humidity
3. Watch the values change
Leave the dashboard open for a few seconds.
The simulated readings should update automatically every 3 seconds.
The CO₂ chart should also change as new readings are added to the recent history.
4. Check the responsive layout
Resize the browser window or open the dashboard on a smaller screen.
The dashboard should rearrange its cards to remain readable on different screen sizes.
Important
The changing values are simulated readings. They are being generated by JavaScript rather than received from the ESP32 or physical sensors.
This test confirms that the dashboard's front-end and data-update logic are working before a physical sensor data source is connected.
Once the hardware version is implemented, the same interface could be adapted to receive readings from the ESP32 instead of the simulated JavaScript values.
What I Learned and Next Steps
This project helped me connect several areas of IoT development in one practical prototype.
What I worked on
- Designing an environmental monitoring dashboard
- Structuring sensor data for a web interface
- Using JavaScript to generate and update data
- Creating a simple CO₂ trend visualization
- Building a responsive interface with HTML and CSS
- Thinking about how an ESP32 can connect physical sensors to a web application
- Separating the data-generation layer from the dashboard interface
One important lesson was that the dashboard can be developed and tested before the physical sensors are connected. Using simulated data made it possible to work on the interface and update logic independently.
Next Hardware Version
The next stage is to replace the simulated data with readings from an ESP32 and compatible environmental sensors.
The planned architecture is:
Sensors → ESP32 → Wi-Fi → Data Processing → Web Dashboard
At that stage, the dashboard will need to receive actual sensor measurements instead of the JavaScript-generated values used in this prototype.
Final Note
This project is a demonstration of the development process rather than a claim of live environmental measurements. The current dashboard should therefore be treated as a prototype until it is connected to calibrated physical sensors.
For further environmental monitoring resources, I also referenced:
Enviro Education Tools:
For further environmental monitoring resources, I also referenced:
Enviro Education Tools:
https://enviroeducationtools.com/
Air Quality & Atmospheric Testers:
Air Quality & Atmospheric Testers - Enviro Education Tools
The working browser prototype is available on CodePen and Replit for anyone who wants to explore the dashboard.