Learn how to assemble an ESP32 based circuit for a 3D printed moon lamp that can be controlled over WiFi using pulse width modulation and N-channel MOSFETs.
[0:02] In the previous video, we 3D printed the moon component of the lamp.
[0:07] In this video, I want to focus on the electronics.
[0:11] We’re going to be using an ESP 32 as the brains of the project.
[0:17] This will let us control the lamp over WiFi.
[0:22] For the light, I’ve got a 3W common anode RGB LED.
[0:25] A common anode RGB LED has a circuit diagram that looks like this.
[0:42] We’ll need to add current limit resistors - these will need to be at least 1 Watt resistors
[0:58] as they’ll be dissipating quite a large load.
[1:14] To provide control over the brightness of the different colours we’re going to use
[1:18] pulse width modulation.
[1:19] With pulse width modulation a square wave is generated by the ESP32 and the duty cycle
[1:28] of the wave determines the brightness.
[1:31] So at 50% duty cycle, we would get 50% brightens.
[1:47] At 10% duty cycle 10% brightness
[2:05] and at 90% duty cycle 90% brightness.
[2:24] Now we can’t switch our LEDs directly as it would be far too much current for the ESP32
[2:30] to handle.
[2:31] So we’ll use N-channel MOSFETs to switch our LEDs on and off.
[2:51] In order to ensure the MOSFET turns on completely, we’ll pull the gate up to 5V and run the
[3:00] ESP32 output in OPEN DRAIN mode.
[3:05] Open drain means that our output acts rather like a switch to ground.
[3:11] When the output is low we are connected to ground and when the output is high we are
[3:29] This means that we can safely pull up to 5V without damaging our 3.3V device.
[3:38] We’ll forego a gate resistor as our circuit is not going to be switching at high speed
[3:50] so we just need to make sure our pull up resistor is low enough to switch on the gate quickly,
[3:56] but not so low that the ESP32 has to sink too much current.
[4:00] I’m going to go with around 470 ohms as this will give us around 10 milliamps which
[4:13] is well within the ESP32 capabilities.
[4:16] Let’s test out our circuit on a breadboard to make sure our assumptions are all correct.
[4:30] So, I have our components
[4:32] We have an ESP32
[4:36] A power MOSFET
[4:42] A 470 ohm resitor
[4:47] A 1 Watt 5 ohm resistor
[4:51] And a 3W RGB LED
[4:54] So, let’s assemble our circuit
[4:58] Speeded up assembly noises….
[5:28] That’s our circuit complete, I’ve wired up the blue
[5:38] channel and loaded my prototype software onto the ESP.
[5:39] Let’s see if it works.
[5:45] So, that’s driving the blue LED at 100% duty cycle
[5:55] This is around 50%, 10% and zero.
[6:07] So our circuit should work nicely.
[6:11] In the next video, we’ll jump onto EasyEDA and build a complete schematic and circuit
[6:19] So, see you in the next video!