Project Name: Cyber Lantern – Decorative Light Based on ESP32-C3
Project Author: Carele
The lantern recommended today is loved by the engineers of the EDA operation teamvery much!! And the editor must recommend it no matter what.
The reason is simple, because this lantern is – beautiful, with a detailed tutorial, and also has technical content.
Use FDM-3D printing for this model
The top eaves and lamp grilles are printed with white PETG materials
The corner decorations and corner pieces are printed with blue PLA materials
The lamp holder is printed with mint green PC/ABS materials
Material Name | Quantity | Remarks |
---|---|---|
Top Decoration | 1 | / |
EC11 Encoder | 1 |
Solder XH2.54-4P terminal Key1, KeyA, KeyB, GND See details below |
Light Eaves 1, Light Eaves 2, Light Eaves 3 | 1 | / |
Magnet | 4 | For magnetic assembly of light eaves |
M3 Nut | 4 | For magnetic assembly of light eaves |
Corner Decoration (Lamp Corner) | 4 | / |
Light Grid | 4 | Requires overlay paper – it is recommended to use sulfuric paper |
Light PCB | 1 | / |
Corner Light (Bottom Corner) | 4 | / |
FPC 1.0x8P Reverse | 1 | / |
Controleer PCB | 1 | / |
M3x6 Screw | 4 | / |
M3 Nut/Copper Embedded Nut | 4 | / |
Polymer Battery | 1 | Size 65x55x9.5mm PH2.0-2P terminal |
Light Holder | 1 | / |
Light Holder – Controller Diagram 1
Light Holder – Controller Diagram 2
Light Eaves 3 – EC11 Encoder
So, if you want to handcraft a lantern, how should the software and hardware be designed?
Initially designed with reference to the bedside lamp function.
It needs to be able to: emit light, have a battery, support power management, be easy to switch, adjust brightness, and reserve IoT functions.
Schematic Diagram_Control
Schematic Diagram_ Driver
Schematic Diagram_ Interface
PCB
Light Board Schematic Diagram
Light Board PCB Diagram
Next, I will explain4 important circuit modules.
Using ESP32-C3-MINI-N4 as the controller.
This module mainly implements light control, IoT and other functions.
No additional chips are needed, just connect it to a PC using a USB cable to program.
The lighting part is located on a separate PCB (Light board).
Using aluminum substrate as the material, ensures that the LED will not overheat seriously under long-term lighting, extending the LED lifespan.
Lighting is divided into two parts: white and color.
-
White Light: Uses two color temperature LEDs, uses the same 3528 package LED, adopts 4×4+4×4, series drive.
-
Color Light: Uses 4×3 WS2812b as the color light source(5050 package).
Due to the series LED scheme, the driving voltage requirement is high, so a boost/buck LED driver must be selected.
Based on actual conditions, let’s calculatewhat the maximum voltage of this project is, and then select the model.
For white lighting, it is composed of cold white and warm white LEDs, each consisting of 16 LEDs in series.
Each LED has a maximum forward voltage of3.2V and a rated current of20mA.
Therefore, the rated driving voltage is 3.2×16=51.2V(LEDs in series)
It is necessary to have a driver that can boost to above 51.2V.
And a rated current of 20mA is a requirement that most drivers can meet.
In summary, it is necessary to choose a boost/buck type LED driver scheme with a maximum voltage greater than 51.2V (and leave some margin).
After comparison, I chose to use dual-channel LGS63042 LED driver to drive the warm white and cold white LEDs separately.
The driving circuit is shown in the figure below:
In terms of human-computer interaction, this projectuses the EC11 encoder. By combining the following interaction tasks, rich human-computer interaction can be realized.
The EC11 encoder has:
-
A quadrature encoder
-
A non-locking push button switch.
The encoder can achieve functions:
-
Value adjustment
-
Mode adjustment
-
etc.
The push button switch (button multiplexing) can execute single-click, double-click, and long-press tasks respectively.
Based on the above hardware design, the overall system framework is shown in the figure below:
Next, I will talk about how I further improved the functions through4 sections of software design.
Set a timer andset Tsms as the refresh cycle.
Each Ts cycle refreshes the light-emitting state of the LEDs (LED1, LED2 brightness; LED3 hue, brightness).
This project uses the FastLED library to implement the WS2812b LED driver.
Currently, it mainly implements color control and brightness control:
Color Control
Color is controlled based on the HSV color model.
Each color is determined by these 3 values:
-
Hue (H)
-
Saturation (S)
-
Value (V).
Change color by controlling hue.
Currently, saturation and brightness are set to 255 by default
Brightness Control
-
Set an unsigned char variable Light3Level,to store brightness value.
-
Use FastLED.setBrightness(Light3Level);to set the stored brightness value.
-
Use the FastLED.show(); functionto refresh the light-emitting state of WS2812b.
White LEDs are driven by the LGS63042 driver circuit, which canbe dimmed using PWM.
Use the analogWrite(LED1, Light1Level); functionto set the duty cycle of the PWM wave input to the EN pin of the driver chip, range: 0~255.
The EC11 encoder is divided into:
-
Quadrature encoder-related program design
-
Push button program design
The human-computer interaction logic is as follows:
Quadrature Encoder (Knob)
The interaction of the quadrature encoder is implemented through the Encoder library.
-
Register the encoder with two pins using Encoder Enc(KEYB, KEYA);
-
Set an initial position and then read the new position newPosition using Encoder library Enc.read();
-
Compare the new position with the old position oldPosition and make corresponding value adjustments
Push Button (Button)
The interaction of the push button is implemented through the OneButton library.
-
As shown in the human-computer interaction logic diagram,the button is divided into single-click, double-click, and long-press functions, and tasks are reused respectively.
This project is open-source!
——Want to replicate? Want to give a thumbs up to the author? You can copy the open-source website and go to the original text.
Open Source Website:https://oshwhub.com/carele/lightbox
Click the end of the article【Read the original text】 to directly enter the original text.
“Cyber Lantern – Decorative Light Based on ESP32-C3” has open-source materials:
-
Circuit design files
-
Source code (development environment is Arduino IDE)
*This article is a user creation from the “Lichuang Open Source Hardware Platform”, if there is any infringement, please contact to delete
Leave a Comment
Your email address will not be published. Required fields are marked *