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.

Signal

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.

Calibration

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

CRGB leds[NUM_LEDS];

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

      // 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);
   FastLED.show();
   delay(1000);
}

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:

ARDUINO IDE: LED Test
#include 
#define NUM_LEDS 410
#define DATA_PIN 5
#define BRIGHTNESS 50

CRGB leds[NUM_LEDS];
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);
        FastLED.clear();
        for(int led = 0; led < numLedsToLight; led++) { 
            leds[led] = CRGB::White; //change colour here
        }
        FastLED.show();
    }

Conclusion

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.

PayPal

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

Patreon

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

image/svg+xml

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

client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image

Learn NodeRED

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

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

Best Automation Projects

Tuya SDK for beginners: Intro to Tuya Cloud API

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

NEST your old thermostat under $5

0
Nest-ing up your older thermostat under $5

Nora – Google Assistant in NodeRED

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

DIY Smart Washing Machine – for about 15 bucks!

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

Sonoff Zigbee Bridge – review

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

Smart Home

We’ve seen this before: SwitchBot K10+ PRO

0
This is an odd one. Building on the success of SwitchBot K10+ they released SwitchBot K10+ PRO - but is the experience actually better?

Is this the smart panel we have waited for?

0
ITEAD has released a new smart panel: Sonoff NSPanel Pro 120 - have they learned the lesson from the terrible launch of the original Pro? Let's see what's new.

Aqara FP1E detects motionless humans

0
This isn't exactly a new device, it's an interaction of the original Aqara presence sensor. Aqara FP1E brings Matter, ZigBee and new triggers to your smart home

SwitchBot S10: cleaning re-imagined!

0
SwitchBot S10 promises unattended vacuuming and mopping so you can focus on things you love and care for. Does it deliver?

Sonoff for households and gardens

0
ITEAD released two ZigBee devices to manage water in your household and gardens. Now you can monitor the flow and dispense water with Sonoff SWV and prevent water damage using the Sonoff Water Leak sensor with a twist.