Data format for Sigfox transmission

  • Hi Folks,

    I'm stepping out of my comfort zone here and I'm sure I'm struggling on a simple task but I hope you can help.

    I've successfully integrated a Sipy into a 3rd party monitoring platform via Azure, works beautifully.

    However my test has involved simply sending example text eg

    s.send("23005000") #send 23.00°C and 50.00%rh

    Now I want to obviously use a variable to insert the real temp and humidity (for example), I feel I have tried a million permutations of hex, bytes etc etc and always get a error or the data is not received correctly on the Sigfox backend.

    Can anyone give me a steer here on the correct approach (using micropython) or point me to some suitable documentation

    Out simply eg the below is clearly wrong, so how do you process a float for transmission?

    temp = 23.00
    hum = 50.00


  • @jez You can use the ustruct module to get a packed byte string. See If you prefer readable content, you can use one of the two format methods: % operator or str.format(). The result is a str, which you may have to convert to a bytes object with str.encode().
    Both is pretty much standard Python.

  • Ok... so can you explain how do you create a list of bytes from a int or float for example? Would you just chop it up into individual characters or use hex?

  • @jez According to the docs maybe you should try with bytes:

    s.send(bytes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]))

Log in to reply

Pycom on Twitter