NeoPixel
This library enables the Adafruit NeoPixel control from a Node.js script through a TCP connection.
The server side has to be installed on an ESP8266/Arduino (or compatible) board.
The client side can work on any machine that runs Node.js.
Requirements
- ESP8266 or compatible board, available here https://amzn.to/2Vpm3C8#esp8266
- A NeoPixel strip led, available here https://amzn.to/2AuuZNQ#neopixel-strip-led
- A power supply that supports 5V and 18watt (depends on number of pixels), available here https://amzn.to/2SFMTo1#power-supply-5v-18w
- A jack for DC connections, available here https://amzn.to/2RaNGQT#jack-dc
Setup
-
Upload the firmware on the ESP8266.
Upload the file firmware/neopixel/neopixel.ino into your ESP8266.
To do this you can use the Board Manager available in the Arduino software.
Follow this instructions https://arduino-esp8266.readthedocs.io/en/latest/installing.html -
Wire the strip with the ESP8266.
Connect the Strip Led and the ESP8266 to a power supply and the DATAIN pin with the D1 pin.
More details are available here https://learn.adafruit.com/adafruit-neopixel-uberguide/basic-connections -
Connect your ESP8266 on your local network.
Turn on your ESP8266. You should see an Access Point that hasneopixel
as SSID name.
Connect on it, then you should see a captive portal that asks your Wi-Fi credentials.
Provide it and then try to ping on your local networkneopixel.local
. You should be able to see this device connected and announced through Bonjour.
More details about the Wi-Fi configuration are available here https://github.com/tzapu/WiFiManager#how-it-works.
More details about the service discovery are available here https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266mDNS#requirements.
Example
const NeoPixel = ; const SERVER = processenv'SERVER' || 'tcp://neopixel.local:800'const PAUSE = || 1000 const neopixel = ;async { try let pixels = await neopixel console let pixel = 0 while 1 pixel = ++pixel % neopixelpixels const latency = await neopixel console await NeoPixel catch e console process }
Reference
new NeoPixel()
const NeoPixel = const neopixel =
connect(tcpUri)
Connects client with the board and returns number of configured pixels.
const latency pixels = await neopixel
setPixels(arrayOfColors, reset=false)
Sets pixel colors. If reset, any other pixel is turned off.
const latency = await neopixel // shorthand versionconst latency = await neopixel
fill(color)
Sets every pixel with the same color.
const latency = await neopixel // shorthand versionconst latency = await neopixel
off()
Turn of every pixel.
const latency = await neopixel
Changelog
- 0.x - Beta version
- 1.0 - First official version
- 1.1 - Migrates to gh-workflows; Upgrades deps; Deprecated Node 8
Contributors
- chrvadala (author)