Robust network protocol - looking for inspiration

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
notabob
Posts: 1
Joined: Fri Oct 26, 2018 9:17 pm

Robust network protocol - looking for inspiration

Post by notabob » Fri Oct 26, 2018 10:04 pm

Via socket i have create my own simple protocol, which communicate to/from a handfuld of ESP32 to a control center on a R-Pi
I have some sorter machines that reports their status to the control center:
e.g. machine 1: running, 25 rpm, temp 40c, machine 2: idle And so on.
Its very simple, it send 8 bytes with information, and it can receive 4 bytes with an action, e.g. start or stop.

It works quite well, less that 50 ms in respons time. But its not very scalable and probably not very robust.

I'm wondering which existing protocol, is suitabel for this kind of solution. Would that be mqtt?
It does not need to be real time, 2-3 sec respons time would be fine.

My control center program does a fine job, its just a simple text readout that list the status of each machine and sound an alarm (buzzer) if a machine goes to the status: stopped. But not very sexy (lack of gui) and not scalable at all.

So if you guys have any recommendations on a portal/dashboard, with some kind of logic build in. I would like to move some of the intelligente into the dashboard.
E.g. If machine1.temperatur > 50 Then send.machine1.idle.
Preferable something that could be installed on a R-Pi og a PC, so i wouldn't have to depend on the internet running. But a cloud solution is not a show stopper.

regards Frantz

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: Robust network protocol - looking for inspiration

Post by kevinkk525 » Sat Oct 27, 2018 8:49 am

try using mqtt for communication and home-assistant as a frontend.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

HerbV
Posts: 7
Joined: Sat Oct 27, 2018 1:33 pm

Re: Robust network protocol - looking for inspiration

Post by HerbV » Sat Oct 27, 2018 1:41 pm

I also use MQTT finally I got it to operate very error tolerant.

Most of the examples ignore that the Broker could crash or even WIFI.
But after sorting that out with the code I think it's the best solution.


Herbert

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: Robust network protocol - looking for inspiration

Post by kevinkk525 » Sat Oct 27, 2018 3:09 pm

Take a look at my repo https://github.com/kevinkk525/micropython-mqtt (forked from Peter Hinch) of a resilient uasyncio mqtt driver (if you use uasyncio which I highly recommend).
With this you should get a fairly stable environment that does not have problems with Wifi or broker outages (at least on my esp8266s). On esp32 I only use the loboris fork but not yet as a 24/7 device so I can't tell if it is absolutely stable.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

Post Reply