The use of the ESP8266 in the world of IoT

User avatar
By totalconfusion
#42796 Hey guys, first post so go easy on me.

I'm looking to control some LED strip lighting from my Android via Blynk.
I'm comfortable flashing the ESP with the code below.

My question is regarding the hardware and wiring. Is GPIO2 the best choice for the LED data line? Do I need to put a resistor or cap anywhere? Can I just run GPIO2 strait in to my LED strip?

I realise I'll need a logic level converter from the ESP (3.3v) GPIO2 pin to the DIN on the WS2812 (5v) - This is not in the diagram.

Hardware set up:
Image

Thanks!

Code: Select all#include <Adafruit_NeoPixel.h>
#include <SPI.h>
#include <BlynkSimpleEsp8266.h>
#include <ESP8266WiFi.h>

#define PIN 4 // GPIO pin  <-- Pin 4 is actually the broken out pin marked GPIO2
#define NUMPIXELS 144 // Number of pixels in strip
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = “BLYNKAUTHCODE”;

void setup()
{
Serial.begin(9600);
Blynk.begin(auth, “SSID”, “PASSWORD”);
pixels.begin();
}
BLYNK_WRITE(V1) // Widget WRITEs to Virtual Pin V1
{

int R = param[0].asInt();
int G = param[1].asInt();
int B = param[2].asInt();
Serial.println(R);
Serial.println(G);
Serial.println(B);
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(R,G,B)); // Moderately bright green color.

pixels.show(); // This sends the updated pixel color to the hardware.

}
}

void loop()
{
Blynk.run();
}


edit: changed diagram and pin number in code.
User avatar
By bbx10node
#43922 I recommend using NeoPixelBus instead of the Adafruit library because NeoPixelBus is designed to work well on the ESP8266. I used the UART method which requires using GPIO2 for DIN. I followed Adafruit's best practices for NeoPixels which includes a large cap and series resistor to drive 128 ws281x LEDs.

https://learn.adafruit.com/adafruit-neo ... -practices

I have not used Blynk.
User avatar
By Barnabybear
#43938 Hi, from my experience GPIO 2 will reliably send data to WS2812Bs without any level changer. The spec on the WS2812Bs is 0.7 Vcc for a data high which at 5V should be 3.5V but it was stable at 3.3V.
You need 10K pullups on GPIO 0 & 2. CH_PD & REST both need to be pulled up to Vcc ether directly or via a pullup resistor if you want to be able to use REST for flashing (I connect directly to Vcc and power off and back on to flash).