HomeESP8266/ESP32ESP32 & 410 LEDs: Experiments 1 - Matrix

ESP32 & 410 LEDs: Experiments 1 – Matrix

How many LEDs is too many? We are about to find out in this part!

I have made this awesome 410 RGB LEDs matrix. It’s fun and serves the educational purposes for now. Soon enough, the ESP32 & 410 LEDs matrix will be transformed into something even more fun. I thought I will take you on this journey with me while I’m trying to figure out how everything works. If you are new to LEDs, this read if for you. I hope you will learn as much as me!

ESP32 & 410 LEDs

First of all, I’d like to thank Banggood.com for sponsoring this. They were kind enough to let me play with some LEDs. Here are the items I use in my matrix

Build yours with Banggood

Buy it using these links to support NotEnoughTech.

410 LEDs is quite a lot!  This thing will need a good power supply. I will test things out first and see how I can wire things up. I used the existing adhesive to glue the strips to the piece of wood. This should be good enough for the testing. I will see how comfortable I am with writing a code for this, then decide what would be my final project.


To build this matrix I cut the strips to 41 LEDs per line.  The 41 isn’t a magical number, it’s the upper limit of the longest wooden board I could find in my garage. I have the total of 10 lines. Each new line has an opposite direction. To drive the WS2812B correctly, you have to check what direction the strip should be facing. Basically, I have created one very long snake. To learn how to drive WS2812B read this.

5V power supply

To power it all up I needed a power supply. I picked a 5V 30A switching power supply. My napkin math tells me this is more than plenty to get each individual LED powered up. This thing looks beefy!

Initially, I connected the power supply at the beginning of the strip to figure out how many LEDs I could power before the voltage collapses. The answer is 40 (depending on brightness). Increasing the voltage could work, but remember, these are individually addressable LEDs, therefore, you are risking a damage to it, if you drive bigger than 5V voltage, but turn on only a few LEDs.

As you can see, up to about 50 LEDs we have no issues at all. Past that, you can notice small flickering. Turning on more LEDs reveals an even bigger problem. The entire matrix turns yellow, then orange and then almost all red.

Time to change the way I connect the power supply. I followed this schematic to make sure that voltage is evenly distributed.

I used 2 channels of my power supply connecting it from both ends. I also interlinked each line to reduce the voltage drop even further. I have more than enough current to drive all the junctions. Remember that each time a junction is created, the current splits in half.

Lastly, I changed the brightness to 253 (max) to see if I have enough juice to power the entire matrix. I’m pleased to say, it’s bright as hell. I’m still half blind while I type these words.


The FastLED library comes with a calibration script. My strips had to be calibrated before I could write colours using names.  Upload the script and follow the instructions. You will be asked to change the order (if needed) of RGB values. This change is declared in the void setup().

ARDUINO IDE: Calibration
#include "FastLED.h"

// RGB Calibration code
// Use this sketch to determine what the RGB ordering for your chipset should be.  Steps for setting up to use:

// * Uncomment the line in setup that corresponds to the LED chipset that you are using.  (Note that they
//   all explicitly specify the RGB order as RGB)
// * Define DATA_PIN to the pin that data is connected to.
// * (Optional) if using software SPI for chipsets that are SPI based, define CLOCK_PIN to the clock pin
// * Compile/upload/run the sketch 

// You should see six leds on.  If the RGB ordering is correct, you should see 1 red led, 2 green 
// leds, and 3 blue leds.  If you see different colors, the count of each color tells you what the 
// position for that color in the rgb orering should be.  So, for example, if you see 1 Blue, and 2
// Red, and 3 Green leds then the rgb ordering should be BRG (Blue, Red, Green).  

// You can then test this ordering by setting the RGB ordering in the addLeds line below to the new ordering
// and it should come out correctly, 1 red, 2 green, and 3 blue.

#define NUM_LEDS 6

// Data pin that led data will be written out over
#define DATA_PIN 6
// Clock pin only needed for SPI based chipsets when not using hardware SPI
//#define CLOCK_PIN 8


void setup() {
	// sanity check delay - allows reprogramming if accidently blowing power w/leds

      // Uncomment one of the following lines for your leds arrangement.
      // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
      // FastLED.setBrightness(CRGB(255,255,255));
      // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS);

      // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<LPD8806, 9, 10, RGB>(leds, NUM_LEDS);

      // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);

void loop() {
   leds[0] = CRGB(255,0,0); 
   leds[1] = CRGB(0,255,0);
   leds[2] = CRGB(0,255,0);
   leds[3] = CRGB(0,0,255);
   leds[4] = CRGB(0,0,255);
   leds[5] = CRGB(0,0,255);

Coding ESP32 & 410 LEDs using Arduino IDE

I wrote a very simple code in Arduino IDE to map the pot’s input to the LEDs. The ADC (Analog to Digital Converter) has 12-bit value. I have to take this into consideration when translating the analogue voltage from pin 2 to a digital output (PWM) sent via pin 5.

As the voltage on the power rail can drop due to power draw, connect the potentiometer to the 5V pin of the ESP32 so the mapping script would read the values without any interference.

Here is the code:

#define NUM_LEDS 410
#define DATA_PIN 5
#define BRIGHTNESS 50

int potPin = 2;
int val = 0;

void setup() {
  FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS); // GRB is the correct value for me
  FastLED.setBrightness(  BRIGHTNESS );

void loop() {
        int val = analogRead(2);
        int numLedsToLight = map(val, 0, 4095, 0, NUM_LEDS);
        for(int led = 0; led < numLedsToLight; led++) { 
            leds[led] = CRGB::White; //change colour here


As you can see, ESP32 & 410 LEDs matrix works great. The next step is to decide how to drive the LEDs. There is more than one option. We can use LED channels for each line, or try to leave it as it is. This is something I will explore in part 2.

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.


Nothing says "Thank you" better than keeping my coffee jar topped up!


Support me on Patreon and get an early access to tutorial files and videos.


Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

Smart Ideas with

Automate your space in with these ecosystems and integrate it with other automation services


Learn NodeRED

NodeRED for beginners: 1. Why do you need a NodeRED server?

To server or not to server? That's a very silly question!

Best Automation Projects

Tuya SDK for beginners: Intro to Tuya Cloud API

Working with Tuya Cloud API. A guide to Cloud automation for beginners, get started with REST!

NEST your old thermostat under $5

Nest-ing up your older thermostat under $5

Nora – Google Assistant in NodeRED

Integrate Google Assistant with NodeRED thanks to Nora - NodeRED home automation

Sonoff Zigbee Bridge – review

Sonoff line up will soon include Sonoff Zigbee Bridge and more Zigbee sensors - here is the first look

DIY Smart Washing Machine – for about 15 bucks!

Learn how to add washing machine notifications to your Google Home on the cheap

Smart Home

I wish I had known about the SMLIGHT ZigBee/Thread Coordinators sooner!

SMLIGHT coordinators are the perfect choice for anyone just diving into ZigBee. SLZB-06 series is easy to use and comes with future-proofing Thread support.

Sonoff ZigBee Bridge U isn’t what you think!

I expected Sonoff ZB Bridge U to be a next gen ZigBee bridge with Matter support. Turns out, there is much more to talk about!

Aqara “Everything” M3 Hub

When I started my home automation adventure, the current problem was the number of ecosystems needed to outfit your smart home. Aqara M3 Hub has a long list of protocols to match that!

Sonoff ZB Micro did it! (and bonus ZigBee device)

A long time ago, I took an angle grinder to the humble Sonoff Micro, will I do this again? Meet Sonoff ZB Micro and Sonoff ZB Contact (SNZB-04P) - the latest devices from the ZigBee ecosystem.

This keyless entry is PRO: SwitchBot Lock Pro

SwitchBot Lock Pro offers comprehensive upgrades over the original, combining enhanced design, stronger performance, and a faster mechanism for keyless entry