Create a Beautiful Lantern with ESP32-C3

Create a Beautiful Lantern with ESP32-C3

Project Name: Cyber Lantern – Decorative Light Based on ESP32-C3

Project Author: Carele

Introduction

The lantern recommended today is loved by the engineers of the EDA operation teamvery much!! And the editor must recommend it no matter what.

Create a Beautiful Lantern with ESP32-C3

The reason is simple, because this lantern is – beautiful, with a detailed tutorial, and also has technical content.

01
Materials for Making the Lantern
01
Shell Material Description

Create a Beautiful Lantern with ESP32-C3

1

Use FDM-3D printing for this model

2

The top eaves and lamp grilles are printed with white PETG materials

3

The corner decorations and corner pieces are printed with blue PLA materials

4

The lamp holder is printed with mint green PC/ABS materials

02
Details of Component Composition

Create a Beautiful Lantern with ESP32-C3

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 /
03
How to Install?
01
Shell Installation Reference Diagram

Create a Beautiful Lantern with ESP32-C3

Create a Beautiful Lantern with ESP32-C3

02
Base Installation Reference Diagram

Create a Beautiful Lantern with ESP32-C3

Light Holder – Controller Diagram 1

Create a Beautiful Lantern with ESP32-C3

Light Holder – Controller Diagram 2

Create a Beautiful Lantern with ESP32-C3

Light Eaves 3 – EC11 Encoder

So, if you want to handcraft a lantern, how should the software and hardware be designed?

04
Hardware Design

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.

Create a Beautiful Lantern with ESP32-C3

Schematic Diagram_Control

Create a Beautiful Lantern with ESP32-C3

Schematic Diagram_ Driver

Create a Beautiful Lantern with ESP32-C3

Schematic Diagram_ Interface

Create a Beautiful Lantern with ESP32-C3

PCB

Create a Beautiful Lantern with ESP32-C3

Light Board Schematic Diagram

Create a Beautiful Lantern with ESP32-C3

Light Board PCB Diagram

Next, I will explain4 important circuit modules.

01
MCU

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.

02
Lighting

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.

Create a Beautiful Lantern with ESP32-C3

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).

03
LED Driver

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:Create a Beautiful Lantern with ESP32-C3

04
Human-Computer Interaction

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.

05
Software Design

Based on the above hardware design, the overall system framework is shown in the figure below:

Create a Beautiful Lantern with ESP32-C3

Next, I will talk about how I further improved the functions through4 sections of software design.

01
System Refresh

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).

02
WS2812b LED Driver

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.

03
White LED Driver

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.

04
EC11 Encoder

The EC11 encoder is divided into:

  • Quadrature encoder-related program design

  • Push button program design

The human-computer interaction logic is as follows:Create a Beautiful Lantern with ESP32-C3

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.

06
Open Source Website

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

Create a Beautiful Lantern with ESP32-C3

Click the end of the article【Read the original text】 to directly enter the original text.

Create a Beautiful Lantern with ESP32-C3

“Cyber Lantern – Decorative Light Based on ESP32-C3” has open-source materials:

  • Circuit design files

  • Source code (development environment is Arduino IDE)

Create a Beautiful Lantern with ESP32-C3

Create a Beautiful Lantern with ESP32-C3

Create a Beautiful Lantern with ESP32-C3

*This article is a user creation from the “Lichuang Open Source Hardware Platform”, if there is any infringement, please contact to delete

Like it if you see it!
Create a Beautiful Lantern with ESP32-C3
Click here to view the original project

Leave a Comment

Your email address will not be published. Required fields are marked *