Peer-to-peer communication with Husarnet on M5StickC
l3m0nad3 last edited by l3m0nad3
I came across this tutorial for using Husarnet to setup peer-to-peer communication between two ESP32 devices (press button on device1 turns on LED on device2, etc.).
However I cannot seem to do
#include <M5StickC.h>to gain access to M5StickC libraries, since it seems like the fork of ESP32 board they used to add Husarnet libraries to is likely out of date.
I am wondering if anyone had success with using Husarnet for P2P communication between two M5StickC's over the internet (each on different network)? Or if anyone had suggestions for other P2P implementations over the Internet?
My goal is to have button press on M5StickC-#1 to do something on screen of M5StickC-#2; and vice-versa.
@robalstona thanks for the reply, do you happen to have any example you could point me towards, where mqtt was used for two devices to send something to each other? Very simple transmission such as a "key word" which would make the recipient device do X if it was code Y sent.
On the mqtt server / broker you can store, subscribe (read), feed (write) various types of data in so-called channels / topics / feeds. You can treat such a channel as a global variable programmatically available from any device using the mqtt protocol. For example, on one device you send a value to the selected channel, using the "mqtt publish" function. The second device, on the other hand, "listens" to this channel using the "mqtt subscribe" function and when it arrives, it receives the value sent from the first device. Of course, any device can send and receive.
it's hard to find a specific complete example of communication in arduino. You will find faster separately how to send and publish data from the device using the mqtt protocol and how to receive subscribe using mqtt
If you put these two examples together, you'll get what you need. See the links, they will brighten up something more
This is possible also with esp-now, I've even seen it done with uiflow but haven't tried personally
@lukasmaximus l3m0nad3 wrote about comunication over internet, so probably distance between these devices are to huge to use esp-now.
@robalstona Thanks for the links. Looks perfect for my purpose. I will take a look!
world101 last edited by world101
You should look into Blynk (https://blynk.io/) for IoT communication over the internet. It’s a good alternative to MQTT. I use both of them. Search the forum for examples of both.
@world101 Thanks! I'll have a look. MQTT seems to be working well for now, super easy to setup as well.