My RGB Alarm Clock [Code Snippet]
Take a look at this quick hack to set up a BeeWi to change colors based on a schedule.
Join the DZone community and get the full member experience.Join For Free
I’ve got a BeeWi Smart LED Color Bulb. I must admit I cannot resist buying these kinds of devices.
I can switch the bulb on/off and change the color using its Mobile App, but that’s not fun. I want to play a little bit with the bulb. My idea is to first switch on the bulb in the morning and set up the bulb color (blue, for example). Then change the bulb color depending on my morning routine. And finally, switch the bulb off. Now I will know if my morning routine is on-time by just looking at the bulb’s color. For example, if the bulb is red and I’m still having breakfast, I’m late.
Now I only need to set up the crontab within my Raspberry Pi to trigger the script and switch on/off the bulb and change the RGB color.
# switch on the bulb /usr/bin/python /mnt/media/projects/iot/bulb.py /mnt/media/projects/iot/conf.json on # set bulb's color to green /usr/bin/python /mnt/media/projects/iot/bulb.py /mnt/media/projects/iot/conf.json colour 999900
Now I’ve got another toy on my desk — one Arduino board. I’m sure I will enjoy a lot. In another post, we'll play with Telegram bots to read the temperature. Now I’ve adapted my bot to switch on/off and change the color of the bulb.
Published at DZone with permission of Gonzalo Ayuso, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.