two-way communication with external network

273 views
Skip to first unread message

Seth Loh

unread,
Jun 15, 2022, 5:51:11 PM6/15/22
to painlessmesh-user
Hey! I've been using painlessmesh/painlessmeshboost for some time for my hydroponics setup and it works great! It relays sensor data to my raspberry pi (acting as a gateway node), which I use the listener + mesh bridge combination to parse the information to influxdb to view the data on grafana.

I'm now trying to develop more complex features, mainly two-way communication where I'll be able to control some of the pumps from the external network. I've looked at the webserver example, and referred to the wiki page, and I would like to solicit some advice for some of the configurations to solve this hurdle.

1) Have the raspberry pi also connect to the mesh network (with a second wifi device) and send commands to an ESP32 webserver node.

2) Have another mqtt broker on the network to receive commands.

3) Have the rpi communicate via serial protocol to the bridge node (probably not a good idea since its already in AP+station mode and I'm not sure if its doing too much)

Have I missed out something obvious?

Peter Buelow

unread,
Apr 15, 2023, 3:15:27 PM4/15/23
to painlessmesh-user
Interesting, I did something similar using MQTT and routing the MQTT messages through my root node which had an ethernet connection alongside it. I'm working to modify my painlessmeshboost to do the forwarding for me though and may drop my ESP32 root node completely at some point.

My plan is to modify the onReceive on the Pi to capture mesh messages and if they are JSON intended for the external network, forward them via mosquitto. I am creating a new MQTT connection for painlessmeshboost which will allow me get external MQTT and send them to the mesh if they are on a specific topic. I'm not ready to share this code yet, but in theory, it will work. The nice thing about using the RPi for all of this is I don't need the extra ESP32 for the root, and it still does all the work.

Once you have this work done, sending MQTT from the local net to the mesh is simple so sending JSON based commands becomes a coding exercise. I'm building a mesh for my path lights which can't be easily connected to home wifi. I am using MQTT + JSON to turn lights on/off and control the colors. The nodes are all low cost ESP32C3, and right now, the root is an S2. Like I mentioned, I hope to make the root the RPi soon.

TLDR; Connect the RPi to the mesh and have it communicate with the local net over or USB wifi. Then use the Pi to do the MQTT forwarding, or make it the MQTT server.

Luca Sanna

unread,
May 24, 2024, 3:28:33 PM5/24/24
to painlessmesh-user

Hi, I also use an ESP32 as an MQTT bridge. I would be interested in eliminating it and creating a server on Ubuntu to communicate with OpenHAB. Have you managed to do this? Thanks.
Reply all
Reply to author
Forward
0 new messages