-->
Page 1 of 4

Working WS2812 library for ESP Arduino IDE.

PostPosted: Mon Apr 27, 2015 10:45 am
by andrew melvin
Working WS2812 library for ESP Arduino IDE.

Hacked together from the ADAFRUIT neopixel lib, and Markus's code he posted on this forum.

All the adafruit commands work, as expected.

My only advice is to re-write all the for loops of the functions and use timers instead. I've it working quite nicely, whilst running MQTT, webserver, WiFi...

remember to use a big power supply, my 60 LEDs in 1m pulls 3A when white.
Any feedback welcome, I will post on github at some point. It will need tidying up.
Works at 80 and 160Mhz
Sometimes the first LED is a bit tricky.. not sure why.

If anyone can offer me some advice for how to change the number of LEDs after compile time, id appreciate it. you can issue a new object definition, and when you query the led number it returns the new amount, but then on the next for loop it goes back. even when changed the library ignores it. Would be good so you can configure your ws2812s in the web browser and set the length without having to recompile....

cheers

Re: Working WS2812 library for ESP Arduino IDE.

PostPosted: Tue Apr 28, 2015 1:45 am
by uhrheber
andrew melvin wrote:Working WS2812 library for ESP Arduino IDE.
Sometimes the first LED is a bit tricky.. not sure why.


That's a well known phenomenon.
The WS2812 are connected in a chain, where the output of one chip is connected to the input of the next.
Meaning, they all see perfect signal levels, except the first one, that sees the output level of the microcontroller.
As the WS2812 are 5V, and the ESp8266 is 3.3V, it's explainable why there are some problems. Also, the signal travels along a wire in most cases, and the impedance is seldomly a perfect match.

Re: Working WS2812 library for ESP Arduino IDE.

PostPosted: Tue Apr 28, 2015 7:37 am
by glynnsimon
Hi,
This looks great and I'm looking forward to getting it up and running. That said, I've hit a compile hurdle with your example referencing the ESP.h include.

Esp_WS2812.h:5:17: fatal error: ESP.h: No such file or directory

That module seems to come from the https://github.com/esp8266/Arduino repo if building from source but isn't included in the prebuilt binary under (assuming this is the correct location for it) arduino-1.6.1/hardware/esp8266com/esp8266/cores/esp8266/ (at least for the Linux variant)

I'm very new to this so my apologies as I'm almost certain there's a simple fix for this.

Any thoughts?

Re: Working WS2812 library for ESP Arduino IDE.

PostPosted: Wed Apr 29, 2015 3:06 pm
by andrew melvin
hi,

yes. you might well be able to comment it out. mine still compiles without that line.
Open the .h file in the zip, if you installed it using the IDE it will be located in the library folder of your arduino folder.
add // before it. I think you can also comment out stdlib. Should look like this

//#include <stdlib.h>
#include <Arduino.h>
//#include <ESP.h>

Let me know how you get on.

A