Getting Started with ESP32-C3: Development Environment Setup

Getting Started with ESP32-C3: Development Environment Setup

  • 1. Introduction

  • 2. Setting Up the Development Environment

    • 2.1 Downloading the ESP-IDF Environment

    • 2.2 Compiling the Code

    • 2.3 Programming and Verification

  • 3. ESP32-C3 LED Analysis

  • 4. Using WiFi Functionality

  • 5. Conclusion

1. Introduction

The ESP32-C3 uses a chip based on the RISC-V architecture, which is currently focused on RISC-V research. Therefore, we will explore the usage of this chip.

The main features of this chip are as follows:

  • Utilizes a single-core RISC-V 32-bit processor with a four-stage pipeline architecture, operating at a frequency of 160MHz.
  • Built-in 400KB SRAM and 384KB ROM
  • Comprehensive Wi-Fi subsystem
  • Low-power Bluetooth

Getting Started with ESP32-C3: Development Environment Setup

In terms of peripheral support

Peripheral Remarks
GPIO x22
SPI x3
UART x2
I2C x1
I2S x1
Infrared Transceiver 2
LED PWM 6
USB Serial 1
Watchdog 3

From the design positioning of the chip, it is mainly targeted at smart home devices or small IoT devices, etc.

Next, let’s experience the development process.

2. Setting Up the Development Environment

To use this chip, setting up the development environment is crucial, as it will enhance the experience. This article primarily focuses on setting up the environment based on Ubuntu 20.04, but it also supports environment setup on Windows and other platforms.

  • ESP32-C3
  • Ubuntu 20.04 PC
  • Serial Cable

Getting Started with ESP32-C3: Development Environment Setup

2.1 Downloading the ESP-IDF Environment

Note: The current ESP-IDF has not yet been integrated into the officially released version (v4.2). You need to use the v4.3 beta version.

The download link is as follows:

https://dl.espressif.com/dl/esp-idf/releases/esp-idf-v4.3-beta3.zip

Once downloaded, simply extract it.

Note that the following software packages need to be installed for compilation:

sudo apt-get install git wget flex bison gperf python3 python3-pip python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0

Enter esp-idf-v4.3-beta3 and execute ./install.sh.

Getting Started with ESP32-C3: Development Environment Setup

After compilation, the above image result should appear.

Input

. ./export.sh

This step will add the necessary PATH for ESP-IDF to the environment variables. If you want these environment variables to persist after rebooting, you can add them to the system environment variable ~/.bashrc

alias get_idf='. /home/bigmagic/workspace/esp-idf-v4.3-beta3/export.sh'

Getting Started with ESP32-C3: Development Environment Setup

Then update the source

source ~/.bashrc

Every time you open a new window, simply enter get_idf to automatically add the environment path.

2.2 Compiling the Code

Once the ESP-IDF environment is set up, you can compile and download the source code.

First, create your own working directory.

Note: Every time you open a new terminal, enter get_idf to update the environment.

First, compile the hello_world program.

Getting Started with ESP32-C3: Development Environment Setup

Enter the following commands:

cp -r $IDF_PATH/examples/get-started/hello_world .

Then start the configuration:

cd hello_world
idf.py set-target esp32c3
idf.py menuconfig

Where menuconfig is used to configure related settings. Here you can configure the Wi-Fi SSID, etc. Since hello_world does not require much configuration, you can skip this step.

Simply enter

idf.py build

to start compiling.

Getting Started with ESP32-C3: Development Environment Setup

2.3 Programming and Verification

Programming can be done using the following command:

idf.py -p PORT [-b BAUD] flash

Where [-b BAUD] is an optional setting for the baud rate.

Note that on Ubuntu, you may encounter permission errors when trying to access the serial hardware.

You can modify the serial port permissions:

sudo chmod 777 /dev/ttyUSB0

Since my device is recognized as /dev/ttyUSB0, I will change its permissions.

idf.py -p /dev/ttyUSB0 flash

Under normal circumstances, the following information should appear.

Getting Started with ESP32-C3: Development Environment Setup

Finally, input

idf.py -p /dev/ttyUSB0 monitor

to see the serial input information.

Getting Started with ESP32-C3: Development Environment Setup

To exit the monitoring mode, enter Ctrl + ].

3. ESP32-C3 LED Analysis

Having completed the basic environment setup, we can now analyze the peripheral programming based on the above environment.

The schematic diagram for the ESP32-C3-DevKitC-02 can be found on the following website.

https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32c3/hw-reference/esp32c3/user-guide-devkitc-02.html

The schematic diagram for its RGB LED is as follows:

Getting Started with ESP32-C3: Development Environment Setup

The current LED used is SK68XXMINI-HS, which is primarily driven by PWM.

The relevant principle explanation is as follows:

https://www.rose-lighting.com/wp-content/uploads/sites/53/2020/05/SK68XX-MINI-HS-REV.04-EN23535RGB-thick.pdf

By adjusting the different PWM settings, different colors of light can be produced.

Getting Started with ESP32-C3: Development Environment Setup

A demo already exists in ESP-IDF.

cp -r $IDF_PATH/examples/peripherals/rmt .

Then enter the led_strip directory.

Enter the following commands:

idf.py set-target esp32c3

Then select configuration:

idf.py menuconfig

Select the relevant configuration:

Getting Started with ESP32-C3: Development Environment Setup

Change the hardware pin to 8.

Getting Started with ESP32-C3: Development Environment Setup

After configuration, enter S to save and Q to exit, then proceed to compile.

idf.py build

Download the program:

idf.py -p /dev/ttyUSB0 flash

After downloading, you should see the LED blinking normally.

4. Using WiFi Functionality

One of the important features of the ESP32-C3 is its ability to connect to WiFi.

Step 1: Get the Code

cp -r $IDF_PATH/examples/wifi .
cd wifi/getting_started/station

Step 2: Select Configuration

idf.py set-target esp32c3

Step 3: Set WiFi SSID and Password

idf.py menuconfig

Setting SSID and Password

Getting Started with ESP32-C3: Development Environment Setup

Step 4: Start Compiling

idf.py build

Step 5: Download the Program

idf.py -p /dev/ttyUSB0 flash

Step 6: Test the Program

idf.py -p /dev/ttyUSB0 monitor

At this point, the test involves connecting to your router and pinging the station via the local IP.

Getting Started with ESP32-C3: Development Environment Setup

You should see that the IP address is obtained normally and the module can be pinged, indicating that the experiment is successful.

5. Conclusion

This article describes the programming method of the ESP32-C3 through environment setup, peripheral programming, and WiFi program demonstration. Overall, using the ESP-IDF integrated development environment can significantly reduce the hassle of environment setup, allowing for a smooth development of upper-level business.

Especially with the API programming approach, it makes the programming model more focused on business design, allowing for network applications, smart homes, remote monitoring, etc. From the experience, this RISC-V chip does not show significant differences in usage compared to other ESP32 chips. In the future, I will work on some small projects with the ESP32-C3, and only with more testing data can the advantages and disadvantages be reflected.

Leave a Comment

×