tags: ESP32 SSD1306 APDS9960 Gesture control Low power consumption
Source address:GitHub source address
The ESP32 OLED demo implements the following functions:
The following picture shows the physical hardware picture of ESP32 OLED Demo:
The DEMO uses ESP32_Button_Module_V2 as the development board, and contains the following components:
Complete hardware schematic diagram:ESP32_BUTTON_MODULE_V2.pdf
Schematic diagram of display screen and sensor power switch control:

VDD33 is the LDO VOUT 3.3V terminal, used as the power supply for ESP32, peripherals, and flash; VDD33_PeriP is the power supply for the display, temperature and humidity sensors, and gesture sensors. Transistor SI2301 is used as a power switch to control the voltage of VDD33_PeriP. By default, the gate terminal of the transistor is kept high and the power switch is turned off. The power switch is turned on by controlling Power_ON to keep it low.
We used the following methods to implement the ESP32 OLED demo:
We have used the following methods to minimize the power consumption of the device in low-power mode.
When the touch sensor is working, there are two states: sleep and measurement, the two states cycle alternately. In the normal working mode, we set the sleep time to be relatively short. After entering the low power mode, we set the sleep time to be relatively long to reduce power consumption as much as possible.
Called before entering low power modetouch_pad_set_meas_time(uint16_t sleep_cycle, uint16_t meas_cycle) The interface adjusts the sleep and measure time of the touch sensor.
Parameter Description:
sleep_cycle:sleep_cycle Determines the interval time between two measurements, the interval time t_sleep = sleep_cycle / (RTC_SLOW_CLK frequency).
can use rtc_clk_slow_freq_get_hz() Interface acquisitionRTC_SLOW_CLK frequency value.
meas_cycle:meas_cycle Determine the measurement time, the measurement time t_meas = meas_cycle / 8M, the maximum measurement time is 0xffff / 8 M = 8.19 ms.Long press the touch sensor button to enter the low-power mode. In the low-power mode, the sampling frequency of the touch sensor will be reduced to the lowest. Therefore, waking up from the low-power mode also requires a little longer to touch the sensor button. The current sampling in low power mode is as follows:

Note: In low power consumption mode, the average current of LDO VOUT 3.3V is about 30 μA, and the maximum current is about 1.6 mA. When it is at the peak, the touch sensor is in the measurement state.

Note: In low power consumption mode, the average current of LDO VIN 5V is about 45 μA, and the maximum current is about 2.1 mA.
First of all, you need to make sure that the ESP32 toolchain has been installed on your computer. For toolchain installation, please refer to the ESP-IDFREADME.md。
Execute the instruction to download the iot-solution project warehouse:
You can directly get the warehouse code recursively, which will automatically initialize all the required submodules:
git clone --recursive https://github.com/espressif/esp-iot-solution.git
You can also manually initialize the sub-module, first run the following command:
git clone https://github.com/espressif/esp-iot-solution.git
git submodule update --init --recursiveAfter the submodule code download is complete, the oled_screen_module in the Iot Solution project can be compiled and run. Switch to the esp-iot-solution/examples/oled_screen_module directory, and then perform the following steps.
Execute the following commands to compile and configure, such as serial port number and serial download speed can beSerial flasher config Configure in this menu option (if you don’t need to configure, you can skip this step).
cd YOUR_IOT_SOLUTION_PATH/examples/oled_screen_module
make menuconfig
Execute the following command to compile oled_screen_module. In the following command, flash is the download command, and monitor means to open the system for printing. You can choose to add it according to the actual situation.
make flash monitor
Note: When downloading the program, if the download cannot start automatically, you can try to enter the download mode manually. After downloading the firmware, press the reset button on the development board to re-run the program, you can view the serial port print.
The development environment of this article: MCU model: ESP8266 IDE environment: Arduino IDE 1.8.9 1.27 inch full color OELD module The content of this article: esp8266 uses u8g2 graphics library to d...
Foreword: For a long time, there were few opportunities to use OLED. Even if I used Daniel's code that was also a reference, I had to study it carefully recently. Write it down and forget it. The 0.61...
OLED SSD1306 driver writing pit: 1、 The pit is dead, and the "==" priority is higher than the "&". . . . . . . . . 2、(The following things are wrong, with a reminder) The first...
Pin definition GND: power ground VCC: Both 3.3v and 5v power supply are available D0: Serial input clock CLK D1: Serial input data RES: reset DC: Control input data/command (high level 1 is data, low ...
OLED use OLED use 1. Data communication using IIC Communication Protocol 2. OLED function OLED use 1. Data communication using IIC Communication Protocol Software simulation IIC start signal Software ...
Toss LOG There are many OLD drivers written online, here for convenience, directly using SSD drivers in the core 1, wiring RK3288 pin label OLED pin ...
This article will introduce the basic method of using the SSD1306 screen drive chip 1.1 Introduction SSD1306 is a screen drive chip that can be used to drive 128 * 64 pixel OLED. SSD1306 embedded cont...
When making this alarm clock, you need to make steps. The first step is to light OLED first, Step in the second step to set the clock module time The third step is to adjust the screen font position &...
Good After the previous article, we can already light an LED light. But this is the interpreter running one sentence at a time, so how does the script work? Here is the recommended sharing site for th...