12 day project: ESP32 - LED controller

Hi Liam

I attempted to do so some time ago but the highest resistor I had on hand was 22MΩ. In theory it is not that hard to get an approximation using the ADC itself as a sort of voltmeter.

  1. Apply 5V directly to an analog input.
  2. Monitor and note the ADC value (1023?)
  3. Apply the same 5V to the input via the highest resistor you can find. Up in the hundreds of MΩ if possible.
  4. Note the ADC value
  5. Consider the ADC itself as the lower leg of a voltage divider and work out the ratio using the ADC numbers. Knowing the value of your resistor you should then be able to work out the approximate Analog input impedance.
    You can expect it to be up in the GΩ area, I think from memory I found about 2GΩ but I had interference problems with the high resistances my set up and had to kill it with 10µF and then measure over 5 time constants which means my estimate was probably on the low side.

Another experiment worth demonstrating to illustrate the effects of a meter.
Measure a 5V supply with a DMM. Then measure the same supply via a 10MΩ resistor. The result will be 2.5V as the meter resistance has now become the lower leg of a voltage divider.

I guess what I am getting at here is be careful describing things like what looks like a simple voltage divider without explaining what effects different loads will have. Failing to consider this could mean some poor (inexperienced) bugger will build up a circuit using a divider to adjust voltage (even a potentiometer as that is what a pot is used for) connect it to a load and then start to panic when it does not work as expected and go off looking for faults which have been built in.

Believe me things like “built in” faults can be a real pain in you know where. Like design problems that haven’t been picked up in the test room and don’t manifest until you get in the field and the real world.
Cheers Bob


Hi Bob,

Yeah good points, with this project I think I’ll try and lock in some values and link back to your explanation with some of my own additions - a ‘good enough’/well placed passive power draw was the main consideration.

I cant even imagine the feeling when a system has been deployed and a fault occurs. It definitely backs up the idea that even with ‘accurate’ modelling some real world tests should happen.

Cheers again Bob!! :smiley:

Trying to get a measurement has been a bit of a struggle, the code in the documenation and the fact that ADC1 is used by WiFi (ESP-NOW uses the same systems) is the only written ADC’s for this version of the firmware. I’m not overly keen on learning to modify, build and test firmware so will come back and try and find a solution to this later(plus the ESP32 module that I have only features a single ADC - Technically 2 but the other is used as a reference voltage). At the rate the engineers at Core are working there will be a module for everything soon!

Due to the silicon shortage and the additional cost($3 ea from Digikey!) I wont feature a USB to serial connection on the PCB itself, Instead you’ll have to grab a CP2104 breakout (or another Serial to USB converter) to complete the breakout board equivalent.I think you could use a Pico instead of a USB-Serial chip - couldnt find anything on that though.

Onto the PCB!


Hi Liam
Sorry, I had not read through the whole thread/project and did not realise that divider is a real thing connected to an Arduino analog input. In that case the input resistance is so high it can be ignored.

I only read that post in isolation and the voltage divider bit came across as a general description. I picked up on all the bits missing which can cause headaches if not considered in the application of such a network. Sorry about that and I apologise. Will read in more detail in the future.

While on this subject though there is one thing often neglected in relation to potentiometers. Power rating. when a pot is rated as being able to dissipate say 1Watt. This means it can dissipate this power OVER THE WHOLE LENGTH of the resistive element. So if for instance you have a 1k 1W pot connected as a rheostat (variable resistor) and only are using 500Ω of it the dissipation capability becomes 0.5W. More than 1 person has come unstuck by not considering this.
Cheers Bob


Hi Bob,

No worries at all! Its quite a long topic and I definitely could have included something in that particular reply specifiying that it was going into one. Nonetheless it sparked a great discussion.

That would have completely slipped my mind, I’ve only used large pots >5k on logic level signals up to about 5 V. I’ve got a couple high power projects scoped out where this could be an issue if not taken into account. For most projects PWM has gotten me out of trouble - and a pot is just used as an input to an analog input/ a couple of OP AMP circuits at uni.


Day 4 - Designing the PCB

Using the schematic from this breakout board we can understand how it works and begin a schematic for our stripped down version.

Doing some more digging I came across this reference doc for designing boards with an ESP32 module.

Doing some research on BOM optimisation I figure that most makers would not want to buy the specific SMD components to get one together I opted for JLC’s assembly service. My original idea had me picking up a capacitor and resistor book - which would be great for prototyping. For all of the other components picking them off other boards - I was eyeing the juicy power supply from the SD card adapter.
This also means that you would only have to get major components and optional ones at that, such as the PiicoDev connection, an ADC, headers, 5V regulator and the logic level converter (the pin will have a resistor attached anyways).

This video was super helpful in giving some direction to my decisions: Episode 485: Bonus Content: How To Make A Custom PCB From Design To Assembly - Full Video - YouTube

Upon checking compatability of the .bin for the ESP32-C3 (the module I have. plus a couple devboards with the same chip on the way) it looks like it’s untested. At this stage I think I’ll continue with the PCB and might have to whip something up in Arduino if MicroPython doesnt work.


MOSFET Selection

To make the system efficient as possible the Rds of the LED should be as low as possible. Having a logic level of 3.3 V on the board will make selecting a power MOSFET slightly more difficult - Most 5 V DC barrel jack PSU’s start to max out between 6-10 A (Though the connectors max current rating is a bit how ya going at that amount).

This guide retouched the info that I’ve learnt from the forum and uni: https://www.digikey.com.au/en/blog/how-to-select-a-mosfet-for-logic-circuits-or-gate-design


Hi Liam
That is a pretty good link with some useful info re Mosfet choice.
There is a paragraph that all should read.
Input Capacitance - Ciss: The combination of the gate, oxide layer, and the body connection of a MOSFET act as a small capacitor that begins charging when voltage is present at the gate. It takes time to charge which results in an ON-state delay. Choose a MOSFET with the lowest input capacitance possible to avoid long delays and to minimize in-rush current which can be very high initially but lessens as the capacitor charges. Ideally, the ON-state delay is extremely short but may create enough surge to damage an I/O pin that has limited current sourcing capacity.

This is a subject I harp on a bit in my replies with particular reference to cumulative damage to low current I/O points. Indeed Core market a relay with driver board SKU Pololu 2480 which is quoted to be logic a level and would be attractive to anyone driving a relay with Arduino or RPi which has no gate current limiting resistor. I have been recommending a series resistor of minimum 330Ω be included to limit this current to a safe value.
Cheers Bob


Hi Bob,

Yeah it was the best one that I could find outside of reading a whole chapter from my textbook.
Everytime I’ve seen you mention it I can imagine its saved them a few questions and money down the line replacing a microcontroller.
That’s very interesting that Pololu hasnt included the resistor, usually theyre pretty good with their schematics - even a solder bridge and optional resistor would’ve been perfect. Might be worth linking to one of your replys on the product page to make others aware!


Day 5 - Schematic and EDA

To learn KiCAD I recommend taking a look at some getting started tutorials:

For general circuit design

  • Watching what the Core engineers make, and reverse engineer some boards
  • Getting involved in different faculties - Electronics relys on math, science physics, the obious ones. But there are other skills that are applicable; writting good code relies on English, Taking one out of Medicine’s book as it relies on lots of interconnected systems and levels of survival (plus the brain is an amazing computer), etc etc
  • Understanding electronics in general - and getting curcious about how stuff works helps lots here

After spending some time nutting out the schematic and plannging roughtly how everything will work together I think I’ve landed on a final design. I’ve learnt from someone that its worth getting something physical infront of you to review rather than trying to examine the digital copy.

This circuit is simiar to the ESP32-C3 Devboard, the circuit that I whipped up on the breadboard.
Mentioned breifly before I havent included the CP2102 as you can grab one for other projects and flashing multiple of the LED controllers - I plan to make a a DIY protoboard circuit so we can replicate the auto flashing circuit.(controlls the flash and reset pins)

The plan with the V1 of the board is to physically cut down the logic level converter to save a little bit of space - check out my other forum topic where I cut a Pico down

I’ve already started to consider the layout of the PCB, since there is effectively a ‘high power’ side of the board and one that is sensitive to RF considerations must be made to ensure there isnt any crosstalk (not sure if this is the correct jargon) between the sections).

ESP32_LED_Controller_v1.pdf (72.9 KB)

EDIT: Updated schematic, fixed the shorting caused by the MOSFET


Love the design-along format :ok_hand:
Setting realistic goals at the start of a project is one of the best ways to ensure it gets done at all, let alone on time.


Hi Liam
What does this do

Except short Vin to ground when activated ???
Cheers Bob


Hi Bob,

Looks like my midnight brain made a mistake there, The LED strips input should in the place of Vin.

I’ll get that fixed up and update the schematic, thanks heaps for catching that!

Cheers Michael! I’ve had plenty of projects fall due to scope creep and wanted to make this one a quick project, making changes when I have some time.

EDIT: Updated schematic, now the PSU should like the circuit a bit more :smiley:


That looks better. Makes a lot more sense. Not so much strain on Vin now.
Cheers Bob


Hi Bob,

Yeah a lot less ahaha, onto making the footprints now. Will keep the topic and repo updated!

1 Like

Day 8 - Final testing and updates

I got my order from Core yesterday and everything was perfect!! The devboards are here and I’m starting to test the code as we speak, the pin numbering will obviously change a bit but the main test is if ESP-NOW’s micropython port works.
Yesterday was a rest day (A rule I have is never rest 2 days in a row)

Changes for the new chip:
When erasing and flashing the --chip argument changes to ‘esp32-c3’ instead of the default ‘esp32’
A new version of firmware has to be flashed for the RISC-V architecture.
Erasing flash:
esptool --chip esp32-c3 --port COM4 erase_flash

Ensure that the flash location is ‘0x0’
esptool --chip esp32-c3 --port COM4 --baud 460800 write_flash -z 0x0 firmware-esp32-GENERIC_C3.bin

esptool --chip esp32-c3 --port COM4 --baud 460800 write_flash -z 0x1000 firmware-esp32-GENERIC_C3.bin EDIT: That did not work(Lucky CoolTerm was checked), to make sure the whole flash is cleared hold down the BOOT button and press reset to bring the ESP into download mode then run the code to erase the flash

EDIT: The code can be flashed on but only one message is received then some undefinined characters

Update: The transmit portion seems to work

EDIT: Both TX and RX were working from the board, there must’ve been an issue with my library so I have temporarily removed it from the main file


Day 9 - PCB Designs

The PCB is almost done and ready to be sent off, a few more changes to the overall shape and some general cleaning is next on the list.
I hope that the module is somewhat PiicoDev compatible, the mechanical connections spanning the middle can act as a mounting point for a couple of modules, a double module, or a mounting point for the entire thing).
The IO connections on the side will allow for servo’s to be connected so the modules have some sort of control - the MOSFET is also available if you don’t have any LEDs mounted (A single-direction motor driver? A Pump?)

Overall it’s about 110mm long, nominally 30mm wide and in the middle section it will be about 55mm wide.

Still todo:

  • Clean up the components - I’m not sure if the IO pads on the back have copper underneath or SS
  • Tune the profile of the board, clean up the placement and try and shrink it a bit
  • Run the traces
  • Make it look super cool
  • Physically print out the plot files to trace out the wiring to confirm there arent any other errors in the circuit (Thanks for noticing the one before @Robert93820 !!)
  • Pay for the PCB’s and assembly service and wait nervously
  • ???
  • Success?

Day 10 - Final V1 Revision

The PCB is almost ready to be sent off - I discovered a cute little hack to make rounds on your PCB, its a bit messy but gets the job done quickly.

  1. Create a circle as a guide, the of the round will be close to what the radius of this initial circle is
  2. Make a segment where the circle intersects the edges of the PCB
  3. From the centre of the segment create a line to the center of the circle, then extend the line to the circumference
  4. Use the arc tool to scribe a line, you may have to readjust the line that isn’t parallel to the horizontal or parallel planes

Day 11 - Nearing the end

I’ve reserved my final day for soldering and programming the actual PCB’s so this will be the last update for a little while, the PCB design is complete, I just have to update the dimension drawings, upload the gerbers to JLC along with the BOM and P&P files.

And the ooh so satisfying '0 DRC errors'..

Should have read the errors on my last PCB design :sweat_smile:

There’s still a bit of housecleaning to do in the GitHub repo and making sure the ESP-NOW packets are correctly unpacked - both for LED strips and sensor data (A parallel into a smart home system).
This is a majority complete - I’d say around 85% so will close off here.

If anyone has any questions while the PCB’s are being shipped lemme know! :smiley:

Update: The PCB has been sent off! I updated a couple of values around the resistors current limiting resistor (from 22k ohms- waaaaaaay too high down to 660 ohms which maxes the inrush current to 5mA)


Hey Liam,

Nice write-up, that notes section on the PCB is a great idea for smarthome systems! Can’t wait to see the finished boards :smiley:



Fantastic write up, really excited to see the finished project.