Two little "lamps", each having a led and they are in sync. I've made 2 mini lamps that are called "Friendship" lamps! One for me and the other for a close person that lives far from me. The idea is that if I turn my light to colour green, my friend light will also turn green! The lamps accept 6 different colours obtained from combining red-green-blue lights.
For a single lamp is required:
- Raspberry Pi Zero WH
- RGB led
- Mini-breadboard or breadboard
- Rezistors
- Heatsync
- 2 pushdown buttons
- Jmper wires
- Micro sd card >32 GB
- Power supply with micro sd
Additional supplies needed: monitor, keyboard, mouse, hdmi adapter, hdmi cable, USB OTG cable
- First you need a bootable micro sd. You can make one easy on your computer by downloading an image from: https://www.raspberrypi.org/software/operating-systems/ and then using a software like BalenaEtcher for flashing the micro sd.
- You need to insert the micro sd into your rpi and then connect all the components on the breadboard as presented in the schematics above. A mini breadboard is used in my case since the outcome desired is a little, cute night light.
- After all the components are properly connected, the rpi will be plugged into a power source and then will start.
- After finding the ip address of the rpi, you can connect from your computer to it (I used VNC Viewer).
- Make sure Python 3 is installed (run python3 --version) on the Raspberry Py. If not, install it via
<sudo apt-get install python3>
. - The next and final step is the need of cloning the lighted.py file from this repository. After you get the script on your rpi, you need to simply run it for the lamp to get functional. The requests are sent to a cloud server, thus it will work on any network without any additional setups.
- Optional: You can make the lamp script autorun at the start-up of the Raspberry Pi by adding the following line to the end of the /etc/rc.local file:
<python3 lighted.py>
- Optional: You can connect the lamp to your own server, either local or on the cloud by changing the url located on top of the lighted.py file. More information in regards to the server used and how it was deployed, you can find here: https://medium.com/fullstackai/how-to-deploy-a-simple-flask-app-on-cloud-run-with-cloud-endpoint-e10088170eb7
- Connect the raspberry pi to a power outlet and to a monitor. After you can easily connect to your home wireless internet. You will need a hdmi cable and an usb otg cable for this step.
- Find the file lighted.py located on the rpi's desktop and run it.
- In addition, you can make the lamp script autorun at the start-up of the Raspberry Pi by adding the following line to the end of the /etc/rc.local file:
<python3 lighted.py>
The server used for keeping the lights in sync is a simple flask server dockerised and deployed on google cloud.
Once the lamps are both plugged in and running, you can play with them in the following way:
- the leftmost button on the schematics picture is used for switching on/off the lamp's light;
- the inner button is used for switching between the lights, there are 6 possible light colours;
You can only switch off your own lamp light, you cannot switch off or on your friend lamp. It could be a bit weird for a sudden light to turn on in the middle of the night! Also, there could be more than 2 lamps connected to the same server and in sync.