remote-control-with-websocket
remote-control-with-websocket copied to clipboard
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
Hello Pete,
And thank you for your nice feedback on the tutorial. I'm glad I was able to light your way.
Concerning PlatformIO, I encourage you to persevere in learning how to use it properly. It is a true integrated development environment. And, as you have seen for yourself, it facilitates the adoption of good programming practices and the organization of your code. Under the pretext of simplifying things for beginners, the Arduino IDE necessarily takes you down the wrong path when you go to scale on more ambitious projects. I think you can play around with it, when you're just starting out, on a few projects. But you have to give it up very quickly and move to a more serious environment like PlatformIO.
As far as uploading the SPIFFS image, you're right, since a recent update of PlatformIO, this feature has been moved to another section as shown in the screenshot below.
And to open the serial monitor, the easiest and most accessible shortcut is this small icon, at the bottom left, which looks like an electrical outlet :

In general, PlatformIO is able to identify the serial interface to the device that corresponds to your ESP32 board on its own. However, sometimes you may need to manage multiple boards within the same project. And, in this case, there are two directives that allow you to explicitly specify which interface to choose for which board. For example:
[env]
platform = espressif32
framework = arduino
upload_speed = 921600
monitor_speed = 115200
[env:board1]
board = esp32dev
upload_port = /dev/cu.SLAB_USBtoUART1
monitor_port = ${env:board1.upload_port}
[env:board2]
board = pico32
upload_port = /dev/cu.SLAB_USBtoUART2
monitor_port = ${env:board2.upload_port}
[env:board3]
board = esp32doit-devkit-v1
upload_port = /dev/cu.SLAB_USBtoUART3
monitor_port = ${env:board3.upload_port}
Take a look at the documention for more details.