PyBytes MQTT integration

  • 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.)

  • 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

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

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


    Best Regards,
    Ahmad El Masri

  • 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)

  • 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?

  • 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

  • Thx @Ahmad,

    The connection I am talking about is between an application on a private server and Pybytes. So this application could subscribe to 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.


  • Hi @paul_tanner

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

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

    port: 1883
    username: your email address
    password: your device token


    Please let me know if you require additional details

Log in to reply

Pycom on Twitter