No USB connection after upload code for I2C to XIAO


I am new at this forum and a newbi with the XIAO and I apologize for my english. I come from germany.

I use a PCF8574 expansion board to control 8 LEDs. With a sample Code it works fine.
Then I tried to use my own code, where I sent light patterns, in the form of binary data like: B11101111 one after the other to the PCF8574.
No errors while compilation. But after sending to the XIAO it was dead!
Or at least unresponsive via USB.

Since I thought the whole thing was a stupid coincidence, I tried it again right away with another XIAO.

Bad idea! Reproducible the same course.

So now 2 XIAO dead!

I can not explain this. The code is really not that complicated.

Where is my failure? And how can I repair the XIAO?

Here is the code:

#include <Wire.h>

// address of PCF8574 IC on TWI bus
#define IO_ADDR (0x20)
int val[6];

void setup() {
Wire.begin(); // initialize the I2C/TWI interface

val[1] = B11111110;
val[2] = B11111101;
val[3] = B11111011;
val[4] = B11110111;
val[5] = B11101111;
val[6] = B11011111;

void loop() {

delay (100);

delay (100);

delay (100);

delay (100);

delay (100);

delay (500);


Hi zenton

Have you tried “double reset”? If you’re lucky, XIAO may reappear in Device Manager. If you’re unlucky, you may need to rewrite bootloader to bricked XIAO.
Searching the topic of ‘Products & Technology> XIAO’, you will find many of the same problems.

Now I have tried the double reset. And I am lucky. One of the XIAOs is alive again. The other one I have to try.
But the Problem with the code still exist. I see no reason why the XIAO can be shot down by such a simple code. It does not matter whether the PCF is connected or not.


I’m glad you were lucky.

If you write “int val [6]”, when you use it, from “val[0]” to “val [5]”.

Yes I know. I have corrected it. But the same behaviour.

As a test, I uploaded your code to XIAO.

1.For the original code, XIAO does not appear in Device Manager after uploading.
2.After “double reset”, XIAO will appear in Device Manager.
3.Next, check the XIAO port in the menu “Tool” “Serial port”.
4.I changed your code to int val [6]; ----> int val [7]; and uploaded it.

The upload was completed without XIAO disappearing from Device Manager.

This is very interesting. I had changed the queries and declarations from val[1]…val[6] to val[0]…val[5].
I will try your version, when I am at home.

Many thanks for your help

That is the solution.
Code works fine now and I have reanimated all my XIAOs.

What I don’t understand is why the compiler didn’t complain but the XIAO just went to sleep.

Thanks again.

1 Like