Enable Javascript


Gebruikerswaardering: 4 / 5

Ster actiefSter actiefSter actiefSter actiefSter inactief
 

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: https://github.com/Links2004/arduinoWebSockets

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: https://github.com/Links2004/arduinoWebSockets
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
#endif
#include <sWiFi.h>        // always under the optional #define xyz declarations
#include <sWebMonitor.h> 

void setup() {
  Serial.begin(115200);
  while (!Serial); delay(1000);
  Serial.println("\n");
  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
    }
  #endif
}