Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

How to translate numbers to hex


#1

I have a Logomatic V2 data logger, if I want my Baby-O to send a sensor value (uint16_t) of 384 I have to separate the 3-4 and 8 and send them as Hex code 0x33 0x34 and 0x38. The logger writes it in txt format 384 and if I send a 0x2C I get a csv table.

How can I separate these numbers so I can send them individually to my logger?


#2

Hello.

You could use sprintf (the documentation can be found here) to write your sensor value to a buffer (or string) and pass it to the OrangutanSerial class function serial_send, which will transmit the data from the buffer to your data logger until all bytes (defined by size) have been sent. You can find more information about the OrangutanSerial class and its parameters in the “Orangutan Serial Port Communication” section of the AVR Library Command Reference.

If you continue to have trouble with your code, you can post it here, and I would be happy to take a look at it.

- Amanda