Category Archives: microcontroller

RISC-V based ESP32c3 with ESP-IDF part 3, OLED screen, and potentiometer

Table of Content

* Introduction
* ADC Limitations on some ESP32 SoCs
* Potentiometer
* OLED I²C Screen
* Building the project and flashing


This piece of software was done for new year 2022, but procrastination helped me to delay the release of the tutorial, it continue the traditionnal (but with detailed explanations) LED blinking introduction tutorial. The goal of this tutorial is to learn to use potentiometer and little I²C screens (4 pins are I²C only, SPI versions use more pins) in EPE-IDF, with ESP32 microcontroller SoC based. I use here a really cheap (<5€) but powerful AI thinker ESP-C3-32S, that use an efficient low power RISC-V microcontroller.

Full schema with part 2 and 3

You can find the complete sources files and prebuild RISC-V firmware for ESP32-C3 on my files repository.

This example contain two main parts in the single file adc/esp32c3/adc/main/adc_dma_example_main.c, called in app_main(void), at the end of the file :
* One simple example single_read(NULL);, that make only one read of the state of the ADC, it uses ADC 1, channels 2,3,4) and ADC 2 (channel 0) and display datas on terminal.
* One more complex example continuous_read(NULL);, that reads 256 times the state of the channels and display them in the console, and then make continuous reading and change the onboard RGB Led blue colour light intensity. Continue reading

Amusons nous avec un bouton et des LEDs sur une carte NodeMCU basée sur un ESP32-C3 (microcontrôleur RISC-V) avec ESP-IDF (FreeRTOS)

* This post is also available in English.


* Introduction
* Matériel : Le ircuit
** Composants
** Breadboard (planche à pain)
** Choix des ports GPIO et de leur broches sur la carte
** partie LED
** Résistances
** Partie bouton
* Le logiciel
** Initialisation
** Boucle principale
** Routine de Service d’intérruption (ou ISR, Interrupt Service Routine)
** Supprimer l’effet de rebond (Debouncing)
*** Chronomètre ESP


Mise à jour: J’ai écris, à la suite de cet article, un autre enseignant l’utilisation d’un potentiomètre et d’un écran OLED..

Suite à la mise à jour d’ArchLinux de python 3.9 vers 3.10, les outils ont du être réinstallés en effectuant :

cd ~/esp/esp-idf
git pull
git submodule update --init --recursive
./ esp32c3

Si vous n’avez jamais utilisé ESP-IDF, vous pouvez lire l’article précédent, d’introduction à ESP-IDF sur les ESP32-C3 basées sur du RISC-V, comment l’installer et lancer l’environment pour compiler et flasher le code. J’ai également écrit un article à propos de l’utilisation d’ESP32-C3 avec le système embarqué POSIX, Apache NuttX , mais il sera inutile ici.

Cet article concerne, à propos le développement, sur ESP32 (plus spécifiquement sur une carte NodeMCU basée sur un ESP32-C3 à moins de 3.5 €, mais il devrait fonctionner à peu près à l’identique sur les autres cartes basées sur de l’ESP) :
* Comment faire clignoter une LED externe en utilisant les ports dits GPIO, en expliquant comment déterminer la tension (en volts, V) et l’intensité (en ampères, A) nécessaires au fonctionnement de la LED, ainsiq que le calcul de la résistance nécessaire, par différents moyens.
* Des explications sur les bandes de couleur des résistances et le calcul des résistances montées en parallèles. Je donne également un lien vers un logiciel libre et à source ouverte que j’ai écrit, pour aider à calculer les résistances nécessaires (en fonction du type de LED, et de l’intensité désirée).
* Comment connectet un commutateur externe aux probches GPIO, et la résistance nécessaire. Comment recevoir et gérer de la bonne façon son état. Notamment en supprimant l’effet de rebond, (debouncing) liée à la pression physique d’un humain sur le bouton, ainsi que l’utilisationd el’interruption logicielle (c’est une tâche plus facile qu’il n’y paraît).
* Comment faire clignoter la LED RVB incluse et l’arrếter/démarraer en utilisant un interrupteur, de façon asyncrone.

Continue reading

Installer le système embarqué POSIX, Apache NuttX sur une carte basée sur un RISC-V ESP32-C3 avec Arch Linux

Table of content

Apache NuttX logo
* Introduction
* System packages
* NuttX sources and tools
* Configuration of devkit project, compilation and flash
* Connexion to NSH via (USB) serial
* The ostest and other basic sets (UPDATE)
* The apps examples (UPDATE)
* SPIflash, SMARTFS and file fsystems (UPDATE)
* NSH scripting (UPDATE)


Apache NuttX is a POSIX embedded system available on a lot of microcontrollers boards and architectures. After seeing some articles from Lup Yuen Lee, installing and working with NuttX on Bouffalo BL602 and BL604 RISC-V microcontroller boards, I discovered it can be installed on one of my boards. So I tried and managed to install it this evening on my recently acquired 3.5€ ESP32-C3S SoC nodeMCU board. ESP32-C3 is a SoC with RISC-V RV32IMC microcontroller, integrated 2.4GHz WiFi and Bluetooth LTE. The board contains a CH340 serial-USB converter, so it can easily be used/flashed/debugged from a computer. I already made a post about installing ESP-IDF tools and flashing examples on this RISC-V board.

For people that already know Espressif SoCs, here is a table of the power usage of some of their ESP models:

SoC        Modem sleep  Light sleep mode  Deep sleep mode
ESP8266          20 mA          2,000 µA            20 µA
ESP32            20 mA            800 µA            20 µA
ESP32-C3         20 mA            130 µA             5 µA

This article explains the procedure to prepare environment, on Arch Linux in November 2021. This is for x86_64, but should work on ARM too, only RISC-V toolchains are missing on ALARM, can be compiled, by using x86_64 versions of PKGBUILD (riscv32-elf-binutils, riscv64-elf-gcc). You can find the pricompiled binaries in my ArchLinux ARM archives including a little text about the order of compilation (binlib, gcc-bootstrap, newlib, gcc (and optionnaly, gcc and newlib again). Direct link to the three most usefull archives:
* riscv32-elf-binutils-2.36.1-2-armv7h.pkg.tar.xz
* riscv64-elf-gcc-11.1.0-1-armv7h.pkg.tar.xz
* riscv64-elf-newlib-4.1.0-1-any.pkg.tar.xz

Latest GIT version is needed In November 2021 for ESP32-C3, some other RISC-V architectures are already in stable releases. This is followed by an example of flashing and connect to the NSH shell, via serial on USB terminal. The dependencies for Debian based Linux on the official page, some parts could be incomplete. Some aspects of the NuttX, POSIX compatible Filesystem. OStest, GPIO and SPIflash included examples are also shortly described. Continue reading

Using ESP-IDF with RISC-V ESP32-C3 nodeMCU module on a Linux system

/>NodeMCU ESP32-C3S »></a></p>
<h2 id=Table of Content

* Introduction
* Step 1, install dependencies
* Step 2, install ESP-IDF
* Step 3, setup working environment
* Step 4, test « Hello World » example
* Step 5, tune the target, if needed
* Step 6, flash the project
* Step 7, viewing the output
* Troubleshooting
** Invalid value for ‘{esp32|esp32s2}’: ‘esp32c3′ is not one of ‘esp32′, ‘esp32s2′
** libsodium/crypto_box/curve25519xchacha20poly1305/box_seal_curve25519xchacha20poly1305.c
** Flashing errors
*** Detection, power, and device that disappear
*** usbfs: interface 0 claimed by ch341 while ‘brltty’ sets config #1
** Problem with CA certificates bundle


The list of existing ESP32-C3 SoC modules (with their specs) is very interesting, This one RISC-V core SoC has lower computing power than the ESP32-S3 (dual-core Xtensa ISA based, with a RISC-V co-processor core for « ultra low power » (ULP) mode), but RISC-V architecture is also far more efficient and will for sure have longer lifetime support and evolution due to its openness. ESP32-C3 use an RV32IMC (Integer, Multiplication/division and Compressed extensions) core.

I bought for my test a ESP-C3-32S-Kit on AliExpress (for ~3.4€). There is also an interesting option, where you can use really tiny 3~4 € ESP-C3-01M-Kit programmer interface/mother board, with a SoC included alone on a daughter (ESP32-C3M with an on PCB antenna). This allows, to flash several pads one only one programmer board. This reduce size of the needed system for final application to just the SoC and it’s power supply and peripherals. Pads of the SoC daughter board are wide enough to be easily soldered.

ESP-IDF is a tool to develop in C language on Espressif platforms, including ESP8266 and ESP32 series. It uses FreeRTOS free and open source embedded real-time OS for its SoCs. Sadly the official documentation for installing it is incomplete with the current state (November 2021) of GIT repository. Here is the mean to install a working ESP-IDF for this SoC series on Linux. This will be more compact and straight forward that the official with Linux+Windows installation.

About RISC-V more generally, I created this week a list of available Open Source RISC-V implementations, and open sources tools to build them or work with them. Continue reading