Richard Bartlett from richards-tech (who wrote the RTIMULib software used for that demo) helped me to figure out the data format used in the serial link; the arduino transmits the 4-byte hex representation of the floating point data.
I can use CPython to convert the data back into a float, confirming that the data I extract is a sane floating point number.
Now I need to generate that hex data from a float on the pyboard.
The following code (from Stack Overflow) can do the trick:
Code: Select all
def float_to_hex(f):
return hex(struct.unpack('<I', struct.pack('<f', f))[0])
float_to_hex(17.5) # Output: '0x418c0000'
-Bryan