Giter Club home page Giter Club logo

remote-control-with-websocket's Introduction

ESP32 Remote Control with WebSocket

Please visit the tutorial

Throughout the tutorial, you will be able to update your code using the different tagged versions of this repository. Each tag corresponds to the finalized code of a chapter:

$ git tag --list -n1
v0.0    Project Bootstrap
v0.1    LED Setup
v0.2    Button Setup
v0.3    Web UI Design
v0.4    SPIFFS Setup
v0.5    WiFi Setup
v0.6    Web Server Setup
v0.7    WebSocket Setup
v0.8    WebSocket Data Exchange
v1.0    WebSocket and JSON

For example, to switch to the version of the chapter that deals with setting up the WiFi connection, simply run:

$ git checkout v0.5

The complete project code corresponds to version 1.0:

$ git checkout v1.0

remote-control-with-websocket's People

Contributors

m1cr0lab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

remote-control-with-websocket's Issues

Huge thanks, and a request to cover saving parameters

Hi Stéphane,

First, thank you for your clear and helpful tutorial. However, I'd like to see an additional chapter on how to save preferences. I'm working on a particular project where this would be useful, but I think the need is not uncommon.

I'm building a macro rail device with a camera on a platform, supported by rails and moved by a stepper motor. The camera approaches the subject in tiny steps, taking a new image each step. Later specialised software stitches the sharp bits from each image into one image with an incredible depth of field.

The hardware is built, and I used a tutorial similar to yours to create a web interface. I'm not a programmer but have a basic understanding of a couple of languages. I've integrated stepper functionality using ESP-FlexyStepper and remote control of the camera via Canon BLE Remote. It's not finished yet, but I have a working prototype.

About a dozen settings are needed, e.g. camera sensor, focal length, f-stop, the delay between steps, etc. Ideally, a user would save these between sessions. I think that a flexible system could be devised using JSON and SPIFFS, mainly since these are already part of the system.

I've researched SPIFFS and ArduinoJason, but following step by step doesn't give you the depth to extract principles and apply them creatively. Instead, I found articles covering saving parameters and others covering server communication but not an integrated combination of the two.

Would you be interested in writing this? I would be surprised if I'm the only one interested.

Having thought about it, these are the questions that it could answer.

  • What would you save? A string? The aduinoJSON object?.
  • At the web server end, does the parsed JSON object persist for the session, or would I have to create a javascript object?
  • How often should I save? Would I save the entire object or just the changes?
  • Is there a better approach altogether

FYI At the moment, the project is not a commercial. I intend to release it as open-source (Hardware, 3D printed and software). It would only be in the unlikely event it was popular that would I think about commercialising it.

Again, thank you for the article, it was very helpful

Kind regards

peterC

Secure Sockets

in your comment to ShawnHymel you mention wss:
the WebSocket layer is much better managed in ESPAsyncWebServer. ... All ws://streams go through the HTTP port and allwss:// streams go through the HTTPS port.

I realize that a tutorial needs to be keep simple, but do you have any examples of an HTTPS server and WSS sockets?

I am struggling to find any reference to TLS, Certificates, or WSS in ESPAsyncWebServer

Stability

Hi,

I've been playing around the same ideas about weeks now and you managed to compile everything I learnt in a very comprehensive way. I managed to do the same using another library (mWebSocket) and after discovering about AsyncTCP and AsyncWebServer, I was willing to update my code and use those libraries. Except that there are many complains about the stability of the AsyncTCP library and the author doesn't look active working in the project anymore.

In this video Phil cover some problems it has: https://www.youtube.com/watch?v=txpVm1ftGOI

What I would like to ask you is this: after working in this project, how stable do you think it is? Have you left it running for long periods of time? I'm concern because the project I am working on, stability is essential.

Anyway, thank you for sharing so much with us. It really helps a lot.

Doesn't connect

Excellent clear tutorial. Just switched over to platformio and was able to get all the libraries. Project compiles and uploads but I don't seem to connect.

Added this code:
Serial.println("Connecting.. status: " + String(WiFi.status()));
delay(500);
/*status codes
WL_NO_SHIELD = 255, // for compatibility with WiFi Shield library
WL_IDLE_STATUS = 0,
WL_NO_SSID_AVAIL = 1,
WL_SCAN_COMPLETED = 2,
WL_CONNECTED = 3,
WL_CONNECT_FAILED = 4,
WL_CONNECTION_LOST = 5,
WL_DISCONNECTED = 6
*/
But it immediately goes to status 1 despite the fact that a scanner program on my AdaFruit Feather Huzzah32 finds the SSID I am trying to connect with. Have tried it in other buildings with other networks, always changing the SSID in the code and recompiling. Perhaps my problem is I'm currently trying to connect to an open network with no password? I'm using:

// WiFi credentials
const char *WIFI_SSID = "dd-wrt_#6";
const char *WIFI_PASS = "NULL";

Thanks in advance from this newbie

Can you point me in the right direction please?

My project is an ESP32 controller for our hot tub. I am using 4 solid state relays to supply power to the circ pump, heater, control panel, and lights - not the underwater lights, they are controlled by the spa control panel. What it does so far is;

On boot, it connects to the WiFi and gets the correct time from a time server. This connection is then closed so WiFi can be used solely for remote control of the unit - initially turning on and off the lights and the control panel. Ultimately, I want to be able to be able to alter the circ pump on/off times and the water temperature set point. Currently, these are hard coded into the sketch. Every loop, it checks to see if there is a client and handles it if there is and every 30 seconds, it checks the time and the water temperature, taking action if the water is more than 0.5° below set point or turning off the heater is the set point has been reached and also running the circ pump if the time is between on and off settings. The circ pump must be run if the heater is turned on.

The web controller for the control panel and lights are taken from a RNT tutorial but I take on board your comments about 'netter ways to do things' - I know my code could be much better, I could have defined a relay class similar to your LED class and specified the pin number, state etc. and ultimately, I will do but we've already had a couple of days in the high twenties, I want to get the hot tub filled soon!

So there are two things I would like to do, improve the webserver method using websockets so I can also interactively display things like air temperature, pressure and humidity as well as water temperature as well as being able to set control board and lights on and off. And the second thing is OTA updates with the ESP32 being inside the hot tub casing, it is important. My problem is that when I try changing the wevserver methods or add OTA (ElegantOTA) and I have to change from, for example, webserver server(80 to WiFiserver server(80) I get problems such as webserver has no member named xxx

So, I need to use a library which will allow me to get the time from a time server, run an ESP32 webserver, AND do OTA updates and my other problem is that while I am a fairly experienced coder in other things ESP32 related, I simply do not have a clue about webserving!

Here is my full code so far. I would really appreciate some advice and pointers to where I can learn what I need to develop this further.

#include <Arduino.h>
#include <WiFi.h>
#include <ElegantOTA.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <ESP32Time.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>

#define lightsPin   12 //red
#define powerPin    18 //white
#define heaterPin   13 //green 
#define pumpPin     19 //yellow 
#define ONE_WIRE_BUS 8
#define ssid      "Steve"
#define password  "jguWzfc76i"

WiFiUDP ntpUDP;
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
WiFiServer server(80);
ESP32Time rtc(7200);
NTPClient timeClient(ntpUDP);

String header;
long currentTime = millis();
long lastTempTime = 0; 
long timeSync;
long previousTime = 0; 
const long timeoutTime = 2000;
int yy,mm,dd,hh,mn,ss;
bool started=true;
String formattedDate;
String timeStamp;
char timeStr[6];

char tempstr[20];
char labtxt[9];
char tmp[5];
float airTemperature, pressure, humidity,wt,sp;
char settings[20];
int hStart,mStart,hSTop,mStop;
int hOn,hOff,mOn,mOff,hNow,mNow;
String outputcontrolState = "off";
String outputlightsState = "off";
boolean power = false;
boolean control = false;
boolean lights = false;
boolean timeron = true;
boolean circon = false;
boolean heateron = false;
unsigned long ota_progress_millis = 0;
const int led = 13;

void setup()
{  
  String dateSubStr;
  Serial.begin(115200);
  delay(3000);
  hOn=13;
  mOn=0;
  hOff=18;
  mOff=30;
  sp=36; 

  pinMode(powerPin,OUTPUT);
  pinMode(pumpPin,OUTPUT);
  pinMode(heaterPin,OUTPUT);
  pinMode(lightsPin,OUTPUT);
  digitalWrite(powerPin,LOW);
  digitalWrite(pumpPin,LOW);
  digitalWrite(heaterPin,LOW);
  digitalWrite(lightsPin,LOW);

  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) 
  {
    delay(500);
    Serial.print(".");
  }

  // Print local IP address and start web server
  Serial.println("");
  Serial.println("WiFi connected.");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  Serial.println("Getting time from NTP Server");
  // get time and set the RTC
  timeClient.begin();
  timeClient.setTimeOffset(0);
  while(!timeClient.update()) timeClient.forceUpdate();
  formattedDate = timeClient.getFormattedDate();
  timeClient.end();
  dateSubStr = formattedDate.substring(0,4);
  yy=dateSubStr.toInt();
  dateSubStr = formattedDate.substring(5,7);
  mm=dateSubStr.toInt();
  dateSubStr = formattedDate.substring(8,10);
  dd=dateSubStr.toInt();
  dateSubStr = formattedDate.substring(11,13);
  hh=dateSubStr.toInt();
  dateSubStr = formattedDate.substring(14,16);
  mn=dateSubStr.toInt();
  dateSubStr = formattedDate.substring(17,20);
  ss=dateSubStr.toInt();

  Serial.print("Setting time and date to : ");
  Serial.println(formattedDate);
  rtc.setTime(ss, mn, hh, dd, mm, yy); 
  server.begin();
  Serial.println("HTTP server started");
  
  sensors.begin();
}

void loop()
{
  if ((millis() - lastTempTime > 1000UL * 30) || started==true)
  {
    started=false;
    sensors.requestTemperatures(); // Send the command to get temperatures
    wt = sensors.getTempCByIndex(0);
    hNow = rtc.getHour(true);
    mNow = rtc.getMinute();
    sprintf(timeStr,"%2d:%02d",hNow,mNow);
    Serial.print("Time          ");
    Serial.println(timeStr);
    Serial.print("Water temp    ");
    Serial.println(wt);
    Serial.print("Set Point     ");
    Serial.println(sp);

    if(hNow==hOn && mNow >= mOn) circon=true;
    else if(hNow==hOn && mNow>=mOn) circon=true;
    else if(hNow<hOn)circon=false;
    else if(hNow>hOff)circon=false;
    else if(hNow==hOff && mNow>=mOff)circon=false;

    if(circon==true) Serial.println("Circ ON - timer");
    else Serial.println("Circ NOT On - timer");

    if(wt<(sp-0.5))
    {
      Serial.println("Heater ON, Circ ON");
      heateron=true;
      circon=true;
    }
    else if (wt>=sp)
    {
      Serial.println("Heater OFF");
      heateron=false;
    }

    if(heateron==true)
    {
      digitalWrite(heaterPin,HIGH);
      digitalWrite(pumpPin,HIGH);
      circon=true;
    } 
    else digitalWrite(heaterPin,LOW);

    if(circon==true) digitalWrite(pumpPin,HIGH);
    else digitalWrite(pumpPin,LOW);
    lastTempTime=millis(); 
  }
  WiFiClient client = server.available();   

  if (client) 
  {                             
    currentTime = millis();
    previousTime = currentTime;
    Serial.println("New Client.");
    String currentLine = "";      
    while (client.connected() && currentTime - previousTime <= timeoutTime) 
    {  
      currentTime = millis();
      if (client.available()) 
      {         
        char c = client.read();         
        Serial.write(c);                
        header += c;
        if (c == '\n') 
        {
          if (currentLine.length() == 0) 
          {
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println("Connection: close");
            client.println();
            
            if (header.indexOf("GET /lights/on") >= 0) 
            {
              Serial.println("Lights on");
              lights = "on";
              digitalWrite(lightsPin, HIGH);
            }
            else if (header.indexOf("GET /lights/off") >= 0) 
            {
              Serial.println("Lights off");
              lights = "off";
              digitalWrite(lightsPin, LOW);
            }
            else if (header.indexOf("GET /power/on") >= 0) 
            {
              Serial.println("Power on");
              power = true;
              digitalWrite(powerPin, HIGH);
            }
            else if (header.indexOf("GET /power/off") >= 0) 
            {
              Serial.println("Power off");
              power = true;
              digitalWrite(powerPin, LOW);
            }

            client.println("<!DOCTYPE html><html>");
            client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
            client.println("<link rel=\"icon\" href=\"data:,\">");
            client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}");
            client.println(".button { background-color: #4CAF50; border: none; color: white; padding: 16px 40px;");
            client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}");
            client.println(".button2 {background-color: #555555;}</style></head>");
            
            client.println("<body><h1>Hot Tub Control</h1>");

            sprintf(tempstr,"<p>Water temperature  %4.1f°C</p>",wt);
            client.println(tempstr);
            
            client.println("<p>Lights</p>");
            if (lights==false) client.println("<p><a href=\"/lights/on\"><button class=\"button\">ON</button></a></p>");
            else client.println("<p><a href=\"/lights/off\"><button class=\"button button2\">OFF</button></a></p>");
               
            client.println("<p>Power</p>");
            if (power==false) client.println("<p><a href=\"/power/on\"><button class=\"button\">ON</button></a></p>");
            else client.println("<p><a href=\"/power/off\"><button class=\"button button2\">OFF</button></a></p>");
            
            client.println("</body></html>");
            client.println();
            break;
          }
          else currentLine = "";
          
        } 
        else if (c != '\r') currentLine += c;
        
      }
    }
    header = "";
      client.stop();
    Serial.println("Client disconnected.");
    Serial.println("");
  }
}

Thanks, Steve (Cyprus)

Big thanks!

Thanks Steph for this interesting, clear, and well-structured project!
It has been a lot of fun to follow it on my esp32
Cheers,
Jesus Ruiz

ESP32 WebSocket Server

Hi,
It was explained very professionally and in detailed. I enjoyed reading it all. I would like to know how you could make the same project full-duplex e.g. by sending a temperature data from server to client and what is the best commercial way to access the device from anywhere in the world.
thank you,
Jim

question to everyone.....

Hello,

Has anyone managed to integrate multiple LEDs and switches? I managed to integrate 4 LEDs and 4 switches, but these can only be switched statically. I have not yet managed to switch this led via the physical switch (via WebSocket)
I would be grateful for any advice.....

Thank you for the great tutorial

Title says it all. This is one of the best tutorials I have seen, it very clearly describes several different concepts needed to make an end-to-end working websocket based implementation and how they tie together. I very much appreciate your effort on this and it really helped make everything click for me. Thanks!

How to add some functionality using Websockets

Hello Stéphane.
I need your help with some direction to add some functionality using Websockets.
1.- Authentication before establishing a communication by Websockets.
2.- Navigate between several pages without losing the connection when going from one page to another.
First of all, Thanks

TRES BON TUTO

Excellent tuto accessible aux débutant en plus.
La pédagogie est au RDV avec des animations permettant une bonne compréhension.
Pour être honnête je n'ai jamais vu une aussi belle construction synchronisée et interactive avec Git.
Bravo l'artiste.

v1.0 led_buitin

Hi,

Missing #define LED_BUILTIN 2
in v1.0

Apart this everything runs ok in platformio.

Regards

JPD

Thanks for sharing useful and practical issue

Dear sir
Thanks a lot for sharing useful and practical issues.
I implemented one of RNT projects (remote control+PHP+SQL) in my home for 18 zone lighening.
every 300ms, ESP32 send a request to host for exploring changes in database.
but with your Websocket project, now, I know that no need to have a database or sending request.
However, in your project, esp32 has rule of server while in my project, PHP+JS+HTML+CSS are inside server.
I control lamps in my mobile by web addressing.
I obtained a registration form. At first you need to log in. then you can observe control page with different zones. for example kitchen zone, rest room zone and so on.
I also no need to control lams from two points because one of my points is control traditionally by a usual power key.
Would you please tell to me how I can change your Websocket project to match to my project?
Thanks

Just a thank you!

Hi.

Thanks for the excellent tutorial. Well structured and easy to follow.

I've gone through it using an ESP8266 NodeMCU board which doesn't require any additional hardware due to on-board button and LED. Maybe the result can be useful for people more interested in the software part and having a NodeMCU board lying around: https://github.com/rheinz/remote-control-with-websocket

Cheers

For the new ones!

as many are new will be great if you ansswer to some Q regarding code.
like : digitalWrite(pin, on ? HIGH : LOW);

Adding interrupts and DMA

First, this is an outstanding tutorial. Over the years I've read perhaps thousands, but this one in particular is easily at the very top. Really, very remarkable.

I found the introduction to PlatformIO and git especially helpful. I've used these tools for awhile but for whatever reason I always had difficulty with PlatformIO as the compiler was constantly generating compile errors for things that I knew were correct. ( I think something about my system PATHs was broken). Anyway, this tutorial gave me a kick in the pants to try PlatformIO again, and what do you know. It worked:)

My principal complaint about using the Arduino is that the libraries don't seem to offer a clear path to detailed and complex configuration of the ESP32 at the basic device level. The primary example being the use of interrupts used with SPI/DMA interfaces. While I find that interrupts and DMA are easy to implement individually using the Arduino environment, making both work together seems more problematic.

Given that the code is already configured within PlatformIO with classic file extensions as .c, .cpp, how much effort is involved in the complete abandonment of Arduino in favor of the Expressif code base so that fine grained control of the device can be implemented? Or to put it another way. Starting with the code base you have graciously provided is it possible to push the ESP32 more aggressively providing say 1MB/sec?

Perhaps adding another chapter or few to cover advanced configurations of streaming I/O?

Regards,

Flash Packets

Help needed for my project

Hi Steve,

Thank you for sharing your knowledge with us. It is great lesson you presented here.

I have been working with a low power devices network using probe request protocol to conserve power on remote battery powered devices. My test shows it works better (less power consumption) than ESPNow. I tried to implement simple monitor and control dashboard for whole network using uPlot graphs and websocket server with my very limited knowledge. I need your help improving the dashboard design to make it simpler.

My project is at links below:

Gateway : https://github.com/happytm/BatteryNode/blob/master/examples/ProbeRequestGateway_ESP32_uPlot.ino
Remote ESP8266 (oneway) device: https://github.com/happytm/BatteryNode/blob/master/examples/ProbeRequestRemote_ESP8266_OneWay.ino
Remote ESP8266 (bidirectional) device: https://github.com/happytm/BatteryNode/blob/master/examples/ProbeRequestRemote_ESP8266_TwoWay.ino

HTML file for dashboard: https://github.com/happytm/BatteryNode/blob/master/test/Dashboard.html

Thanks.

vscode+platformIO is giving me errors when compiling version 0.6!

Hello! Thank you so much for the tutorial!
I'm using it and I've found a problem that's preventing me from continuing!
I'm using a wroom32 board, which should be the same as the one you used in your tutorial!
1

I have vscode+platformIO installed on my computer, I downloaded the code from github to my computer and when I compiled version 0.5 it worked!
v0 5

But I get an error compiling version 0.6!
v0 6

It seems that there is a problem with the initWebServer() function.

Please help me!

Hello! and fantastic tutorial

wow this is one of the best and most informative tutorials. I am new to websockets, jason and ESP32. i followed through your tutorial learning all about websockets. i have the project working but wanted to add more led's and buttons and not sure how to do this the best way. do you have any tutorials or is there a quick way to figure it out. i can get it to work but there is a lot of repetitive code. any ideas???

Thank you
Mark

Question from a user from Germany

Hello Stéphane,
a really nice project! Could you perhaps publish the code from #13 again? I tried to implement your code for several LEDs and buttons but it doesn't work. The leds on the breadboard work (2 leds, 2 buttons) but the dashboard does not. There are problems with: function onMessage(event) {
let data = JSON.parse(event.data);
document.getElementById('led_' + data.rank).className = data.status;
} specifically with 'led_' + data.rank.
Is that right?
String processor(const String &var) {
return String(var == "STATE_1" && led[0].on ? "on" : "off" );

}
and: void notifyClients() {
ws.textAll(led[0].on ? "on" : "off" );
}

void handleWebSocketMessage(void *arg, uint8_t data, size_t len) {
AwsFrameInfo info = (AwsFrameInfo)arg;
if (info->final && info->index == 0 && info->len == len && info->opcode == WS_TEXT) {
data[len] = 0;
if (strcmp((char
)data, "toggle") == 0) {
led[0].on = !led[0].on;
notifyClients();
}
}
I don't think so.
led[0].on = !led[0].on;

How do you think that?........

(

Removed function mbedtls_md5_starts in WebAuthentication.cpp results in build error

Thanks for creating this great tutorial! Very well explained and easy to follow.

Line lib_deps = ESP Async WebServer in platform.ini results in a build error:

Linking .pio/build/esp32doit-devkit-v1/firmware.elf
/home/user/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/esp32doit-devkit-v1/libc09/libESP Async WebServer.a(WebAuthentication.cpp.o):(.literal._ZL6getMD5PhtPc+0x4): undefined reference to `mbedtls_md5_starts'
/home/user/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/esp32doit-devkit-v1/libc09/libESP Async WebServer.a(WebAuthentication.cpp.o): in function `getMD5(unsigned char*, unsigned short, char*)':
/home/user/Documents/PlatformIO/Projects/ESP32-Websocket/.pio/libdeps/esp32doit-devkit-v1/ESP Async WebServer/src/WebAuthentication.cpp:73: undefined reference to `mbedtls_md5_starts'
collect2: error: ld returned 1 exit status
*** [.pio/build/esp32doit-devkit-v1/firmware.elf] Error 1

This issue has already reported in me-no-dev/ESPAsyncWebServer#1147 and is waiting for a new release.

A temporary workaround until the developer creates an updated library is to change:

-From: lib_deps = ESP Async WebServer
+To: lib_deps = https://github.com/me-no-dev/ESPAsyncWebServer.git

Great Tutorial. One question about the code

I am just getting into working with microprocessors but had C++ class about 25 years ago.

This code example is perfect for a fun project that I am working on.

I am wondering about one piece of code in the button section that I am not quite sure what the C++ code is doing with the == in this context.
bool pressed = reading == LOW;

Aside for this, the explanations were great.

If you want to take this example further; it would be interesting to have two buttons with associated LEDs along with a counter that that compares how much one LED has been "ON" verses the other. This could be an interesting game were two people get on the web page and try to have their light "ON" for more than the other person. They would have to alternate between trying to turn "ON" their LED while turning "OFF" the other LED.

Thanks - very nice

Thank you very much - a nice tutorial. Around 10 years ago I worked with websockets but they work not as expected. With your tutorial I get a small server to work.

Client-side display of websocket data

Thanks for the great work herein. I found this repository via RNT Labs. I have a question, and it is not an issue.

I need to display the data sent by the ESP32 to the websocket client browser. All examples I have seen are for switching glyphs on the browser on and off.

1- How can I display data received via websocket on the browser screen - without the JS script?
2- If JS script must be used, how can I display event.data on the screen?
3- Where does console.log() output go in the client?

Thank you so much.
Bromium

Excellent tutorial

Hello Stéphane,
i found your tutorial some time ago and i found it helpful, essential for my testing project (i needed a web interface from which to control a led).
So, thank you definitely.
Considering im an iOS developer, i dedicated several time to some concepts like the websocket one. However, your tutorial pointed to 2 different types of the protocol setup: ws and wss.
Could you point me to some useful resource about this topic, on how to pass from a ws to a wss/how to implement a wss?
Some instruction like
"You need to"
"and do this, and then this"
will surely help

Many Thanks!!

Hi Steph,

Got here via the link in RNT, thought as you wrote the original tutorial I'd follow yours. Lots of things aligned for this experiment, I'd forgotten aspects of WS so wanted a 101 induction, I'd just got an ESP32 (previously used ESP8266's), I'd just got a Raspberry Pi4 for a new project, I had tried PlatformIO before but kept going back to Arduino for ease ...

So with the Pi, I thought I would just install PlatformIO and use that. I do like it, but it is an environment that takes a bit of getting used.

Your tutorial is really clear. I always get confused between Server and Client so I like the talk analogy of WebSockets and I like the structure of having the Server code clearly in the C++ and the Client in the SPIFF .js file. If I try and do everything in one file I find it really confusing as to what it what.

I really appreciate the clean nature of your code. I like the structures. The debounce function is really nice!

The only two issues I have had were with PlatformIO...

the Serial Monitor - it only seems to work when I invoke it from the PlatformIO upload and monitor tab.
the upload Filesystem Image has moved from where you have it in the video to the env: platform section

As I said I am determined to try harder with PlatformIO so whilst I am keeping the Arduino IDE on my Mac, for now, I am only going to use PlatformIO on my Raspberry Pi, I do like the way that it forces you to code 'properly' and won't let you get away with sloppy? practice in the same way the Arduino IDE does (ie not declaring things properly? for instance) but it is a bit 'harder' especially if you don't use it regularly.

Thanks again for a great primer on WebSockets very much appreciated!!

Pete

Thank you!

Thank you sir for an exceptional project!!
This has helped me so much in my websockets-on-esp32 discovery.
cheers,
Greg

v1.1

Hi,

How can I create a v1.1 for mysels in platformio

git add myNotes.md
git stash
git commit -m "my file added"

?

Regards

JPD

ESP8266

Thanks for the tutorial and the code. Have you done this for the esp8266 at all ?

Thanks

Upgrade

Big Thanks for your project which inspired me to modify and upgrade it with PID Controller .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.