Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

My RGB Alarm Clock [Code Snippet]

DZone's Guide to

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.

· IoT Zone
Free Resource

Discover why Bluetooth mesh is the next evolution of IoT solutions. Download the mesh overview.

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.

The prototype is very simple. The bulb has a Bluetooth interface and I’ve found a Python script to control the bulb. I’ve modified this script to adapt it to my needs.

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.

For example:

# 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.

Take a deep dive into Bluetooth mesh. Read the tech overview and discover new IoT innovations.

Topics:
iot apps ,raspberry pi ,python ,iot

Published at DZone with permission of Gonzalo Ayuso, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}