How to detect disconnection from USB and how to keep the radio active on battery

You may have already tried,

What happens if I leave the USB cable connected on the XIAO side with the magnet and disconnect it on the PC side?
Or have you tried it with a USB cable that is not magnetized but properly connected?

When disconnected from USB, the serial monitor disconnects, is this not the cause?

may be an intermitant connection… power surge

Same thing, I lose radio connectivity.

Yeah tried that too.

Yup, it disconnects the serial monitor, but stays working on the battery. Everything works except the radio loses connectivity. Even the uptime counter I have running on millis() stays working. I don’t think thats the cause, because even if comment out all the Serial stuff and don’t call Serial.begin, and leave the serial monitor closed it happens.

I will try disconnecting and see if I can reproduce it.
The board library is mbed-enable 2.9.2, correct?
I can connect the receiver to the USB, disconnect the USB cable on the transmitter side, and see if it works on battery power.

1 Like

Hmm, I just tried with the mbed-enable core, 2.9.2 because I was testing with the non-mbed enabled core, 1.1.8 and it works fine with the mbed-enabled core! No disconnect of the radio!

It’s got to be something specific to the non-mbed core!

I think you are starting to see some of the cause.
I will try it here as well.

edit
It works fine with mbed 2.9.2!

1 Like

Is it working?? I don’t think it is ok