Hi.. I’m seeing so many ways to interconnect devices, and need an overview perspective. In a sense, everything is about controlling something (e.g. LEDs) or receiving data (e.g. temperature sensor data).
So, in the “Building WebServers” book, extensive use is made of asyncWebServer/socket (using the server.on(“/xxxx”…) code in the server to handle requests by the client). Then in the “Home Automation” book, extensive use is made of Mosquitto to connect server to client (using onMqttConnect, on MqttMessage, etc code in the server). Then in a tutorial for Raspberry Pi, you introduced Flask+Jinja to handle communications (using @app.route(“/xxxx”…) code in the server). Finally, recently, you published an article with micropython for the RPi Pico (using the more obvious socket.socket() in the server).
This is a daunting collection of ways to connect server and clients. I assume any of these can be used – why would I pick Flask, for example, over Mosquitto or sockets? (I have successfully gone through all the tutorials using ESP32s and Raspberry Pis, and especially use Flash in recent RPi designs, but now I’m scratching my head wondering if I’m using the “best” protocol). Can you comment on these various approaches?
Thanks for any illumination :–)
Hi.
It depends on your preferences and your project requirements and the board you’re using and the libraries available for what you want to do.
For example, if you want to use Node-RED to display data, one of the easiest ways to connect several devices is to use MQTT. If you’re using Node-RED, you don’t need to create a web page for the interface, so you won’t need to create a web server, neither HTML or JavaScript files.
If you like to customize the way the data is displayed or how your web page looks, you would want something that easily allows you to serve files for web development. For example, I like to use the AsyncWebServer library because you can easily use WebSockets and server-sent events to synchronize everything in real time. And the fact that you can upload web page files (HTML, CSS, and Javascript) using the filesystem is a great advantage because it makes coding much easier. However, it might be a bit overkill for simple projects.
There isn’t the “best” protocol, it will really depend on your project and the hardware you have available, and also the way you like to do things (if you’re more of a coding person, or if you like to use “already-made” dashboards.
I’m sorry if this is confusing, but this is my opinion about this subject,
Regards,
Sara
Hi Sara, Thanks for your answer. You prompted me to again look at that terrific 600+ page book on Building Web Servers ! …Whew ! … a lot of content, but I’m better informed now with all the protocols in that book, so thanks for the motivation! I’m happy with using the AsyncWebServer for ESP32 applications, and Flask for Raspberry Pi applications (though I have to dig into Apache since Flask really doesn’t have a production server). This link (from William Lucid’s questions) helped a little in weighing Firebase, Moquitto and Node-Red.
Since this was a very broad question, and the answer is sort of “depends”, I’m good with closing this question out. – JoeM