Remy Virin

iOS dude

Create a LEDs-powered Cloud! ☁️⚡️✨

At Prynt, 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… (See video here)

How to build Claudie? ✨

First we started with this video from instructables, it’s a great start, but it wasn’t easy to build something solid that won’t break, acrylic roads are quite expensive and the glue doesn’t really stick to. The goal here is to have a structure that is really light.
So after trying to build something with acrylic roads, we decided to take a cardboard and put bubble paper wrap around it to give to more a cloud form. After we tapped the LEDs on the bubble paper. Finally, we followed the procedure with the vinyl fabric and the polyester fiberfill shown on the video.
What you will need technically 🛒
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.

Wiring The Pi & the LEDs 🛠

This is how you wire the Pi and the LEDs, the diode is really important, it will reduce the input DC voltage from 5V to 3.3V, so the Pi which is delivering a voltage from 0 to 3.3V on the PWM will be able to control the LEDs. If you don’t put the diode, your Pi might be destroyed. This article is a great source if you want to understand why.
Image courtesy of Adafruit

Deploying the code on the Raspberry Pi 👩‍💻

If you are not familiar with the Raspberry Pi environment, the setup is really easy. You just have to download Raspbian and install it on a SD Card. The installation documentation is really helpful.
The
rpi_ws281x
is the lib that manages the LEDs, you might want to fork it to set the amount of LEDs 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
http://IP_ADDRESS:PORT/prynt
it lights the cloud in a storm effect.

Getting the Raspberry Pi ready

Once you have the OS running and can ssh on the Raspberry Pi you can clone this project and install everything you will need:
pip install RPi.GPIO # Python module to control Raspberry Pi GPIO
pip install Flask # a Python framework to create a web server
git clone git@github.com: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 git@github.com: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
http://IP_ADDRESS:PORT/prynt
should light the cloud.

Customize with your own needs 🛠

As said before, you can put any trigger you want, a like on your Facebook page, one on Instagram to light your cloud, the possibilities are endless :)
This is the code that is doing the animation on Claudie side:
@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 several ways to do it, is editing the
crontab
script:
sudo crontab -e
Start Claudie program:
@reboot python /home/pi/Desktop/Claudie/app.py & 

Customize your Claudie 🌈 🌈

If the double rainbow is your kind of thing, you can customize it like this.
If you have any questions or comments, I’d love to read them in the comments!
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.

Tags

More by Remy Virin

Topics of interest