peterhinch / micropython-mqtt

A 'resilient' asynchronous MQTT driver. Recovers from WiFi and broker outages.
MIT License
550 stars 117 forks source link

MQTT Broker on microPython. #22

Closed beyonlo closed 2 years ago

beyonlo commented 4 years ago

Hello.

Are there a MQTT Broker implementation for the microPython?

I want to use ESP32 as the WiFi Gateway and I would like to use a MQTT Broker on it.

Thank you.

peterhinch commented 4 years ago

Not as far as I know. I recommend mosquitto which runs fine on a minimal Linux box such as a Raspberry Pi. But I don't know of a bare metal broker solution.

beyonlo commented 4 years ago

Hello Peter.

Yes, I know the mosquitto and I already use it in the Rpi, including the Pi zero w. But I'm want to use ESP32 as a WiFi Gateway for the all other devices, that are ESP32 too. Maybe 20 ESP32 clients to each one ESP32 Gateway - via WiFi of course.

The ESP32 Gateway will have a 4G modem doing ppp over uart. So, the idea is to use MQTT client on all ESP32 clients and send data to ESP32 Gateway using MQTT - over WiFi. So, in the ESP32 Gateway will be running the MQTT Broker. And, still in the ESP32 Gateway, I will need to open a MQTT Client to send to a cloud MQTT Broker, like as IBM, over 4G/LTE. So in the ESP32 Gateway I will have a MQTT broker and a MQTT client.

Scenario:

ESP32 clients (MQTT client) <-----WiFi-----> ESP32 gateway (MQTT Broker and MQTT client) <------PPoS-----> IBM Cloud (MQTT Broker)

What do you think about that?

peterhinch commented 4 years ago

I'm not sure why you need two MQTT brokers. It's valid for the one broker to be on the internet and there are various public brokers. But the scheme you outline should work, if you can find a decent local broker.

Otherwise for a local broker you could add a WiFi connected Raspberry Pi (or similar) running mosquitto.

You might want to ask on the forum where there are plenty of knowledgeable users. There was recent discussion of an alternative broker, but my recollection is that the conclusion was that it was of poor quality.

I am expecting to be off-grid until mid next week.