This is a simple server program for a Raspberry Pi that hosts a web page to select different colors on it.
Try out a demo here
Three different modes are currently available.
- The one color mode allows you to select a simple color.
- The fade mode can be used to smoothly transition inbetween several selected colors.
- The changing colors mode switches between all selected colors.
Download the server git clone https://github.com/mec-kon/led-strip-server.git
Then navigate into the server folder with cd led-strip-server
.
Initialize the submodules with git submodule update --init
To use the server, you must change the ip address of the server.
You can do this by typing nano static/src/deviceConfig.json
.
The easiest way to build the program is with CMake.
First you need to install all required dependencies.
You can do this with sudo apt-get install cmake wiringpi build-essential
.
You will also need to install libmosquittopp if you want to use mqtt in this project.
You can do this with sudo apt-get install libmosquittopp-dev
.
Then, all you have to do is create a new folder with mkdir build
in the current project folder, change to this folder with cd build
and create a makefile
with cmake ..
or cmake .. -DUSE_MQTT=OFF
if you don't want to use mqtt .
Then you can create the executables by simply typing make
Now install the server with sudo make install
.
To start the server automatically when booting, you can use crontab.
But first you have to activate the automatic login.
For this you have to open the settings with sudo raspi-config
.
Navigate to "Boot Options" and then to "Desktop/CLI". Select "Console Autologin" and then "Finish".
Restart the Raspberry Pi.
Next type crontab -e
.
In the window that opens, add the line "@reboot /usr/local/bin/led-strip-server".
To receive commands from Openhab, the following files must be added or modified in "/etc/openhab2/":
- create "color.items" in "/etc/openhab2/items"
- modify "default.sitemap" in "/etc/openhab2/sitemaps"
- create "color.rules" in "/etc/openhab2/rules"
The mentioned files can be found here
Pull requests are always welcome !