Page 2 of 2

Re: MIcropython as MQTT broker

Posted: Sat May 01, 2021 1:14 pm
by karfas
(600m2, 60m corridor, 20 rooms, 40cm stone walls, 40 esps, 1 pi4)
So if i actually manage the network connections in a mesh, and manage a station and AP on every esp (with a single root).
What is to stop me using the station to publish (upstream) and the AP to subscribe (downstream).
As far as I understand, this is not the way a mesh (e.g. ESP-Mesh, see https://docs.espressif.com/projects/esp ... ata-stream) is working. I also don't see the need for a star topology, as each ESP will most likely "see" his neighbour (you might want to try this first), so this comes down to a simple case of routing (either traditional or via mesh).

How much data do you expect to transfer ? Routing a number of video streams over one ESP32 will most likely not work, but I don't see a problem with a few sensor readings now and then.

Re: MIcropython as MQTT broker

Posted: Tue Jun 01, 2021 6:40 pm
by beyonlo
Hi all.

I would like to use a MQTT Broker on MicroPython (on ESP32) too.

Just a idea/question: Are there a pure Python MQTT Broker? So, maybe, is possible to port it to MicroPython.

Is that a good idea?

Anyway, the best way is to have a MQTT Broker that works with uasyncio, of course.

Thank you.

Re: MIcropython as MQTT broker

Posted: Wed Jun 02, 2021 1:39 pm
by smurf
Yes there are pure-python MQTT brokers, hbmqtt for one. The problem is that it's basically unmaintained, and the fork that *is* maintained is based on anyio which hasn't been ported to micropython (yet, it's somewhere on my list of interesting things to do).

Also, you will have moments with iffy networking, which means that you need to buffer some messages. Unfortunately you probably don't have much free memory on your MicroPython device once you load all that broker code onto it. MQTT is not a simple protocol.

I wouldn't do that. IMHO it's far more useful to teach MicroPython about ESP's wifi mesh support, and run Mosquitto on a Raspberry Pi somewhere. At least that way you have some chance of stable operation of the whole setup.

Re: MIcropython as MQTT broker

Posted: Thu Jun 03, 2021 7:25 pm
by laldana73
Hello, this library https://github.com/martin-ger/esp_mqtt can help you to use an esp8266 module as a MQTT broker. But this is not Micropython, is using NONOS SDK or esp8266SDK.
https://github.com/cesanta/mongoose the mongoose networking library can be used to build a MQTT broker in the esp32. you could use this to build a module for ESP32 Micropython port.
or you coud use COAP in Micropython, instead MQTT

Another approach?

Posted: Fri Jun 04, 2021 8:11 am
by pythoncoder
In any application which must run 24/7 I would test these solutions carefully to ensure they recover from loss of WiFi connectivity. I would also test that they can run continuously for days on end: this can be a tall order for ESPx unless there is a watchdog timer.

Running MQTT in a mesh configuration using bridges is an interesting idea, but it isn't how MQTT was designed. There could be hidden pitfalls.

I think it's also worth considering using MQTT as designed, but with long range radio technology. I haven't looked into this in detail, but LORA supports networking. So I wonder if it's possible to configure a Raspberry Pi running Mosquitto to use a LORA device. Clients could run on PyCom hardware with a modified version of mqtt_as.