Category: Arduino and ESP
Hits: 225

User Rating: 4 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Inactive

My simple to use ESP32 sWebMonitor
Totally free to use and modify
(third-party library addresses can be found in the comments)<\p>

Can't use a USB monitor?
Download my simpleLib library. Load the example sWebMonitor.ino, in the example folder sWebMonitor you will also find the WebMonitor.html.
Download the used WebSocket library:

Simple to use
Just a few lines and add your own application code.
Red code is required WebMonitor code.
Green code is example code.
An "@": edit it before using.
wsProtocol: the used project name.
wsPort: the used TCP port.

#define USE_WS true  // used WebSockets Server library:
const char *ssid = "edit"@,
       *password = "edit"@;
#ifdef USE_WS
  #define USE_ECHO  true  // using the ECHO
  const char *wsURI = "/",
        *wsProtocol = "myWebMonitor"@;  // project name,  also in HTML
  const uint16_t wsPort = 8090@;        // used TCP Port, also in HTML
#include <sWiFi.h>        // always under the optional #define xyz declarations
#include <sWebMonitor.h> 

void setup() {
  while (!Serial); delay(1000);
  stdSetup();  // is necessary on this place - init all your defined choices
  Serial.printf("WebMonitor - Port: %u, Name: %s\n", wsPort, wsProtocol);

void loop() {
  static time_t t = 0;
  wifiOn();  // is necessary on this place - connection 'stays alive' control
  #ifdef USE_WS
    if (wsVal) wsAction();  // WebSocket data received?
    if (millis() >= t) {    // time to send a demo value?
      char c[21];
      t = millis();
      sprintf(c, "millis: %u", t);
      t += 5000;
      wsPrint(c);  // send to WebMonitor