MIcropython as MQTT broker

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
james_km69
Posts: 9
Joined: Wed Aug 15, 2018 8:31 pm

MIcropython as MQTT broker

Post by james_km69 » Wed Aug 15, 2018 8:43 pm

Hi, I am new to MQTT. I have it working with my ESP32 broad with my windows (or Rasb) as Mqtt broker.
wondering if it is possible to have the same ESP32 micro controller to be a mqtt broker (running Micro Python on it)
If so, any direction on how to do this?

Thanks,
James

User avatar
pythoncoder
Posts: 4921
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: MIcropython as MQTT broker

Post by pythoncoder » Thu Aug 16, 2018 8:20 am

I don't think this has been done. It would be quite involved and I'm not sure there would be much point. Why not just run mosquitto on a Raspberry Pi?
Peter Hinch

james_km69
Posts: 9
Joined: Wed Aug 15, 2018 8:31 pm

Re: MIcropython as MQTT broker

Post by james_km69 » Fri Aug 17, 2018 11:58 am

Thanks pythoncoder for the reply. I was just wondering. My goal was to eliminate at least one hardware from the system

OutoftheBOTS_
Posts: 794
Joined: Mon Nov 20, 2017 10:18 am

Re: MIcropython as MQTT broker

Post by OutoftheBOTS_ » Fri Aug 17, 2018 7:32 pm

If your connected to the internet then their is always cloud brokers :)

xenobius
Posts: 2
Joined: Fri Jan 22, 2021 8:04 am

Re: MIcropython as MQTT broker

Post by xenobius » Sat Jan 23, 2021 9:03 pm

But the thing is that you may want (like I actually do):

1. To have a system independent of cloud brokers simply because internet is not an option. For agriculture projects, you have situations where internet is not feasible because its either too far away from the nearest internet provider and they simply wont offer you internet - or because its just not worth it paying for internet only to be used for multiple tiny modules to communicate effectively together!

2. Custom boards with custom sizes for custom enclosures cannot always make use of the bulky raspberry pi. Sure enough you could now use the MicroPI but once again that a board on its own that needs to be "inserted" into your custom board. Perhaps its more ideal to have just 1 board and so raspberry pi is not an option either.

User avatar
tonazza
Posts: 2
Joined: Mon Feb 08, 2021 4:25 pm

Re: MIcropython as MQTT broker

Post by tonazza » Mon Feb 08, 2021 4:37 pm

Hello,

I was asking myself the same question that james_km69 asked :)
In my case I was actually searching for a MQTT broker library for the ESP-IDF SDK to be used with ESP32 hardware, but even micropython would have done the trick.
I've done some research and unfortunately there is no easy existing solution... :cry:

I'm working on a IoT project that has some restrictions (much like the latest xenobius post), and I'm thinking of going in the following direction: the devices will "speak" between them using websockets (and not MQTT), and in case there is an active internet connection, the system status will be backed up to a cloud MQTT broker by one "chosen " device, which will be the only MQTT client on the devices network.
In this way, the need for a local broker is removed.

Of course this is no elegant solution, but the alternative would be porting the Mosquitto code to ESP-IDF FreeRTOS.... :o

Andrea

User avatar
tonazza
Posts: 2
Joined: Mon Feb 08, 2021 4:25 pm

Re: MIcropython as MQTT broker

Post by tonazza » Tue Feb 09, 2021 2:39 pm

EDIT: just FYI, a starting solution does exist for ESP-IDF (not Micropython), using a library called mongoose
The company who develops mongoose also proposes a full embedded firmware called Mongoose OS, which is basically an alternative to micropython, having a limited free edition and a full paid commercial edition.

...still not tried the above, but at least a starting point exists!

Post Reply