BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

"SmartLED Controller" - ESP+FastLED+Blynk (Video)

I made, what I call, a smart shelf!

Hardware:
ESP8266 NodeMCU Dev Board
10x WS2812 Smart LEDs (FastLED Library)
Blynk Local Server
5V 1.2A Power Supply

Here is a little video I made just now…

Latest code: https://github.com/jaminNZx/ESP8266-WS28xx-Blynk/

14 Likes

You can disable “on release” feature of sliders, and hopefully get smooth color updates :wink:

1 Like

Yup you can actually see that being used on the saturation slider… the issue im facing is that it overloads the poor little ESP and causes it to reset … go slow enough and it can handle 50 odd requests in a split second but after that is goes offline.

I chopped that part from the video lol

Here is the code if you can see anywhere to improve it? Im kinda just learning/googling my way through it.

1 Like

use magic code:

2 Likes

Thanks for that Dave1829!

1 Like

I tried using your code but get a bunch of comply errors on the ESP… did your code complie correctly?

Yup it compiles every time no problem.
Im using Adafruit HUZZAH board drivers.

What compile errors is it throwing?

I’ve just updated my other post with some new code.
Added alert mode, off button and other two colours.

hmm i just tried your fresh code above and still cant compile

error below

Arduino: 1.6.8 (Mac OS X), Board: “Adafruit HUZZAH ESP8266, 80 MHz, 115200, 4M (3M SPIFFS)”

Build options changed, rebuilding all
In file included from /Users/fsolanes/Documents/Arduino/newpost/newpost.ino:26:0:
/Users/fsolanes/Documents/Arduino/libraries/FastLED-master/FastLED.h:17:21: note: #pragma message: FastLED version 3.001.001

pragma message “FastLED version 3.001.001”

                 ^

In file included from /Users/fsolanes/Documents/Arduino/libraries/FastLED-master/FastLED.h:65:0,
from /Users/fsolanes/Documents/Arduino/newpost/newpost.ino:26:
/Users/fsolanes/Documents/Arduino/libraries/FastLED-master/fastspi.h:110:23: note: #pragma message: No hardware SPI pins defined. All SPI access will default to bitbanged output

pragma message “No hardware SPI pins defined. All SPI access will default to bitbanged output”

                   ^

In file included from /Users/fsolanes/Documents/Arduino/newpost/newpost.ino:26:0:
/Users/fsolanes/Documents/Arduino/libraries/FastLED-master/FastLED.h: In static member function ‘static CLEDController& CFastLED::addLeds(CRGB*, int, int)’:
/Users/fsolanes/Documents/Arduino/libraries/FastLED-master/FastLED.h:404:14: error: ‘WS2813_PORTA’ was not declared in this scope
case WS2813_PORTA: return addLeds(new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER, 0, false, 300>(), data, nLedsOrOffset, nLedsIfOffset);
^
exit status 1
Error compiling for board Adafruit HUZZAH ESP8266.

This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.

Sounds like you’re using a broken library… are you able to set up a simple FastLED demo example?

I’m using FastLED v3.1 too.

Update your arduino compiler to 1.6.9 (you’re on 1.6.8)

Try

#include "FastLED.h" 

instead of

#include <FastLED.h>

I remember having issues getting the example to run… had something to do with the way you define the library.

Try this:

#include "FastLED.h"
#define NUM_LEDS 60
#define PIN 6
CRGB leds[NUM_LEDS];
	void setup() { FastLED.addLeds<NEOPIXEL, PIN>(leds, NUM_LEDS); }
	void loop() {
		leds[0] = CRGB::White; FastLED.show(); delay(30);
		leds[0] = CRGB::Black; FastLED.show(); delay(30);
	}

Here is the compile output from my end. Similar SPI/Bitbanging issue but its just a warning. It wil works fine.

In file included from D:\_UserData\My Documents\Arduino\ESP_Shelf_Blynk_FullOptions\ESP_Shelf_Blynk_FullOptions.ino:4:0:

D:\_UserData\My Documents\Arduino\libraries\FastLED-master/FastLED.h:17:21: note: #pragma message: FastLED version 3.001.001

 #    pragma message "FastLED version 3.001.001"

                     ^

In file included from D:\_UserData\My Documents\Arduino\libraries\FastLED-master/FastLED.h:65:0,

                 from D:\_UserData\My Documents\Arduino\ESP_Shelf_Blynk_FullOptions\ESP_Shelf_Blynk_FullOptions.ino:4:

D:\_UserData\My Documents\Arduino\libraries\FastLED-master/fastspi.h:110:23: note: #pragma message: No hardware SPI pins defined.  All SPI access will default to bitbanged output

 #      pragma message "No hardware SPI pins defined.  All SPI access will default to bitbanged output"

                       ^


Sketch uses 237,297 bytes (22%) of program storage space. Maximum is 1,044,464 bytes.
Global variables use 34,164 bytes (41%) of dynamic memory, leaving 47,756 bytes for local variables. Maximum is 81,920 bytes.
Uploading 241440 bytes from to flash at 0x00000000
............................................................................................................................................................................................................................................

I decided to create bunch of modular slave units that I can place around my house. Controlled by the same interface and code (albeit slightly modified for less LEDs) as previous posts :slight_smile:







1 Like

What logic level shifter did you use for your LED data signal? I’m trying something similar, but I’m having difficulty getting any sort of response out of my LEDs with a Wemos D1 R2 (3.3V DO).

  • I’ve verified the LEDs are performing correctly with an UNO.
  • I’ve verified D5 on the Wemos is the correct pin and matches with my code.
  • I’ve put a 3.3v to 5v bi-directional shifter in and verified the LED still works on D5.

But, whenever I un-wire the LED and replace it with the WS2812B strip, I don’t even get a peep out of the LEDs. Also just for experimentation I tried without a resistor in the data signal line and also feeding the leds directly with the 3.3v signal, but neither worked.

Here is the code I’m trying to run:

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <FastLED.h>
#include <SimpleTimer.h>

// How many leds in your strip?
#define NUM_LEDS 70
#define DATA_PIN 14

CRGB leds[NUM_LEDS];

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).

char auth[] = "XXXXXXXXXX";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "XXXXXXXXXX";
char pass[] = "XXXXXXXXXX";

int varonoff;
int i = 0;

SimpleTimer timer;

void setup()
{
  //Serial.begin(9600);
  FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
  Blynk.begin(auth, ssid, pass);

  timer.setInterval(50L, chase);
  timer.setInterval(1000L,senduptime);
  
}

void loop()
{
  Blynk.run();
    timer.run(); // Initiates SimpleTimer
}





  void chase() {



      leds[i - 3] = CHSV( 224, 255, 0);
      leds[i - 2] = CHSV( 224, 255, 50);
      leds[i - 1] = CHSV( 224, 255, 150);
      leds[i] = CHSV( 224, 255, 255);
      leds[i + 1] = CHSV( 224, 255, 150);
      leds[i + 2] = CHSV( 224, 255, 50);
      leds[i + 3] = CHSV( 224, 255, 0);
      FastLED.show();
      i++;
      if (i == 70){
        i = 0;
      }


    }

void senduptime(){

    Blynk.virtualWrite(V20, millis() / 1000);
  
}

This code works on the UNO (modified of course to remove all of the blynk stuff) and I know the code is running on the Wemos, because the uptime is updating correctly on the app.

Any help is appreciated!

Edit: updated code. See below.

Try changing #define DATA_PIN 5 to #define DATA_PIN 14 if you are connected to D5 http://www.wemos.cc/Products/d1_r2.html

1 Like

Wow! Okay so it works to an extent. I am getting LEDS to light and do what they are supposed to do most of the time. Only problem now is that the wemos disconnects (I’m assuming resets but haven’t check with serial monitor yet) from the app every 2-3 seconds causing long pauses in the LED “animation” I slightly updated the code and to avoid having another long post, I have edited the code in the previous post to reflect the changes.

Also, why did controlling an individual LED from D5 in the app work? Is it because the app re-maps for you or something like that?

Thanks again!

edit: I added some stuff to Serial.print and discovered it didn’t seem to like when “i +1” or +2 or +3 got bigger than 70 (number of leds) I edited the code so “i” never tried to write to an LED bigger than 70. Strangely the uno didn’t have a problem with this.

Time to add back in some of the other code to see if I can get this where I want it to be!

@Jon_Moore to be honest I don’t really know how the pin definitions work but this is what works for us:

  1. In the IDE you obviously need to set the correct board.
  2. In the app set your device as an ESP8266 not as a WeMos
  3. In the sketch use regular ESP GPIO numbers.

This way your sketch will work on regular ESP’s and the WeMos.

Hook up Serial Monitor and debug with:

#define BLYNK_DEBUG // Optional, this enables lots of prints
#define BLYNK_PRINT Serial

Comment out the first line once you have fixed the problem as it can make your hardware run 10 times slower than it does without debug.

Try 50L at 500L and see if it works as expected. If it does keep reducing the 500L and retest. Can be done with a slider if you don’t want to keep changing your sketch.

Okay it still seems to stutter every once in a while but I had to modify the code again. it also didn’t like writing to the led “i-1” when “i” was 0 AND “varhue” was less than 105… It was very repeatable and it would set “i” to a value of several million immediately after this step…

Strangely enough it didn’t mind -2 or -3…

I can now control the hue with a slider and it works after another code modification!It does still stutter occasionally, but I think it’s workable for my project.

Thanks for your help Costas! If I need any further assistance (or want to show off my project) I’ll start a new post. Blynk+Arduino+Wemos is so much fun!

Mine also stutters a bit during the demo modes… I think its just a limitation of the hardware.

Good on your for getting it working! Feel free to use my code :grinning:

@Jon_Moore and @Jamin how long does the light sequence last? I’m just wondering if you are missing a Blynk heartbeat.

Youre right! It will be that.

Check out my code… all the sequences are FOR loops… which I take it is blocking the heartbeat.

@Jamin for sure your code in post 3 of this thread is blocking and not suited to internet control via an ESP (e.g. Blynk).

When your code does work i.e. before you get blacklisted for flooding, what does V5 show on the Terminal for the number of updates per second?