R-Pi Relay + RGB Controller
Raspberry Pi Relay & APA102 LED controller allows control & switching of APA102 addressable LED strips (and LED driver) using a web GUI. Motor controller functionality is also built-in to control hard-wired home automation type blind / projector screen motors. Ideal for use in home cinema applications. Unlike regular "dumb" RGB strips, addressable strips have independently controlled LEDs, allowing for the creation of light effects & sequences. Project details available on GitHub here: https://github.com/plasmadancom/Raspberry-Pi-Relay-APA102-LED-Controller
Step 1: Raspberry Pi Relay & APA102 LED Controller
Raspberry Pi Relay & APA102 LED Controller
Raspberry Pi Relay & APA102 LED controller allows control & switching of APA102 addressable LED strips (and LED driver) using a web GUI. Motor controller functionality is also built-in to control hard-wired home automation type blind / projector screen motors. Ideal for use in home cinema applications. Unlike regular "dumb" RGB strips, addressable strips have independently controlled LEDs, allowing for the creation of light effects & sequences.
Features
- APA102 LED control
- 2x changeover relay control
- 2x mains AC input detection
- Motorised blind / projector screen control
- 2x TTL inputs for external buttons
Motivation
This project was created for use in my own home cinema build. I wanted a single-room home automation solution that would offer addressable RGB control, with the ability to directly switch a mains AC powered LED driver. Additional relay channels where added to the prototype to allow other circuits to be switched using the controller, such as spotlights. The motorised blind control relays were added into the design during my home cinema build.
Home cinema build log: https://www.avforums.com/threads/ongoing-plasmadans-living-room-cinema-office-build.1992617/
Responsive Web GUI
The GUI includes controls for the changeover relay channels, motorised blind / projector screen, a full RGB color picker for the APA102 LEDs and a preset control to cycle built-in light modes / effects. There is also the ability to reboot the Raspberry Pi directly from the GUI, making development & testing easier for your application.
Built on bootstrap 3; the GUI is fully responsive and adapts to any screen size / orientation.
App Features
As well as support for mobile devices, the GUI includes modern manifest data to allow it to work more like a native app. This means when you save the GUI to the home-screen it will load & function without an address-bar, just like an app.
Chrome Extension
The specially created Chrome extension makes the web GUI even easier to use on desktop, allowing for GUI control without the need to leave the current web page. The Chrome extension also provides the ability to map keyboard shortcuts to each function of the web GUI, including toggle on / off, LED preset & blind control.
https://chrome.google.com/webstore/detail/apa102-led-controller/jnmjhaaahpdapgcddlgaldjhapmoapje
Prerequisites
Raspberry Pi with Raspian: https://www.raspberrypi.org/downloads/raspbian/
I recommend a clean Raspian install before proceeding.
Dependencies
APA102 LEDs require the Python port of the Adafruit DotStar library to function. This is included in this repo for completeness.
https://github.com/adafruit/Adafruit_DotStar_Pi
Build Your Own!
The hardware for this controller is quite simple, all the components are readily available. If you decide to build one for yourself, I have provided the necessary Gerber files for the PCB. These can either be sent to a PCB manufacturer like PCBway, or you can etch the board yourself (see included transfer pdf). The PCB design is single-sided to make it easier to re-create yourself. The PCB was designed to fit into a small case (CAMDENBOSS 7200-269C). If you require additional inputs / outputs, or want to make any other changes; you may want to create your own PCB instead.
Parts list: https://goo.gl/5SdG7h
Alternatively you can buy a PCB or complete controller from me. Contact me on AV Forums here.
Just The Basics
If all you want is LED control via Raspberry Pi, you can do this without a PCB. The circuit diagram below shows how to connect APA102 LEDs to a Raspberry Pi using a 74AHCT125 - Quad Level-Shifter. You will still need an LED driver to power the LEDs. The LEDs must share a common-ground with the Raspberry Pi & LED driver.
Stackable
The PCB can easily be stacked using standoffs. The CAMDENBOSS 7200-269C enclosure is tall enough to accommodate two stacked boards. So if you require more channels; this is a simple solution.
Raspberry Pi Compatibility
- All except the original Model B (rev. 1) - Although with some changes it can be made to work.
The PCB design uses a 26-way header (same as the Raspberry Pi model B). A 26-way to 40-way ribbon cable will be needed to work with Raspberry Pi B+ and above.
Wiring
The controller is designed to work with 4-wire type addressable LED strips; such as APA102 (AKA Adafruit DotStars) or WS2801. Everything else on the controller is pretty-much universal in terms of wiring options. I have provided an example wiring diagram:
In this example, the LED driver and halogen lighting circuits are linked to the changeover relay channels. This allows for standard 2-way / intermediate (3-way if you're outside the UK) light switches to be used in conjunction with the controller. This means that if the controller went offline for whatever reason, your lights will still work!
Notice in the example that the switched-line is looped back into the AC detect circuits. This is to allow the Raspberry Pi to sense when the lights / LED driver are powered, regardless of relay / switch positions. If you don't require 2-way control you can disable this in the config.
Installation
sudo bash
Update Raspian
apt-get update
apt-get upgrade
Install Apache components
apt-get install apache2 php5 libapache2-mod-php5
Install WiringPi
apt-get install git-core -y
Get repo
git clone git://git.drogon.net/wiringPi
Build WiringPi
cd wiringPi
git pull origin
./build
Install python-dev & pip
apt-get install python-dev python-pip -y
Install WiringPi
pip install wiringpi2
Enable SPI
Needed for RGB LEDs to work.
raspi-config
Scroll to "Advanced Options", "SPI", set to enabled.
Clone Repo Contents
cd /var/www/html
Empty default Apache files
rm -rf *
Clone repo
git clone https://github.com/plasmadancom/Raspberry-Pi-Relay-APA102-LED-Controller .
Be sure to set file permissions to 755 in the web directory.
chmod -R 755 /var/www
Apache requires sudo permission to use WiringPi. Note: If your Raspberry Pi is on a shared network you may want to find a more secure method than this.
echo "www-data ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
To make the Python scripts run at startup, edit rc.local:
nano /etc/rc.local
Add before exit 0
python /var/www/html/python/motor.py&
python /var/www/html/python/preset.py&
The scripts are independent from each other to allow you to just use what you need.
Optional: install vsftpd for easier file editing
apt-get install vsftpd -y
Change user for vsftpd
chown -R pi /var/www
Edit vsftpd.conf
nano /etc/vsftpd.conf
Uncomment the following line:
write_enable=YES
Add the following line:
force_dot_files=YES
Restart vsftpd
service vsftpd restart
Config
There are lots of user customisable options in the config file :/python/config.py
Edit the config options as required.
License
MIT © Dan Jones - PlasmaDan.com
- Comments(0)
- Likes(2)