Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    PyBytes MQTT integration

    Scheduled Pinned Locked Moved Pybytes IoT platform
    9 Posts 3 Posters 152 Views 3 Watching
    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.
    • P Offline
      paul_tanner
      last edited by

      Is it possible to have an MQTT client watch data coming into PyBytes from registered devices and consume that data in real time? This client would be running on premise (not AWS). I've seen nothing in the docs on this so far. (It's the approach we use with TTN but in this case we'll be using NB-IoT not LoRa.)

      1 Reply Last reply Reply Quote 0
      • ahmadelmasriA Offline
        ahmadelmasri
        last edited by

        Hi @paul_tanner

        You can use MQTTX to seeMQTT data between your device and Pybytes.

        name: up to you
        client-id: up to you

        host: mqtt.pybytes.pycom.io
        port: 1883
        username: your email address
        password: your device token

        Link: https://github.com/emqx/MQTTX

        Please let me know if you require additional details

        Ahmad EL Masri

        1 Reply Last reply Reply Quote 1
        • P Offline
          paul_tanner
          last edited by paul_tanner

          Thx @Ahmad,

          The connection I am talking about is between an application on a private server and Pybytes. So this application could subscribe to mqtt.pybytes.pycom.io. If there were multiple devices it sounds like it would need to subscribe once for each device. What would the data coming back look like?

          BTW. This doesn't sound secure enough to meet GDPR requirements.

          Regards.

          1 Reply Last reply Reply Quote 0
          • ahmadelmasriA Offline
            ahmadelmasri
            last edited by

            Hi @paul_tanner

            Yes, you can do this on a private server, if you want to listen to multiple devices you should do multiple subscriptions!

            BTW. This doesn't sound secure enough to meet GDPR requirements.

            We are trying to enhance our security level to match GDPR requirements. knowing that if you use the secure connection between device and MQTT which make the communication more secure, however, in this case, you should listen to another port 8883

            Best Regards,
            Ahmad El Masri

            Ahmad EL Masri

            P 1 Reply Last reply Reply Quote 0
            • P Offline
              paul_tanner @ahmadelmasri
              last edited by

              Thx @ahmadelmasri
              Having a secure connection is good so we would do that.
              However, there should be a shared secret between the two servers so that other people cannot subscribe to our data.

              Please note my other question: What would the data coming back look like?

              I am assuming it will be a json object. But what will the contents be?

              1 Reply Last reply Reply Quote 0
              • G Offline
                Gijs
                last edited by Gijs

                Hi,
                The MQTT messages are all formatted in JSON. They contain a header, message type etc. You could turn on pybytes debugging on the device to see all content as well, using

                import pycom
                pycom.nvs_set('pybytes_debug', 99)
                

                Features like OTA firmware update and Pymakr Online are structured differently (outside of the scope of MQTT)

                1 Reply Last reply Reply Quote 0
                • ahmadelmasriA Offline
                  ahmadelmasri
                  last edited by

                  Hi @paul_tanner

                  So we pack the message. it contains the command, the pin, and the payload (encoded also, but based on the type int, string, tuple, float, ...) check below link for more details on how to decode the message.

                  Reference: https://docs.python.org/3/library/struct.html

                  Best Regards,
                  Ahmad El Masri

                  Ahmad EL Masri

                  P 1 Reply Last reply Reply Quote 0
                  • P Offline
                    paul_tanner @ahmadelmasri
                    last edited by

                    @ahmadelmasri thanks for that. Does PyBytes hold the device location (if not transmitted by the device) and if so is that accessible though this API?

                    Also, could you clarify "command" and "pin" in this context please.

                    ahmadelmasriA 1 Reply Last reply Reply Quote 0
                    • ahmadelmasriA Offline
                      ahmadelmasri @paul_tanner
                      last edited by

                      Hi @paul_tanner

                      No Pybytes will not transmit location unless you request that under Pybytes.

                      basically, we use this to identify some actions on Pybytes section for example sending a location command. the pin is used to know which pin is used under this command (also can be used as an identifier a random number)

                      The part that holds the message details is the payload.

                      Best Regards,
                      Ahmad EL Masri

                      Ahmad EL Masri

                      1 Reply Last reply Reply Quote 0

                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                      With your input, this post could be even better 💗

                      Register Login
                      • 1 / 1
                      • First post
                        Last post

                      Pycom on Twitter

                      Pycom