visit
At , we have creativity days, we work on everything we want for few days. I believe this is really important to have some time you can work on something else for your company. A colleague did some art paint in our office, another create slack emoji of everyone in the company, I decided to create this cloud with the help of some colleagues (by the way, we name it Claudie).
As you can see in the video, you can plug the cloud to any trigger that will light his LEDs. For instance if someone likes your Facebook page, a transaction made in your shop etc…Disclaimer: We made this cloud with all the followings components, there is many ways to do it, you can use an Arduino instead of a Raspberry Pi, use different types of LEDs.
The
rpi_ws281x
is the lib that manages the LEDs, you might want to fork it to you have and to customize the light animation (see all the examples in the python folder).The
Claudie
repository is handling a web server, every time we send a POST
on //IP_ADDRESS:PORT/prynt
it lights the cloud in a storm effect.pip install RPi.GPIO # Python module to control Raspberry Pi GPIO
pip install Flask # a Python framework to create a web server
git clone [email protected]:rvi/Claudie.git # our implementation of the web server that will light the LEDs
# Installation of the lib that control the LEDs via the GPIO
sudo apt-get update
sudo apt-get install build-essential python-dev git scons swig
git clone [email protected]:rvi/rpi_ws281x.git
cd rpi_ws281x
scons
cd python
sudo python setup.py install
# Go back to Claudie code and run the app
cd ../../Claudie
python app.py
Now you have your app ready by doing
POST
on //IP_ADDRESS:PORT/prynt
should light the cloud.
@app.route('/prynt', methods = ['POST'])
def prynt():
time.sleep(0.5) # usefull when you have a lot of requests at the same time
# Launch a subprocess in Python to light the LEDs with a greenStorm animation
subprocess.call(['sudo', sys.executable, '/home/pi/Desktop/rpi_ws281x/python/examples/greenStorm.py'])
return 'Clould storm successful!'
Each time a
POST
is made on /prynt
we create a subprocess with the sudo authorisation. That was the main difficulty of this project, sudo
is required to use the rpi_ws281x
lib. This subprocess executes the storm animation on the cloud one time. The user ( pi by default) executing the command need to have the sudo authorisation.If there is a power outage, it can be great if your program restart by itself, on the startup of the Pi. To do so, one of the to do it, is editing the
crontab
script:sudo crontab -e
@reboot python /home/pi/Desktop/Claudie/app.py &
Disclaimer: Setting sudo by default on the pi user is not recommended in terms of security. Further more if your Raspberry Pi is accessible from outside your network.