Skip to content

App that turns your Raspberry Pi into a controller for Ws2812b LED strips

Notifications You must be signed in to change notification settings

BounceU/pi_led_server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Ws2812b LED strip control application for Raspberry Pi

This project turns a Raspberry Pi into a controller for a Ws2812b LED strip, with an ExpressJS app being used for input and a rust backend driving the LEDs. I made this because I had these LEDs spare from a different project, and wanted to use them to light my room.

Description Current simple UI for the website, using the iro.js color picker.

How to run

You will need to run both the Rust and Javascript programs.

Rust

On your Raspberry Pi, you will need to install rust and get the llvm-dev and libclang-dev packages. If building with cargo says you need any more dependencies, get those too.

Note: You will need to do additional steps and change some system files based on which Raspberry Pi model and what pins you are using. Read the Limitations section of the rpi_ws281x readme. Your user will probably also need to be in the gpio and spi groups.

Javascript

To run the ExpressJS app, you will need to install node. Then, in the led_js_server folder you can run npm install to download all the required packages. Make sure to create a .env file in this folder as well, based on the .env.example file there. Once you've done that, you can add logins to the app by running

node admin.js add <username> <password>

Then, run

node server.js

and your app will be listening on whatever port you set in the .env file.

Physical Components and Wiring

I am using a Raspberry Pi 4b and BTF-Lighting FCOB COB WS2812B IC RGB LED DC 5v Strip, as well as a 5V 30A LED Strip powersupply. This is supplying power to both my Raspberry Pi and the LED strip.

I've hooked up the power supply directly to the LED strip, and am taking 5v and ground from the LED strip to power the Raspberry Pi. The data line for the LEDs are connected to Raspberry Pi pin 19 (GPIO 10). You can use other pins as well, but consult the rpi_ws281x repo on what you might need to do to get them working. You will also need to change this in the Rust code.

Description

Other things you can do

Run on startup

I set up the Rust and Javascript programs as systemd daemons, so they run automatically when the Pi powers on. Both the Rust and Javascript components will try to reconnect to each other should a connection fail, so the order they start in does not matter.

Cloudflared tunnel

I set up a cloudlfared tunnel on my Pi so that I can access it anywhere through my domain. Otherwise, you'd only be able to control the LEDs while on the same network by knowing its hostname and port (i.e. raspberrypi.local:8000).

Other things I need to do

  • Make an easy install script
    • Install dependencies, Rust, Node, build, and create systemd daemons
    • Also make an uninstall script
  • Add more animations

About

App that turns your Raspberry Pi into a controller for Ws2812b LED strips

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published