Converting sensor data to byte

  • I need some advice how to convert data to bytes so I can send it to TTN. F.e. the Pysense has several sensors which produce floating point numbers. I'd like to be able to convert all data read from the sensors into bytes so I can send them in one packet. For this I need some advice.

    How to get data converted into bytes for sending to TTN?

  • Thanks for the suggestions! Still looking to get some examples how to serialize sensor data with MicroPython for TTN. All examples I found are for Arduino. Maybe @bucknall has some nice examples around?

  • @tobru

    This link might also be helpful.

  • @tobru You may use struct.pack() and struct.unpack() for that purpose. Look at the Python manuals for proper use. You may also convert data into ASCII strings with the format commands, which are then human readable.

Pycom on Twitter