Esp32c3 Arduino Code No Effect

I followed this link and installed library for ESP32C3 in Arduino IDE.
I tried to run the simple LED blinking code, but got nothing at serial monitor:

// define led according to pin diagram
int led = B10;

void setup() {
  // initialize digital pin led as an output
  pinMode(led, OUTPUT);
  Serial.begin(115200);
}

void loop() {
  Serial.println("LED HIGH");
  digitalWrite(led, HIGH);   // turn the LED on 
  delay(1000);               // wait for a second
  Serial.println("LED low");
  digitalWrite(led, LOW);    // turn the LED off
  delay(1000);               // wait for a second
}

Here is IDE output for compiling and code uploading

Sketch uses 250966 bytes (19%) of program storage space. Maximum is 1310720 bytes.
Global variables use 13884 bytes (4%) of dynamic memory, leaving 313796 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.5.1
Serial port COM7
Connecting...
Chip is ESP32-C3 (revision v0.4)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 64:e8:33:11:8f:58
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00003fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00050fff...
Compressed 13200 bytes to 9522...
Writing at 0x00000000... (100 %)
Wrote 13200 bytes (9522 compressed) at 0x00000000 in 0.2 seconds (effective 425.2 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.1 seconds (effective 391.1 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 586.7 kbit/s)...
Hash of data verified.
Compressed 262336 bytes to 146515...
Writing at 0x00010000... (11 %)
Writing at 0x0001b060... (22 %)
Writing at 0x00022f65... (33 %)
Writing at 0x000296b0... (44 %)
Writing at 0x0002f6a2... (55 %)
Writing at 0x000358fe... (66 %)
Writing at 0x0003b5f5... (77 %)
Writing at 0x00043c00... (88 %)
Writing at 0x00049f54... (100 %)
Wrote 262336 bytes (146515 compressed) at 0x00010000 in 2.1 seconds (effective 1002.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Hello, sorry to see that your program is not running correctly, according to your code there is generally no problem, if you can see the LED flashing, please make sure that your serial port monitor, the COM port is correctly configured (the same as the burning COM port) and the baud rate is set to the same as the code

If you write it like this, maybe it will work

  Serial.begin(115200);
  Serial.setTxTimeoutMs(0);

I didn’t link a LED. So no LED flashing.
One more issue: original code in the link use int led = D10;, which leads to compiling error. I have to change to B10.

Serial.setTxTimeoutMs(0)

gives compiling error. Compiler cannot find that function.
The available one is setRxTimeout, adding which does not solve my problem.

My XIAO works.

BoardServicePackage : esp32 by Espressif Systems 2.0.14
Board Select : XIAO_ESP32C3

// define led according to pin diagram
int led = D10;

void setup() {
  // initialize digital pin led as an output
  pinMode(led, OUTPUT);
  Serial.begin(115200);
}

void loop() {
  Serial.println("LED HIGH");
  digitalWrite(led, HIGH);   // turn the LED on 
  delay(1000);               // wait for a second
  Serial.println("LED LOW");
  digitalWrite(led, LOW);    // turn the LED off
  delay(1000);               // wait for a second
}


This is my Arduino IDE.
Is there anything not right?

Your board is not selected correctly. You need to select XIAO ESP32C3 instead of ESP32C3 Dev Module.

1 Like

thank you, guys.
I chose the wrong board in the beginning.
After select Xiao ESP32C3, the code works well.

2 Likes

Hi,

Today I tried to run another app, but got this from serial monitor:


What is wrong here?

Have you re-powered or reset the program after uploading?

yes, I did.
Somehow it is not stable.
Sometimes, my new code starts to run.
Sometimes it just stuck at ESP-ROM; Quit often nothing appears.

BTW, I found this link: Get Started - ESP32-C3 - — ESP-IDF Programming Guide v4.3 documentation, which seems different from Arduino IDE.
Which one is recommended, Arduino or ESP-IDF?

You need to check if your code is not outputting from the serial port because of a logic problem. If you are using xiao esp32c3, we still recommend you to use Arduino

It’s the same code pasted by @msfujino.
OK, I connect ESP32C3 to an external sensor through SPI interface. The sensor draw power from ESP32C3’s 5v pin.
If I disconnect that 5v pin and GND from the sensor; the code is able to run if I reset C3 board.
As I read from this wiki, the power is drew directly from USB, and the sensor current in running mode is less than 10mA. The USB port should be able to handle.

Why don’t you try powering the sensor from the 3V3 pin?

the sensor requires at least 3.7v power supply.
For fast prototyping, I don’t want to add extra circuit.

What sensor (board?) are you connected to? And the connecting pins specifically?
Is the input/output of the sensor 3.3V? XIAO accepts only 3.3V input/output.

TI ADS1299, whose digital input/output is 1.8~3.3v.