Table of Content
* ADC Limitations on some ESP32 SoCs
* 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.
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
* Ce billet est également disponible en français.
Table of Content
* Hardware: The Circuit
** Choose GPIO ports and their board pins
** LED part
** Switch button part
* The Software
** Main loop
** ISR (Interrupt Service Routine)
*** ESP timer
Update: I wrote this article, following this other one that teach the usage of a potentiometer and an OLED screen..
After ArchLinux upgrade from python 3.9 to 3.10, tools need to be reinstalled by:
git submodule update --init --recursive
If you never used ESP-IDF, you can read the previous introduction article to ESP-IDF on RISC-V based ESP32-C3, how to install it and start environment for compiling and flashing code. I also wrote article about using ESP32-C3 with Apache NuttX POSIX OS, but it will be useless here.
This article is about, on ESP32 (more specifically a less than 3.5€ ESP32-C3 based NodeMCU board, but it should work about the same way on other ESP based boards) :
* How to blink an external LED using GPIO, including how to know LED needed voltage (V), amperage (A), and compute needed resistor, by using several possible means.
* Explanations about resistors values colours bands and computation of parallel mounted resistors. I also give link to free and open source software I wrote to help to compute needed resistors (depending on LED type, and desired intensity).
* How to connect an external switch to GPIO, and which resistor is needed. How to receive and manage it’s state a good way. By debouncing physical human pressure on switch, and use software interruption (that’s more easy that it could sounds).
* How to blink included RGB LED and stop/start it by using switch, an asynchronous way.