Arduino Nano ESP32 - Web Apps Web Plotter

Overview

This tutorial covers the DIYablesWebPlotterPage class from the DIYables ESP32 WebApps Library. The page renders a streaming line chart in the browser. The Arduino Nano ESP32 sketch sends data points over WebSocket; the browser appends each point to the corresponding series in real time. Up to 8 independent data series are supported simultaneously.

Arduino Nano ESP32 Web Plotter

Watch this step-by-step video tutorial demonstrating how to use a DHT sensor with the Web Plotter app:

What This Tutorial Covers

  • Configuring the plotter title, axis labels, and sample retention limit
  • Sending named data points from the sketch using addDataPoint()
  • Plotting multiple series simultaneously
  • Replacing simulated data with real sensor readings

Hardware Preparation

1×Arduino Nano ESP32
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano ESP32

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Steps

Follow these instructions step by step:

  • If this is your first time using the Arduino Nano ESP32, refer to the tutorial on setting up the Arduino Nano ESP32 development environment.
  • Connect the Arduino Nano ESP32 board to your computer using a USB cable.
  • Launch the Arduino IDE on your computer.
  • Select the appropriate board (e.g. Arduino Nano ESP32) and COM port.
  • Navigate to the Libraries icon on the left bar of the Arduino IDE.
  • Search "DIYables ESP32 WebApps", then find the DIYables ESP32 WebApps Library by DIYables
  • Click Install button to install the library.
  • Search for DIYables ESP32 WebApps created by DIYables and click the Install button.
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Nano ESP32
Library Manager
Type:
All
Topic:
All
DIYables ESP32 WebApps by DIYables
A comprehensive library designed for ESP32 that provides multiple professional web applications including Web Monitor, Chat, Digital Pin Control, Sliders, Joystick, Analog Gauge, Rotator Control, and Temperature Display via WebSocket communication. Features modular architecture for memory efficiency, automatic config handling, and perfect for IoT projects, robotics, sensor monitoring, servo/stepper control, temperature monitoring, and remote ESP32 control. More info
1.0.1
INSTALL
Newbiely.ino
···
1 void setup() {
Output
Serial Monitor
Ln 1, Col 1
Arduino Nano ESP32 on COM15
1
  • You will be asked for installing some other library dependencies
  • Click Install All button to install all library dependencies.
  • On Arduino IDE, Go to File Examples DIYables ESP32 WebApps WebPlotter example, or copy the above code and paste it to the editor of Arduino IDE
/* * DIYables WebApp Library - Web Plotter Example * * This example demonstrates the Web Plotter feature: * - Real-time data visualization * - Multiple data series support * - Auto-scaling Y-axis * - Responsive web interface * - WebSocket communication for instant updates * * Hardware: ESP32 Boards * * Setup: * 1. Update WiFi credentials below * 2. Upload the sketch to your Arduino * 3. Open Serial Monitor to see the IP address * 4. Navigate to http://[IP_ADDRESS]/webplotter */ #include <DIYables_ESP32_Platform.h> #include <DIYablesWebApps.h> // WiFi credentials - UPDATE THESE WITH YOUR NETWORK const char WIFI_SSID[] = "YOUR_WIFI_SSID"; const char WIFI_PASSWORD[] = "YOUR_WIFI_PASSWORD"; // Create WebApp server and page instances ESP32ServerFactory serverFactory; DIYablesWebAppServer webAppsServer(serverFactory, 80, 81); DIYablesHomePage homePage; DIYablesWebPlotterPage webPlotterPage; // Simulation variables unsigned long lastDataTime = 0; const unsigned long DATA_INTERVAL = 1000; // Send data every 1000ms float timeCounter = 0; void setup() { Serial.begin(9600); delay(1000); // TODO: Initialize your hardware pins and sensors here Serial.println("DIYables ESP32 WebApp - Web Plotter Example"); // Add home and web plotter pages webAppsServer.addApp(&homePage); webAppsServer.addApp(&webPlotterPage); // Optional: Add 404 page for better user experience webAppsServer.setNotFoundPage(DIYablesNotFoundPage()); // Configure the plotter webPlotterPage.setPlotTitle("Real-time Data Plotter"); webPlotterPage.setAxisLabels("Time (s)", "Values"); webPlotterPage.enableAutoScale(true); webPlotterPage.setMaxSamples(50); // Start the WebApp server if (!webAppsServer.begin(WIFI_SSID, WIFI_PASSWORD)) { while (1) { Serial.println("Failed to start WebApp server!"); delay(1000); } } // Set up callbacks webPlotterPage.onPlotterDataRequest([]() { Serial.println("Web client requested data"); sendSensorData(); }); Serial.println("\nWebPlotter is ready!"); Serial.println("Usage Instructions:"); Serial.println("1. Connect to the WiFi network"); Serial.println("2. Open your web browser"); Serial.println("3. Navigate to the Arduino's IP address"); Serial.println("4. Click on 'Web Plotter' to view real-time data"); Serial.println("\nGenerating simulated sensor data..."); } void loop() { // Handle web server and WebSocket connections webAppsServer.loop(); // Send sensor data at regular intervals if (millis() - lastDataTime >= DATA_INTERVAL) { lastDataTime = millis(); sendSensorData(); timeCounter += DATA_INTERVAL / 1000.0; // Convert to seconds } } void sendSensorData() { // Generate simulated sensor data // In a real application, replace these with actual sensor readings // Simulated temperature sensor (sine wave with noise) float temperature = 25.0 + 5.0 * sin(timeCounter * 0.5) + random(-100, 100) / 100.0; // Simulated humidity sensor (cosine wave) float humidity = 50.0 + 20.0 * cos(timeCounter * 0.3); // Simulated light sensor (triangle wave) float light = 512.0 + 300.0 * (2.0 * abs(fmod(timeCounter * 0.2, 2.0) - 1.0) - 1.0); // Simulated analog pin reading float analogValue = analogRead(A0); // Send data using different methods: // Method 1: Send individual values (uncomment to use) // webPlotterPage.sendPlotData(temperature); // Method 2: Send multiple values at once webPlotterPage.sendPlotData(temperature, humidity, light / 10.0, analogValue / 100.0); // Method 3: Send array of values (alternative approach) // float values[] = {temperature, humidity, light / 10.0, analogValue / 100.0}; // webPlotterPage.sendPlotData(values, 4); // Method 4: Send raw data string (for custom formatting) // String dataLine = String(temperature, 2) + " " + String(humidity, 1) + " " + String(light / 10.0, 1); // webPlotterPage.sendPlotData(dataLine); // Print to Serial Monitor in Serial Plotter compatible format // Format: Temperature Humidity Light Analog (tab-separated for Serial Plotter) Serial.print(temperature, 1); Serial.print("\t"); Serial.print(humidity, 1); Serial.print("\t"); Serial.print(light / 10.0, 1); Serial.print("\t"); Serial.println(analogValue / 100.0, 2); }
  • Update the WiFi credentials in the sketch:
const char WIFI_SSID[] = "YOUR_WIFI_NETWORK"; const char WIFI_PASSWORD[] = "YOUR_WIFI_PASSWORD";
  • Click Upload button on Arduino IDE to upload code to Arduino Nano ESP32
  • Open the Serial Monitor
  • The Serial Monitor output should resemble the following:
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Nano ESP32
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Nano ESP32' on 'COM15')
New Line
9600 baud
DIYables WebApp - Web Plotter Example INFO: Added app / INFO: Added app /web-plotter DIYables WebApp Library Platform: Arduino Nano ESP32 Network connected! IP address: 192.168.0.2 HTTP server started on port 80 Configuring WebSocket server callbacks... WebSocket server started on port 81 WebSocket URL: ws://192.168.0.2:81 WebSocket server started on port 81 ========================================== DIYables WebApp Ready! ========================================== Web Interface: http://192.168.0.2 WebSocket: ws://192.168.0.2:81 Available Applications: Home Page: http://192.168.0.2/ Web Plotter: http://192.168.0.2/web-plotter ==========================================
Ln 11, Col 1
Arduino Nano ESP32 on COM15
2
  • If nothing appears, press the reset button on the board.
  • Enter the IP address from the Serial Monitor into a browser on the same network.
  • Example: http://192.168.0.2
  • The home page shows a card for the plotter application:
Arduino Nano ESP32 DIYables WebApp Home page with Web Plotter app
  • Select the Web Plotter card to open the chart page:
Arduino Nano ESP32 DIYables WebApp Web Plotter app
  • The page is also directly accessible at http://192.168.0.2/web-plotter.
  • The chart begins updating as the sketch sends simulated data. Each series is drawn in a distinct color.

Plotter Configuration

Set the chart title, axis labels, auto-scale behavior, and maximum retained samples before starting the server:

webPlotterPage.setPlotTitle("Sensor Data"); webPlotterPage.setAxisLabels("Time (s)", "Value"); webPlotterPage.enableAutoScale(true); webPlotterPage.setMaxSamples(100); // Keep last 100 points per series

Sending Data Points

Each data point specifies a series name, X value, and Y value. The series is created automatically on first use:

// Single series webPlotterPage.addDataPoint("temperature", elapsedSeconds, sensorValue); // Multiple series in the same update cycle webPlotterPage.addDataPoint("temperature", t, tempValue); webPlotterPage.addDataPoint("humidity", t, humValue); webPlotterPage.addDataPoint("pressure", t, pressValue);

Reading from Real Sensors

Replace the simulated values in the example with actual sensor readings:

Single Sensor

float temperature = analogRead(A0) * (5.0 / 1023.0) * 100.0; // LM35 webPlotterPage.addDataPoint("LM35", millis() / 1000.0, temperature);

Multiple Sensors

float temp = readTemperature(); float humid = readHumidity(); webPlotterPage.addDataPoint("Temp", millis() / 1000.0, temp); webPlotterPage.addDataPoint("Humid", millis() / 1000.0, humid);

Limit the send rate to avoid overwhelming the WebSocket connection. A 500 ms to 1000 ms interval is suitable for most sensor applications.

Troubleshooting

Chart does not update

  • Confirm webAppsServer.loop() runs on every loop() iteration
  • Add Serial.println() before addDataPoint() to verify the code path executes
  • Reload the browser page and check the WebSocket connection indicator

Chart shows flat lines or wrong values

  • Verify the sensor read and scaling formula
  • Print the value to the Serial Monitor alongside sending it to the plotter

Too many data points slow the browser

  • Lower setMaxSamples() to reduce the points retained per series
  • Increase the delay between data sends

Board not reachable

  • Confirm the IP address from the Serial Monitor
  • Ensure the browser device is on the same 2.4 GHz network as the board

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!