Seeeduino Xiao nRF52840 Serial.read()

Hmm, I have the same problem:

platform.ini

[env]
framework = arduino
platform = https://github.com/maxgerhardt/platform-nordicnrf52
monitor_speed = 115200

[env:xiaoble_adafruit]
board = xiaoble_adafruit

main.cpp

#include <Arduino.h>

// google suggested this one. It helps on the compiler, but does not yield anything in the serial monitor
//#include "Adafruit_TinyUSB.h"

void setup() {
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  Serial.println("hello world");
  digitalWrite(LED_BUILTIN, ! digitalRead(LED_BUILTIN));
  delay(500);
}

Compiler cant find Serial

.pio/build/xiaoble_adafruit/src/main.cpp.o: In function `setup':
main.cpp:(.text.setup+0x8): undefined reference to `Adafruit_USBD_CDC::begin(unsigned long)'
main.cpp:(.text.setup+0x18): undefined reference to `Serial'
.pio/build/xiaoble_adafruit/src/main.cpp.o: In function `loop':
main.cpp:(.text.loop+0x2c): undefined reference to `Serial'
collect2: error: ld returned 1 exit status
*** [.pio/build/xiaoble_adafruit/firmware.elf] Error 1

If I use the mbed variant it will compile, but then I am not able to get into the 5uA region when sleeping in delay()

As code hints, I have including the Adafruit_TinyUSB.h, bit it didn’t really help

This is correct.

Try further adding

monitor_dtr = 1

(or 0) to the platformio.ini, it might unblock the serial monitor.

Ok let me try. New platformio.ini contains

[env]
framework = arduino
platform = https://github.com/maxgerhardt/platform-nordicnrf52
monitor_speed = 115200
monitor_dtr = 1

[env:xiaoble_adafruit]
board = xiaoble_adafruit

and main.cpp

#include <Arduino.h>
#include "Adafruit_TinyUSB.h"

void setup() {
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  static int i = 0;
    
  Serial.print("hello new blinky world: ");
  Serial.println(i++);
  
  digitalWrite(LED_BUILTIN, ! digitalRead(LED_BUILTIN));

  delay(500);
}

Still I get nothing in the Serial Monitor. Then by chance I hit Enter and notice a line of output.

It appears that sometimes if I send something, enter and random keys seems to work, on the monitor my code will output a line. My new program include a counter, and this shows that a lot of lines has been skipped. Furthermore sometimes I receive a garbled line.

An example from my Serial Monitor

hello new blinky world: 697
hello new blinky world: 698
hello new blinky world: 700
hello new blinky world: 701
hello new blinky world: 702
␜�pzbOȶM�w�{���hello new blinky world: 1508
hello new blinky world: 1525

I tried monitor_dtr = 1, monitor_dtr = 0, and without at all.

1 and none yields this “can be induced” behavior whereas 0 appears to give no output no matter what I do.

Suggestions on what to try next?

I have no idea how that could be possible. Unfortunetaly I also don’t have the board for it.

I tried the same configuration and code on a windows instead of my linux, and this seems to work much better. There must be something funky going on in my aging linux installation