Serial.print not working in void setup

using a Seeed Studio XIAO nRF52840 (Sense), Serial.print will not print in the serial monitor

#include "Adafruit_TinyUSB.h"
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>

#define BNO055_SAMPLERATE_DELAY_MS (100)
Adafruit_BNO055 bno = Adafruit_BNO055(-1, 0x28);

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(115200);
  while (!Serial) {}
  Serial.println("starting");

  if(!bno.begin()) //checking for connection w IMU
  {
    Serial.print("BNO055 not detected");
    digitalWrite(LED_BUILTIN, LOW);
    while(1);
  }

}

Welcome to the forum

Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE

1 Like

Just out of interest, what happens if you put a 1 second delay() before the first print statement ?

What is connected to the board ?

it still didn't work, unfortunately. it's going to be connected to an Adafruit BNO055 IMU

what speed is the serial monitor set to?

115200

sometimes you really need to step back

i would try a very simple program that does nothing but configure the port and print something in setup()

no libraries (i.e. #includes)

Try the simplest possible sketch that just prints in setup(), no libraries, nothing connected to the board

it will print with this code

#include "Adafruit_TinyUSB.h"

void setup() {
  Serial.begin(115200);
  while (!Serial) {}
  Serial.println("test");
}

if i don't include the tinyusb library, i get this error

c:/users/evanm/appdata/local/arduino15/packages/seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\evanm\AppData\Local\Temp\arduino-sketch-3807E8328886481D2EF8C9070C3E1CD1\sketch\sketch_sep26a.ino.cpp.o: in function `setup':
C:\Users\evanm\AppData\Local\Temp\.arduinoIDE-unsaved2022826-7824-122bd1s.rqd6\sketch_sep26a/sketch_sep26a.ino:4: undefined reference to `Adafruit_USBD_CDC::begin(unsigned long)'
c:/users/evanm/appdata/local/arduino15/packages/seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\evanm\AppData\Local\Temp\.arduinoIDE-unsaved2022826-7824-122bd1s.rqd6\sketch_sep26a/sketch_sep26a.ino:5: undefined reference to `Adafruit_USBD_CDC::operator bool()'
c:/users/evanm/appdata/local/arduino15/packages/seeeduino/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\evanm\AppData\Local\Temp\.arduinoIDE-unsaved2022826-7824-122bd1s.rqd6\sketch_sep26a/sketch_sep26a.ino:6: undefined reference to `Serial'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

without the while (!Serial) {} nothing prints

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