Extra 5% OFF Use Code: OL05
Free Shipping over ₹999

Getting Started with ESP32-C6

Introduction

The Seeed Studio XIAO ESP32C6 is powered by the highly integrated ESP32-C6 SoC, featuring two 32-bit RISC-V processors: a high-performance processor running at up to 160 MHz, and a low-power processor clocked at up to 20 MHz. With 512KB of SRAM and 4MB of Flash, it provides ample programming space, opening up more possibilities for IoT control applications.

Specifications comparison

ProductsXIAO ESP32C6XIAO ESP32C3XIAO ESP32S3
ProcessorEspressif ESP32-C6 SoCEspressif ESP32-C3 SoCEspressif ESP32-S3R8
Two 32-bit RISC-V processors, with the high-performance one running up to 160 MHz, and the low-power one clocking up to 20 MHzRISC-V single-core 32-bit chip processor with a four-stage pipeline that operates at up to 160 MHzXtensa LX7 dual-core, 32-bit processor running up to 240 MHz
WirelessComplete 2.4GHz Wi-Fi 6 subsystemComplete 2.4GHz Wi-Fi subsystem
BLE: Bluetooth 5.0, Bluetooth MeshBLE: Bluetooth 5.0, Bluetooth MeshBLE: Bluetooth 5.0, Bluetooth Mesh
Zigbee,Thread,IEEE 802.15.4//
On-chip Memory512KB SRAM & 4MB Flash400KB SRAM & 4MB Flash8M PSRAM & 8MB Flash
Interface1x UART,1x LP_UART, 1x IIC, 1x LP_IIC, 1x SPI,11x GPIO(PWM), 7x ADC, 1xSDIO1x UART, 1x IIC, 1x SPI,11x GPIO(PWM), 4x ADC1x UART, 1x IIC, 1x IIS, 1x SPI,11x GPIO(PWM), 9x ADC, 1x User LED, 1x Charge LED
1x Reset button, 1x Boot button
Dimensions21 x 17.8 mm
PowerInput voltageType-C: 5V
BAT: 4.2V
Circuit operating Voltage (ready to operate)USB:5V@9mA
BAT:3.8V@9mA
Type-C: 5V@19mA
BAT: 3.8V@22mA
Charging battery current100mA350mA100mA
Power Consumption Model(Supply Power: 3.8V)Modem-sleep Model~ 30 mA~ 24 mA~ 25 mA
Light-sleep Model~ 2.5 mA~ 3 mA~ 2 mA
Deep Sleep Model~ 15 μA~ 44 μA~ 14 μA
Working Temperature-40°C ~ 85°C-40°C ~ 65°C

Features

  • Enhanced Connectivity: Integrates 2.4 GHz Wi-Fi 6 (802.11ax), Bluetooth 5(LE), and IEEE 802.15.4 radio connectivity, allowing for the application of Thread and Zigbee protocols.
  • Matter Native: Supports the building of Matter-compliant smart home projects, ensuring interoperability among different smart devices.
  • Security Encrypted on Chip: Utilizes the ESP32-C6 to provide secure boot, encryption, and Trusted Execution Environment (TEE) features, enhancing the security of smart home projects.
  • Outstanding RF Performance: Features an on-board antenna with up to 80m BLE/Wi-Fi range and offers an interface for connecting an external UFL antenna, ensuring reliable connectivity.
  • Leveraging Power Consumption: Offers four working modes, including a deep sleep mode with consumption as low as 15 μA, along with support for lithium battery charge management.
  • Dual RISC-V Processors: Incorporates two 32-bit RISC-V processors, with the high-performance processor capable of running up to 160 MHz and the low-power processor up to 20 MHz.
  • Classic XIAO Designs: Maintains the thumb-size form factor of 21 x 17.8mm and single-sided mount design, ideal for space-limited projects like wearable devices.

Hardware overview

XIAO ESP32C6 indication diagram
XIAO ESP32C6 Pin List

TIP

GPIO14 is used to select between using the built-in antenna or an external antenna. Before that, you need to set GPIO3 low level to turn on this function. If GPIO14 is set low level, it uses the built-in antenna; if it set to high level, it uses the external antenna. Default is low level. If you want to set it high, you can refer the code below.

void setup() {
  pinMode(3, OUTPUT);
  digitalWrite(3, LOW);//turn on this function
  delay(100);
  pinMode(14, OUTPUT); 
  digitalWrite(14, HIGH);//use external antenna
}

Getting started

To enable you to get started with the XIAO ESP32C6 faster, please read the hardware and software preparation below to prepare the XIAO.

Hardware Preparation

You need to prepare the following:

TIP

Some USB cables can only supply power and cannot transfer data. If you don’t have a USB cable or don’t know if your USB cable can transmit data, you can check Seeed USB Type-C support USB 3.1.

Solder header

XIAO ESP32C6 is shipped without pin headers by default, you need to prepare your own pin headers and solder it to the corresponding pins of XIAO so that you can connect to the expansion board or sensor.

Due to the miniature size of XIAO ESP32C6, please be careful when soldering headers, do not stick different pins together, and do not stick solder to the shield or other components. Otherwise, it may cause XIAO to short circuit or not work properly, and the consequences caused by this will be borne by the user.

BootLoader Mode

There are times when we use the wrong program to make XIAO appear to lose ports or not work properly. The specific performance is:

  • Connected to computer, but no port number found for XIAO.
  • The computer is connected and the port number appears, but the upload program fails.

When you encounter the above two situations, you can try to put XIAO into BootLoader mode, which can solve most of the problems of unrecognized devices and failed uploads. The specific method is:

  • Step 1. Press and hold the BOOT button on the XIAO ESP32C6 without releasing it.
  • Step 2. Keep the BOOT button pressed and then connect to the computer via the data cable. Release the BOOT button after connecting to the computer.
  • Step 3. Upload the Blink program to check the operation of the XIAO ESP32C6.

Reset

When the program runs abnormally, you can press Reset once during power-up to let XIAO re-execute the uploaded program.

When you press and hold the BOOT key while powering up and then press the Reset key once, you can also enter BootLoader mode.

Software Preparation

The recommended programming tool for the XIAO ESP32C6 is the Arduino IDE, so you need to complete the Arduino installation as part of the software preparation.

TIP

If this is your first time using Arduino, we highly recommend you to refer to Getting Started with Arduino.

And the on-board package for XIAO ESP32C6 requires at least version 2.0.8 to be available.

  • Step 1. Download and Install the stable version of Arduino IDE according to your operating system.

Download Arduino IDE

  • Step 2. Launch the Arduino application.
  • Step 3. Add the XIAO ESP32C6 on-board package to the Arduino IDE and click OK.
  • Step 4. Close the Arduino IDE and reopen it.

Add the XIAO-C6 Board

To install the XIAO ESP32C6 board, follow these steps:

https://espressif.github.io/arduino-esp32/package_esp32_index.json
  1. Add the above board manager URL to the preferences of your Arduino IDE, which is taken from the Installing – Arduino ESP32.
  1. Download the XIAO ESP32C6 board package.

note

Only available if the version of the esp32 board is greater than 3.0.0.

  1. Opt for XIAO_ESP32C6 variant.

Now enjoy coding ✨.

  • Step 1. Launch the Arduino application.
  • Step 2. Navigate to File > Examples > 01.Basics > Blink, open the program.
  • Step 3. Select the board model to XIAO ESP32C6, and select the correct port number to upload the program.

Once the program is successfully uploaded, you will see the following output message and you can observe that the orange LED on the right side of the XIAO ESP32C6 is blinking.

Battery Usage

The XIAO ESP32C6 series has a built-in power management chip that allows the XIAO ESP32C6 to be powered independently by using a battery or to charge the battery through the XIAO ESP32C6’s USB port.

If you want to connect the battery for XIAO, we recommend you to purchase qualified rechargeable 3.7V lithium battery. When soldering the battery, please be careful to distinguish between the positive and negative terminals. The negative terminal of the power supply should be the side closest to the USB port, and the positive terminal of the power supply is the side away from the USB port.

caution

When you use battery power, there will be no voltage on the 5V pin.

red indicator light

At the same time, we have the red indicator light for battery charging as XIAO ESP32S3:

The red light behavior for the XIAO ESP32 C6 is as follows:

  • When the XIAO ESP32 C6 is not connected to a battery:
    • The red light comes on when the Type-C cable is connected and goes off after 30 seconds.
  • When the battery is connected and the Type-C cable is connected for charging:
    • The red light flashes.
  • When the battery is fully charged via the Type-C connection:
    • The red light turns off.

Deep sleep mode and wake-up

The XIAO ESP32C6 has a complete deep sleep mode and wake-up function. Here we will show two of the more common examples offered by the ESP.

Demo1: Deep Sleep with External Wake Up

This code displays how to use deep sleep with an external trigger as a wake up source and how to store data in RTC memory to use it over reboots.

/*
Hardware Connections
======================
Push Button to GPIO 0 pulled down with a 10K Ohm
resistor

NOTE:
======
Bit mask of GPIO numbers which will cause wakeup. Only GPIOs
which have RTC functionality can be used in this bit map.
For different SoCs, the related GPIOs are:
- ESP32: 0, 2, 4, 12-15, 25-27, 32-39
- ESP32-S2: 0-21
- ESP32-S3: 0-21
- ESP32-C6: 0-7
- ESP32-H2: 7-14
*/

#define BUTTON_PIN_BITMASK (1ULL << GPIO_NUM_0) // GPIO 0 bitmask for ext1

RTC_DATA_ATTR int bootCount = 0;

/*
Method to print the reason by which ESP32
has been awaken from sleep
*/
void print_wakeup_reason(){
  esp_sleep_wakeup_cause_t wakeup_reason;

  wakeup_reason = esp_sleep_get_wakeup_cause();

  switch(wakeup_reason)
  {
    case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break;
    case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
    case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break;
    case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break;
    case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break;
    default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break;
  }
}

void setup(){
  Serial.begin(115200);
  delay(1000); //Take some time to open up the Serial Monitor

  //Increment boot number and print it every reboot
  ++bootCount;
  Serial.println("Boot number: " + String(bootCount));

  //Print the wakeup reason for ESP32
  print_wakeup_reason();

  /*
  First we configure the wake up source
  We set our ESP32 to wake up for an external trigger.
  There are two types for ESP32, ext0 and ext1, ext0 
  don't support ESP32C6 so we use ext1.
  */

  //If you were to use ext1, you would use it like
  esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK,ESP_EXT1_WAKEUP_ANY_HIGH);

  //Go to sleep now
  Serial.println("Going to sleep now");
  esp_deep_sleep_start();
  Serial.println("This will never be printed");
}

void loop(){
  //This is not going to be called
}

Demo2: Deep Sleep with Timer Wake Up

ESP32 offers a deep sleep mode for effective power saving as power is an important factor for IoT applications. In this mode CPUs, most of the RAM, and all the digital peripherals which are clocked from APB_CLK are powered off. The only parts of the chip which can still be powered on are: RTC controller, RTC peripherals ,and RTC memories.

This code displays the most basic deep sleep with a timer to wake it up and how to store data in RTC memory to use it over reboots.

/*
Simple Deep Sleep with Timer Wake Up
=====================================
This code is under Public Domain License.

Author:
Pranav Cherukupalli <cherukupallip@gmail.com>
*/

#define uS_TO_S_FACTOR 1000000ULL  /* Conversion factor for micro seconds to seconds */
#define TIME_TO_SLEEP  5        /* Time ESP32 will go to sleep (in seconds) */

RTC_DATA_ATTR int bootCount = 0;

/*
Method to print the reason by which ESP32
has been awaken from sleep
*/
void print_wakeup_reason(){
  esp_sleep_wakeup_cause_t wakeup_reason;

  wakeup_reason = esp_sleep_get_wakeup_cause();

  switch(wakeup_reason)
  {
    case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break;
    case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
    case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break;
    case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break;
    case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break;
    default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break;
  }
}

void setup(){
  Serial.begin(115200);
  delay(1000); //Take some time to open up the Serial Monitor

  //Increment boot number and print it every reboot
  ++bootCount;
  Serial.println("Boot number: " + String(bootCount));

  //Print the wakeup reason for ESP32
  print_wakeup_reason();

  /*
  First we configure the wake up source
  We set our ESP32 to wake up every 5 seconds
  */
  esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
  Serial.println("Setup ESP32 to sleep for every " + String(TIME_TO_SLEEP) +
  " Seconds");

  /*
  Next we decide what all peripherals to shut down/keep on
  By default, ESP32 will automatically power down the peripherals
  not needed by the wakeup source, but if you want to be a poweruser
  this is for you. Read in detail at the API docs
  http://esp-idf.readthedocs.io/en/latest/api-reference/system/deep_sleep.html
  Left the line commented as an example of how to configure peripherals.
  The line below turns off all RTC peripherals in deep sleep.
  */
  //esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
  //Serial.println("Configured all RTC Peripherals to be powered down in sleep");

  /*
  Now that we have setup a wake cause and if needed setup the
  peripherals state in deep sleep, we can now start going to
  deep sleep.
  In the case that no wake up sources were provided but deep
  sleep was started, it will sleep forever unless hardware
  reset occurs.
  */
  Serial.println("Going to sleep now");
  Serial.flush(); 
  esp_deep_sleep_start();
  Serial.println("This will never be printed");
}

void loop(){
  //This is not going to be called
}

tip

If you want to learn to use more of the deep sleep mode and wake-up functions, you can find more sample programs officially written for the chip by ESP in the Arduino IDE.

    Leave a Reply

    Your email address will not be published.

    Need Help?