7

In my project I have a set of sensors in a local network that should communicate with a Raspberry Pi 3 and then with a distant MQTT broker.

Since I'm using ESP8266 for the sensor nodes I thought I would make the esp nodes MQTT clients that communicate with the broker directly through the pi's internet connection. But I need the pi to have access to the sensors' data from the local nodes as well as data from sensors linked to it.

So I would like the best solution to implement such a communication. I thought of adding a broker to the Pi that would be bridged to the distant broker as well as publish MQTT messages to a python program running on the Raspberry.

  1. Is there a way to avoid putting another broker on the Pi?

  2. Is there a better solution to do this?

  3. Will the broker consume too much memory?

Knowing that I may need to stream camera frame data as well.

8

A broker like mosquitto will run happily on the Pi and bridge to a remote broker.

How much resources it will consume entirely depends on how much traffic you send through it and if you end up queuing large amounts of retained messages. Under most circumstances it's pretty low (unless you are planning on streaming video via MQTT).

But this solution has the benefit that should the link to remote broker go down everything will continue to work locally.

Layered brokers like this is one of the specific use cases MQTT was designed to handle.

2

You could setup something like Node-RED that would collect the payloads from ESP8266 sensors, and turn around and send out the same payloads using a different topic. I do this myself on my home automation setup. I have some temp reading that come in every three seconds on one topic, but I needed to throttle them down to once a minute and sent back out using a different topic. Both sets of messages use the same Broker.

So in your case, use the Raspberry Pi as the local MQTT broker with its own set of topics, have Node-RED capture the packets that need to be sent on and use a different set of topics to send them on. I have a Docker server that runs a Mosquitto broker container, and a Node-RED container as well as two other containers that make use of the Node-RED converted data. Works like a champ.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.