wont serial read bytes over 128

This used to work now all of a sudden, on multiple PCs using Megas

unsigned char thisByte = ; will not accept extended ascii characters and display its byte value. ascii characters between 33-127 will serial print thier byte values to the serial monitor.

example code:

unsigned char thisByte; // for incoming serial data

void setup() {
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps

void loop()
{ while ( !Serial.available() );
  thisByte = ;
  Serial.println(thisByte, DEC);

type "d" in the serial monitor -> outputs 100
type in "ÿ" (which is 255) in the serial monitor -> outputs 195 191

this always worked in the past but now it doesnt. any insight?

Your post was MOVED to its current location as it is more suitable

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

I would think that your keyboard is encoding ÿ as UTF16 UTF-16 - Wikipedia, which uses 2 bytes for for each character. Why it's doing that now if it didn't before is for someone else to answer.

Whatever the underlying cause, it is not that serial read won't read bytes over 128.

This looks like UTF-8 encoding instead of UTF-16. May be a feature of the new IDE or Serial Monitor?

Look up UTF-8 encoding how to convert back into single byte character - if possible.

this is correct behaviour. ÿ is a two byte UTF-8 character. So you receive 195 191.


This should be the case since Arduino IDE 1.8.9 on Windows Systems

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