🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Peer-to-peer communication with Husarnet on M5StickC

    Arduino
    4
    10
    12.7k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      l3m0nad3
      last edited by l3m0nad3

      Hello,

      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.

      Thank you!

      l3m0n

      R 1 Reply Last reply Reply Quote 0
      • R
        robalstona @l3m0nad3
        last edited by

        @l3m0nad3 You could use mqtt protocol with with one of free mqtt server/broker like io.adafruit.com (i use it)

        L 1 Reply Last reply Reply Quote 0
        • L
          l3m0nad3 @robalstona
          last edited by

          @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.

          R 1 Reply Last reply Reply Quote 0
          • R
            robalstona @l3m0nad3
            last edited by

            @l3m0nad3

            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

            https://youtu.be/v6pcccSWl5s
            https://www.google.com/amp/s/techtutorialsx.com/2017/04/09/esp8266-connecting-to-mqtt-broker/amp/

            L 1 Reply Last reply Reply Quote 0
            • lukasmaximusL
              lukasmaximus
              last edited by

              This is possible also with esp-now, I've even seen it done with uiflow but haven't tried personally

              R L 2 Replies Last reply Reply Quote 0
              • R
                robalstona @lukasmaximus
                last edited by

                @lukasmaximus l3m0nad3 wrote about comunication over internet, so probably distance between these devices are to huge to use esp-now.

                1 Reply Last reply Reply Quote 0
                • L
                  l3m0nad3 @robalstona
                  last edited by

                  @robalstona Thanks for the links. Looks perfect for my purpose. I will take a look!

                  1 Reply Last reply Reply Quote 0
                  • L
                    l3m0nad3 @lukasmaximus
                    last edited by

                    @lukasmaximus Appreciate the insight but yes, as @robalstona mentioned, the devices are quite far apart (not within range for esp-now to work properly).

                    1 Reply Last reply Reply Quote 0
                    • world101W
                      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.

                      L 1 Reply Last reply Reply Quote 0
                      • L
                        l3m0nad3 @world101
                        last edited by

                        @world101 Thanks! I'll have a look. MQTT seems to be working well for now, super easy to setup as well.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post