Seeeduino Xiao nRF52840

Hello all,

I’m having trouble getting serial data from a qt gui to be read with PlatfromIO. The code works great on ArduinoIDE in both the serial monitor and from the gui, sending a single char to give LED brightness. However, putting the code on PlatfromIO works from the serial monitor but not from the GUI. The GUI says information was sent and the COM is writable, but the Seeeduino Xiao never reads it.

Does anyone have any experience with changes being made from Arduino to PlatfromIO for reading serial devices on Xiao boards?


#include <Arduino.h>
#include <U8x8lib.h>
#include <Wire.h>

int ledPin = 10;
char serialData = 0;
int ledBrightness = 0;

U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* clock=*/ PIN_WIRE_SCL, /* data=*/ PIN_WIRE_SDA, /* reset=*/ U8X8_PIN_NONE);   // OLEDs without Reset of the Display

// the setup function runs once when you press reset or power the board
void setup() 
  u8x8.setFlipMode(1);   // set number from 1 to 3, the screen word will rotary 180
  u8x8.setCursor(0, 0);

  pinMode(ledPin, OUTPUT);
  analogWrite(ledPin, 0);


// the loop function runs over and over again forever
void loop() 
    serialData =;

    ledBrightness = serialData - '0';
    ledBrightness = normalizeData(ledBrightness,0,9);;

    writeLed(ledPin, ledBrightness);

void printOLED(int value)
  u8x8.setCursor(0, 0);


void writeLed(int ledPin, int ledBrightness) 
  analogWrite(ledPin, ledBrightness);

int normalizeData(int data, float min, float max)
  return ((data-min)/(max-min))*255;

What’s the platformio.ini and the version of the Arduino core used within the Arduino IDE for the your board? (Tools->Board manager)

I’m using for the .ini:

; PlatformIO Project Configuration File
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
; Please visit documentation for the other options and examples

platform =
board = xiaoblesense
framework = arduino
monitor_speed = 115200

lib_deps = 

And Version:2.0.3
Seeed XIAO nRF52840 Sense for Arduino

How can that be? The package index has the nRF52 cores 2.6.1 to 2.8.1 (ArduinoCore-mbed fork) or 1.0.0 (Adafruit_nRF52_Arduino fork).

Can you post the package URL that you added in File->Preferences?

Oh sorry I misread!

It is:

Should be:

I see. My custom platform uses the at-the-time-of-writing up-to-date core version, 2.6.1. I’ll update it to 2.8.1 so that we can compare apples to apples.

1 Like

I did update the core to the latest one but the changes are extremely small and none of them relate to the USB Serial: Update core to 2.8.1 · maxgerhardt/framework-mbed-seeed@b7a8974 · GitHub.

Can you grab the changes by using the CLI with the command

pio pkg update -g -p ""

and recompiling and reuploading the project anyways?

Thanks for the help! I updated the package and it still works for the serial monitor but not from the usbC cable to the nRF52840 plugged into my computer that is sending the serial data.

And just to make tripple sure that you’re not using the 1.0.0 version accidentally, you have this board selected right in the “Seeed nRF52 mbed-enabled Boards” right?


(Well, the one below that with the “Sense” in it)

Good catch. I am not using the mbed-enabled board version, but the Version 1.0.0 Seeed nRF52 Board in Arduino.

Screenshot (2)


I see.

Two options from here (well, parallel):

  • I update the platform to allow using the “1.0.0” version (extremely badly named by Seeed for another Adafruit_nRF52_Arduino fork, don’t know why they have the same board support in two different cores at all)
  • or, please try to see if in the Qt C++ code, you can assert the “DTR” (data terminal ready) signal of the opened serial port. Some Arduino cores have the pecularity that they will silently ignore and data sent to the virtual USB serial port if the virtual DTR signal is not asserted. The RTS can be left alone. This could unblock the firmware running with the PlatformIO fimware (using ArduinoCore-mbed fork) from accepting data from your Qt program.

Specifically, code from QSerialPort sets DTR to high upon closing port; won't emit readyReady when DTR is otherwise held high. | Qt Forum looks good. Try with both false and true in serial.setDataTerminalReady().

1 Like

Awesome let me try and update my Qt code first and add the DTR signal.

You’re a genius. Adding that to my QSerialPort initiallization fixed the problem. I think, exactly like you said the Arduino core was ignoring the data without the DTR signal. It works now with this:

1 Like

Great to hear! I’ll still work on getting the “1.0.0” supported in PlatformIO. If you were to use the custom built-in libraries of the Arduino core like BLE, they would be different between ArduinoCore-mbed and Adafruit_nRF52_Arduino, and the sketch would not compile anymore under PlatformIO.

Makes sense, so currently the only PlatfromIO support is for the ArduinoCore-mbed that you created. If I run into those issues I’ll bug you again :wink:

I’ve created a xiaoblesense_adafruit and xiaoble_adafruit board that make use of the “1.0.0” Seeed Adafruit nRF52 core version. Can you execute the update command again (or if that doesn’t work, delete <home directory>/.platformio/platforms/nrf52*) and flash the example code from GitHub - maxgerhardt/pio-xiao-ble-test: Test programs for PlatformIO support for Xiao BLE (Sense) boards. on it, which is from here? I’d very much like to know whether the project can be uploaded and the BLE Uart service shows up in the App and can be connected to.

What settings should I use in the .ini file?

For your board and the given example file,

platform =
board = xiaoblesense_adafruit
framework = arduino
monitor_speed = 115200