/ws2812-nodemcu-rest-service

JSON REST Service interfacing with NodeMCU and WS2812

Primary LanguageLuaGNU General Public License v2.0GPL-2.0

...facing exactly this setup.

Based on https://github.com/marcoskirsch/nodemcu-httpserver

Find out more about the HTTP-Server itself and File uploading processes

Features

  • [POST] Supports RGB Stripes with WS2812(b) LED chip (up to 144 led hard set)
  • [GET] Reset leds to low brightness (current testing purpose only)

Prerequisites

Firmware

Make sure modules are built in. For convenience i added a working firmware file built by the NodeMCU build service and includes the following modules bit cjson file gpio http net node tmr uart wifi ws2812

Uploader-Software

Currently nodemcu-uploader as mentioned on nodemcu-httpserver project

This repository is prepared to use this as a submodule. To install just type git submodule update --init

Getting Started

  1. Upload all files
  • erase your flash with esptool
  • upload flash using make upload_all
  • restart node
  1. Setup Wifi
  • Connect to ESP-* Wifi. Password is same as AP.
  • Setup your wifi settings curl -H "Content-Type: application/json" -X POST -d '{"ssid":"yourssid", "password":"yourpassword"}' http://192.168.111.1:80/setup.lua
  • restart node
  • get by asking your wifi system (or using console)
  1. LED Settings
  • numleds = Number of leds in your row (may be multiple stripes)
  • channels = Number of channels, e.g. 3 for RGB, 4 for RGBW
  • Configure the led settings curl -H "Content-Type: application/json" -X POST -d '{"numleds":144, "channels":3}' http://<yourip>:80/settings.lua

If anything gets wrong or does not work: Restart & Re-Flash Firmware and start over

Test

This testing should work always - even on ESP* - Access Point connection. would be 192.168.111.1 then.

curl -H "Content-Type: application/json" -X POST -d '{"1":[23, 233, 112],"25":[223, 84, 122]}' http://<yourip>:80/leds.lua

Animations

Few animations are supported, some of them need data, example call:

curl -H "Content-Type: application/json" -X POST -d '{"name":"fill", "data":[42,42,42]}' http://<yourip>:80/animation.lua
  • buzzer
  • doublebuzzer
  • fill - data = [r,g,b]

Currently not working/in progress/ideas

  • RGBW Stripes
  • set all LEDs at once
  • make Buffer configurable
  • add Animations