Problems in Serial Tutorial


#1

I’ve been following along the serial tutorial and I’ve been seeing some weird stuff. I’ll document here both some observations and fixes.

Starting with this code which is what the Serial tutorial page suggests:

int incomingByte = 0;

void setup() {
  Serial1.begin(38400);
}

void loop() {
  while (Serial1.available())
  {
    incomingByte = Serial1.read();
    Serial1.write(incomingByte);
  }
}

This will result in no output being sent. The reason seems to be because of the int declaration for incomingByte. If I change this to a uint8_t, then it works great. I have some other strange solutions that also work, but I think this is the one that most people should be using. Using int makes it look like there are interactions between write() and print() and println() where one works and the other doesn’t and one before the other seems to break the following call.

Also noted: After I flash this program, the Bluz stays in a green fast blink for about 30sec to a minute before it finally switches to a blue BLE connecting blink. If I turn off then on the Bluz, it starts right up immediately.


#2

I will modify the example to reflect this, thanks for pointing it out!