Hey! This project is an alarm clock implemented using the Photon board to make it smarter.
In our busy everyday lives, we set alarms on our mobiles depending on the day to day changing schedules. However, our alarm clocks have not yet gained the intelligence to keep track of these changes or support multiple alarm support intuitively. This forces us to sleep with our mobile lying next to us, dissipating harmful radiation throughout the night. Further, since most of us have disposed off the old dumb bed side alarm, we have to look at the bright screen of the phone when we wake up to tell the time and this can spoil our sleep in case we have woken up earlier than necessary.
The Photon clock is my first step to solving this problem!
Working
Lets see the device in action!
The device loads the time from the internet when it boots up.
Adding the first alarm to on the mobile -
Adding the second alarm. Notice that this alarm is set for earlier than the first. The algorithm on the Photon understands this and modifies the alarm time accordingly.
Now lets ring the alarm!
The alarm goes off with the sounds and lights blazing from the toy car! When the alarm rings on the mobile, it sends a message to the Photon asking the alarm to ring. The alarm goes off on the Photon with the sounds from the car. The alarm can be switched off from the phone and this will switch off the physical alarm also. Neat!
The Photon is now ready with the next alarm that we had set earlier.
I have also added a physical button that will turn off the alarm - the functions of the regular alarm clock must not change!
Building the project
The project mainly involves the Photon and the FireFox OS mobile phone.
The Photon
This is a brilliant piece of hardware. This is my first experience building a cloud application and Photon made it really easy. The interaction between the Photon and the FireFox OS was done completely using HTTP requests. Since HTTP requests can easily trigger functions in the Photon, the interaction was a breeze.
The next challenge for the photon was to interface with the MAX7219 led driver. The library provided with the Build made this extremely simple and it worked out of the box.
Then I had to build the clock on the Photon. Once again, the provided libraries were more than sufficient. However, I could not use the provided alarm library as my application required specific functions that were not available. Therefore I built the alarm backbone which handles the alarms.
The FireFox OS
This must be the most interesting part of my project and also the most difficult!
I had to choose a mobile platform to build the clock application. This was a completely new terrain for me. I own an iPhone but do not have a developers account on the same. Photon provided support for Android but I did not want to use it for two reasons -
1) I wanted to build the functionality into the native clock application and this would need flashing the OS and complications
2) I personally do not wish to purchase an Android phone as it would cost a lot.
Therefore I decided to attempt to create my application using the FireFox OS. Now, I am a beginner in web apps also but I was excited when I heard of the idea of a mobile OS on HTML5 and really wanted to try it.
It was only after I purchased the mobile that Mozilla announced that it will be discontinuing the FireFox Mobile (they are planning on porting it to the IoT space, so fingers crossed on that!). It was a disappointment but I decided to continue using the platform. Now that I have developed on the platform, I can say that it is a pity that they are closing as the mobile is a boom for IoT development. It is completed HTML5 based so every button press can be converted to send a HTTP request!
That said, setting up the environment was a huge challenge. It took me 2 weeks of pouring through documentation to begin modifying the native apps. However I was finally able to side load the native clock application with my custom changes!
However, there were many hurdles to be crossed. The basic idea is to insert the appropriate HTTP requests where needed. An example request is :
var xhttp = new XMLHttpRequest();xhttp.open("POST", "https://api.particle.io/v1/devices/<ID>/doneAlarm?access_token=<TOKEN>", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("args=off");
The tricky part was to find the locations to insert the code. This required a detailed understanding of the app and for that I needed to learn java script also! It was turning out to be way more than what I bargained for but I stuck with and it finally worked!
The Alarm Sound
I was thinking of ways to sound the alarm and my friend happened to gift me a toy car with lights and sounds! It was a simple matter to wire to a GPIO and get the sounds!
Vision behind the project
Mobiles phones started combining various applications into them since they got smarter - clocks, address book, maps, music players. This consequently prevented those appliances from developing and increased our dependence on mobiles. My vision is to reverse this process by making everything smart again!
Comments