FastLED + ESP8266 Web Server

So I managed to get the Fastled working with WiFi, it didn’t go easy and I had to try and find a lot of answers, so that’s the reason why I post my steps taking to make it work.

First things first, here you will find the complete package from Jason Coon

I use the Wemos D2 but also the Wemosmini will do great, didn’t try other ESP8266 boards. Running the latest Arduino IDE (1.8.16( Windows Store 1.8.51.0)) but here is one of the major things, I used the ESP8266 2.6.0 in the board manager, it wouldn’t work with the latest version right now 3.0.2. Some other versions work also but this did it for me.

When you got all the stuff you need, included the WiFiManager library, this is going to help you setup your device to connect to your router and set your credentials. Also I found the colors red and green just where the opposite so I had to change the value from RGB to GRB, I’m using the WS2812 leds but there are others you can use with it as well. So, this is my setup for a ringlight.


/*
   ESP8266 FastLED WebServer: https://github.com/jasoncoon/esp8266-fastled-webserver
   Copyright (C) 2015-2018 Jason Coon

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

//#define FASTLED_ALLOW_INTERRUPTS 1
//#define INTERRUPT_THRESHOLD 1
#define FASTLED_INTERRUPT_RETRY_COUNT 0

#include <FastLED.h>
FASTLED_USING_NAMESPACE

extern "C" {
#include "user_interface.h"
}

#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPUpdateServer.h>
#include <ESP8266HTTPClient.h>
//#include <WebSocketsServer.h>
#include <FS.h>
#include <EEPROM.h>
//#include <IRremoteESP8266.h>
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager/tree/development
#include "GradientPalettes.h"

#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))

#include "Field.h"

//#define RECV_PIN D4
//IRrecv irReceiver(RECV_PIN);

//#include "Commands.h"

WiFiManager wifiManager;
ESP8266WebServer webServer(80);
//WebSocketsServer webSocketsServer = WebSocketsServer(81);
ESP8266HTTPUpdateServer httpUpdateServer;

#include "FSBrowser.h"

#define DATA_PIN      D5
#define LED_TYPE      WS2812
#define COLOR_ORDER   GRB
#define NUM_LEDS      45

#define MILLI_AMPS         2000 // IMPORTANT: set the max milli-Amps of your power supply (4A = 4000mA)
#define FRAMES_PER_SECOND  120  // here you can control the speed. With the Access Point / Web Server the animations run a bit slower.

If you have this set up you need to upload it in 2 different ways, one is just the regular way to upload all the code to your Arduino, the second is the ESP8266 Sketch Data Upload.

After this everything should be there, it creates a AP (access point) showing the name you have giving it on rule 272 in

nameString = "Led_Ring_Light-" + macID;

Check the IP of the webserver (you can do this by open the serial monitor) and connect with the device you connected to the AP. You now will be showing a page to set your SSID and password, it will popup all the SSID’s in your neighbourhood, just select yours obviously and set your password, if it connect you go back to your normal AP (your router that is) and now you can look it up by the IP your router have giving it, maybe you should check your router to find what IP this has gotten and give it a static IP so you don’t have to check your router every time.

About connecting everything.

Depends on what setup you use, if you use a ring like mine you can power it from your board pretty much (no guarantees) by USB… Here are the three possible setups that are easy to use.

Just powered by USB
Above the USB powered setup.
Wemos powered by USB and the strip connected to a external power source. Be aware to connect grounds.
Above the USB and external powered setup.
This will be working as a standalone setup with a power supply to power both of them.
Above the standalone powered setup using the 5V power supply.

So that’s pretty much it, but to answer on some questions about external power supply. You will need this to get it working standalone or if the power it needs exceeds the max it can draw from your Arduino or any other micro controller. A Wemos can power up to 500mAh. So a led on the strip can draw on max that means “white” a 60mAh if the brightness is set to max (255), so if you have a strip like I do, with 66 leds a meter, and using almost 2 meters would mean I have like 132 leds.

132 x 60 = 7920

It means you need a power supply that can get you like 8 Amps, you can’t draw that much power of your Microcontroller.

! NOTE: The measurements about how much power a led draws are obviously different, some say it just pulls 55mAh on max others claim it’s even less, I suggest you go with the 60mAh, you will be save and you wont get your microcontroller or power supply fried. The 5050 leds that are used on the WS2812 are drawing 20mAh per channel, so on max it would be 60mAh per led.

I use for my led ring with 45 leds a general USB power supply with an output of 5Volts @ 2.14Amp, I never use all white at max so this have never been a problem.

Hope this will help you if you didn’t get it to work.

Keep flashing those leds and add some color to your life (or room) 🙂

Amanda

Leave a Comment

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