zachgoldstein / heavy-meta-lights

A light control system for heavy meta, an art car headed to burning man

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Heavy Meta Lights

What is this?

A light control system for heavy meta, an art car headed to burning man.

Core goals

  • Open up new ways to interact with light on the art car
  • Integrate addtional inputs to control lights (audio)
  • Build a better interface to control multiple strips at once

Usage

  • Start the backend
export FLASK_APP=/home/pi/art-car/src/api.py
pipenv shell
flask run --host=0.0.0.0

You should see some ouput saying "* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)"

How this works (or at least is intended to)

  • A bunch of lifx light strips are distributed around the art car.
    • Each of the strips connects to a local wifi network.
  • A device (like a raspi) capable of running python is connected to the same wifi network
    • This device runs a python process that uses lifx's client library to connect to and drive the light strips
    • The same device exposes some sort of simplistic interface to the local network (be it API or UI) for control over the process driving the lights

Deploying to raspi

Note! On a new raspberry pi you'll probably need to make sure the OS is installed and ssh is enabled

  • Find the raspi IP
    • run ping raspberrypi.local
    • alternatively nmap -sn 192.168.1.0/24
  • ssh into the raspi and install all dependencies (order is important):
ssh pi@<raspi ip>
sudo apt-get install libasound-dev portaudio19-dev python3-pyaudio python3-numpy
python3 -m pip install --user pipenv
sudo apt install libatlas3-base
pipenv lock --clear
pipenv install numpy
pipenv shell
pip install -U MarkupSafe
mkdir ./art-car
cd ./art-car
pipenv update && pipenv install
  • From the host machine, copy over all files scp -rp ./* pi@<raspi ip>:/home/pi/art-car
  • Back on the raspi, copy over the systemd service so the app will start when the raspi starts up:
sudo cp /home/pi/art-car/art-car.service /lib/systemd/system/art-car.service
sudo chmod 644 /lib/systemd/system/art-car.service
sudo chmod 777 /home/pi/art-car/run.sh 
sudo systemctl daemon-reload
sudo systemctl enable art-car.service
sudo reboot

You should now see lights going crazy when the raspberry pi starts. To control the service, on the raspberry pi, use systemd: To stop:

sudo systemctl stop art-car.service

To restart:

sudo systemctl restart art-car.service

To view the logs, use journalctl:

journalctl -u art-car.service

How can I get involved?

  • Take a look at the issues list and find one of interest
  • Label issue with "in-progress"
  • Go for it!
  • Put together a PR, flag somebody to have it merged
  • Close issue

Development

note, pyaudio depends on portaudio, a lower level library. To install on a mac:

brew install portaudio

Using pipenv, setup your dev environment with all the required libs:

pipenv install --dev 

Setting up light strips

This process really sucks. You'll need an internet connection, phone and have to install the app. I do not have alot of confidence in this process. If light strips need to be reset often, it will be challenging without an internet connection because of the dependence on the app during this process.

If you're on android, you'll need to turn on flight mode to make sure your cellular connection does not conflict with the light strip's wifi bootstrapping process.

To setup each strip:

  • Reset the strip if it's been connected previously
    • Turn it on and off 5 times
    • Press the teeny tiny button and hold for 15 seconds until the lights start to cycle
  • Connect to your normal wifi
  • In app, hit the "+" button (on android)
  • Connect to the new network the light strip has started (starts with "LIFX")
  • Add light and complete form on app

About

A light control system for heavy meta, an art car headed to burning man

License:MIT License


Languages

Language:Python 58.2%Language:HTML 40.3%Language:Shell 1.5%