Ever wake up to your alarm clock only to shut it off, lay back down, close your eyes for just a few seconds... and end up waking up much later than you had wanted? This project aims to solve that problem by building a smart alarm clock that can sense whether or not someone is still in bed and then proceed to wake them up again if necessary. This could help prevent someone from being disastrously late. For parents, there is a feature to push the data up to the cloud for your viewing pleasure. That means, you can check if your kids are still snoozing their day away and push an alarm sound over the internet to wake them up.
In the future, perhaps this project can be developed to integrate many Calendar APIs and the Google Map API to make smarter decisions about when someone has to wake up. With a few more sensors, it could potentially help us sleep better by monitoring the conditions for sounder sleep.
I started this project at Intel's IoT Roadshow Hackathon which featured their Intel Edison boards. These boards and a starter kit were provided.
Supplies that I had:
Intel® Edison with Kit for Arduino(chip and board), https://www.arduino.cc/en/ArduinoCertified/IntelEd...
Grove-LCD RGB Backlight
PIR Motion Sensor
Infrared Reflective Sensor
IR Distance Interruptor
Step 1: Setting Up Intel Edison
If this is your first time working with Intel Edison then there will be a few steps necessary before you can really get to the good stuff. Luckily, Intel does a decent job of providing introduction resources. Check out this link to get started -> https://github.com/intel-iot-roadshow/getting-star...
As a forwarning, I'm running Mac OS Yosemite. (My brother was running Windows 7 and faced serious problems.) I also code in C++.
I'll just make a few comments on what they have provided as I just went through the process earlier today.
- Getting Started with Intel Edison
- The actual physical part of connecting the board is pretty straight forward.
- Set up Your Computer
- I used a mac so I skipped this.
- Flash Edison Firmware
- The Flash Tool was provided on USB drives at the Hackathon so that will explain why the instructions assume you have the software already.
- Google it and download it (I found it easily and was about to download it before they told me I didn't have to.)
- My brother was running Windows 7 and it was absolutely impossible to do this step with his computer. He had to get a pre-flashed Edison chip after trying different ways to connect it for a few hours.
- The steps are very thorough for a Mac, no complaints.
- Straightforward as well
- Since I went with C++, I used their version of Eclipse which comes with special libraries. USE THEIR VERSION OF ECLIPSE. It will make life easier
- You can also use Arduino and load Intel Edison's IoT libraries but it may get confusing. I didn't try it and recommend Eclipse from the get go. I think Eclipse also makes connecting things to the cloud easier as well.
- Don't skip this step! It looks boring but I did and I regret it! This shows you how to easily import header files for the specific sensors you wish to use. The header file names are jargon so it won't be super obvious what they refer to if you skip this step.
- We will be using the LCD Display (under Displays), the IR Distance Interrupt, the PIR Motion Sensor, and the IR Reflective Sensor (under Light/Proximity/IR)
Step 2: Making the LCD Display Work
So now you have the Intel Edison all set up. You even have the header files to the relevant sensors in place. (Make sure this is the case.) Let's begin.
A fun little test that I did on my LCD Display to make sure it was working was add a pulsing effect. The relevant code is pictured above.
Step 3: Using and Calibrating the Sensors
Since you have loaded in the appropriate header files, getting each sensor up and running is relatively simple. Create an instance of a pointer to each sensor class by using the constructor. After creating the instances, each type of IR sensor basically has 1 function that matters (->value(), ->blackDetected(), etc.) and each of these functions will return a bool.
These sensor outputs will depend on the sensitivity which should be adjusted to fit your needs. The motion sensor can't be calibrated but both the IR Distance Sensor and the IR Reflective Sensor have potentiometers to adjust the sensitivity.
In the picture, I am calibrating the IR Distance Sensor which is meant to send a "true" when it senses an object approaching or very near to the sensor. Using a screwdriver, spinning it clockwise makes it more sensitive and counter clockwise makes it less sensitive. For this device, the recommendation is to hold the sensor over a dark, open area and twist the knob until the LED just turns off.
The IR Reflective sensor is traditionally used for close-up sensing so it should be calibrated on a table with a light and dark area. Details on calibrating the sensor can be found here http://www.seeedstudio.com/wiki/Grove_-_Infrared_...
I have included some of my code to have the Intel Edison board react to the sensors' inputs.
Step 4: Displaying Updated Time
In the cpp file that was uploaded to the previous page, the hardcoded string "Time: " was used to make it easier to just get the sensors up and running but what we really want is the real time.
Originally, I tried setting up the RTC on the Intel Edison but I found out that you actually need an external (coin) battery to use the RTC. (The idea being that the clock would continue to run even when the Intel chip is turned off.) If you have a battery, than you can use that method and set the time yourself.
However, looking through demo programs, I went with a different method for displaying the time. I've included the code above. This relies on being updated through the internet. In the main program, you can replace the hardcoded "lcd->write('Time: ');" with "displayTime(lcd);"
I didn't have the time to configure button inputs to set the alarm time myself but you can imagine how one might do this relatively easily. In the code, you would write a state that could be initiated ("if") with a button. In the state, you would proceed to print instructions onto the LCD and input with a set of buttons to change the desired alarm time. Then, you would compare this set time with the value that is returned by displayTime. If it hits that time, then the alarm is automatically sounded.
Step 5: Connecting to the Cloud
So I attempted to use Intel's own IoT Analytics platform. You can find the link to that platform here https://dashboard.us.enableiot.com
Out of all the resources for the Intel Edison that I worked with, the aspect that was least documented was the IoT Analytics Platform. I will go through their instructions and comment on where I tripped up.
Their guide is included here. https://software.intel.com/en-us/node/530661
It was also useful to look at Intel's github IoT examples used here https://github.com/intel-iot-devkit/iot-devkit-sam... Specifically, I found the "transportation-safety" example quite helpful. Along with the official guide from the other link, take a look at their sample guide to get started.
- Make sure IoTKit-Admin and IoTKit-Agent are installed
- They were for me so... good luck with that if it's not for you. At least, the steps look pretty detailed.
- Test your connections
- iotkit-admin test
- iotkit-admin device-id
Disclaimer: I wasn't able to completely connect my device to the Intel IoT Analytics Platform. I had it connected and successfully sent up test signals through Edison which is Wifi connected. I also added functions to my code to allow for the connections and to push the data up to the cloud. At one point, this seemed to be working but there was an error with the sensor name. The readings along with the error message could be seen in the terminal. I had taken some of the code from the Intel Github Transportation and Safety Sample project and made the mistake of not renaming the sensor. After renaming the sensor and setting up the Edison chip again, the connection no longer seemed to work. With some more time, it's probably a simple fix as all the pieces seemed to be working at some point and just not all at the same time.
This is a work in progress so hopefully I can come back with better news soon. Good luck to you!
Step 6: Continued Work and Vision
Get the IoT resources working. (AT&T M2X seemed to work for some people.)
Connect a speaker to Edison with Bluetooth.
Analyze and Interpret the data and display it as a very straightforward ("Out of Bed","Waking Up","Still asleep", "Returned to Sleep") outputs. This will be made easier with more sensors that are set at different sensitivity levels. This will be very important in "fool proofing" the alarm clock.
Assign the Speaker as an "Actuator" on Intel IoT Analytics so that it can be controlled from the cloud.
Integrate with Calendar Applications to allow the alarm to adjust to your schedule.
Google Maps API to check if traffic is extra bad so the alarm knows to wake you up earlier than usual.
Track Sleeping Movement Data to analyze sleep patterns and recommend better sleeping times for the user.