Sending 8 bit int through Serial

Hi, I'm trying to print an 8 bit integer from my microcontroller and receive it through my com port in python. However, when I write something like this

uint8_t val = 25;
Serial.print(val);

and read through my python code, I found that the microcontroller sends this value as 2 bytes (one 2 and one 5) rather than the 8bit value of 25. Is there a way to send this as the 1byte value and not 2 bytes?

Serial.write(val);

Check this out:

Serial.write()

I’ve written a small tutorial on interfacing with Python. It might be useful may be - See Two ways communication between Python3 and Arduino

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.