|
| 1 | +# Alarm clock in Python* |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +This smart alarm clock application is part of a series of how-to Intel® IoT code sample exercises using the Intel® IoT Developer Kit, Intel® Edison development platform, cloud platforms, APIs, and other technologies. |
| 6 | + |
| 7 | +From this exercise, developers will learn how to:<br> |
| 8 | +- Connect the Intel® Edison development platform, a computing platform designed for prototyping and producing IoT and wearable computing products.<br> |
| 9 | +- Interface with the Intel® Edison platform IO and sensor repository using MRAA and UPM from the Intel® IoT Developer Kit, a complete hardware and software solution to help developers explore the IoT and implement innovative projects.<br> |
| 10 | +- Run this code sample in Intel® XDK IoT Edition, an IDE for creating applications that interact with sensors and actuators, enabling a quick start for developing software for the Intel® Edison or Intel® Galileo board.<br> |
| 11 | +- Set up a web application server to set the alarm time and store this alarm data using Azure Redis Cache\* from Microsoft Azure\*, Redis Store\* from IBM Bluemix\*, or ElastiCache\* using Redis\* from Amazon Web Services\* (AWS), different cloud services for connecting IoT solutions including data analysis, machine learning, and a variety of productivity tools to simplify the process of connecting your sensors to the cloud and getting your IoT project up and running quickly. |
| 12 | +- Set up a MQTT-based server using IoT Hub from Microsoft Azure\*, IoT from IBM Bluemix\*, IoT or IoT from Amazon Web Services\* (AWS), different cloud machine to machine messaging services based on the industry standard MQTT protocol. |
| 13 | +- Invoke the services of the Weather Underground* API for accessing weather data. |
| 14 | + |
| 15 | +## What it is |
| 16 | + |
| 17 | +Using an Intel® Edison board, this project lets you create a smart alarm clock that:<br> |
| 18 | +- can be accessed with your mobile phone via the built-in web interface to set the alarm time.<br> |
| 19 | +- displays live weather data on the LCD.<br> |
| 20 | +- keeps track of how long it takes you to wake up each morning, using cloud-based data storage. |
| 21 | + |
| 22 | +## How it works |
| 23 | + |
| 24 | +This smart alarm clock has a number of useful features. Set the alarm using a web page served directly from the Intel® Edison board using your mobile phone. When the alarm goes off, the buzzer sounds and the LCD indicates it’s time to get up. The rotary dial can be used to adjust the brightness of the display. |
| 25 | + |
| 26 | +In addition, the smart alarm clock can access daily weather data via the Weather Underground* API and use it to change the color of the LCD. |
| 27 | +Optionally, all data can also be stored using the Intel® IoT Examples Datastore running in your own Microsoft\* Azure\*, IBM\* Bluemix\*, or AWS account. |
| 28 | + |
| 29 | +## Hardware requirements |
| 30 | + |
| 31 | +This sample can be used with either the Grove\* Starter Kit Plus from Seeed Studio, or else the DFRobot\* Edison Starter Kit. |
| 32 | + |
| 33 | +Grove\* Starter Kit Plus, containing: |
| 34 | + |
| 35 | +1. Intel® Edison with an Arduino* breakout board |
| 36 | +2. [Grove\* Rotary Analog Sensor](http://iotdk.intel.com/docs/master/upm/node/classes/groverotary.html) |
| 37 | +3. [Grove\* Buzzer](http://iotdk.intel.com/docs/master/upm/node/classes/buzzer.html). |
| 38 | +4. [Grove\* Button](http://iotdk.intel.com/docs/master/upm/node/classes/grovebutton.html) |
| 39 | +5. [Grove\* RGB LCD](http://iotdk.intel.com/docs/master/upm/node/classes/jhd1313m1.html) |
| 40 | + |
| 41 | +DFRobot\* Starter Kit for Intel® Edison, containing: |
| 42 | + |
| 43 | +1. Intel® Edison with an Arduino* breakout board |
| 44 | +2. [Buzzer](http://www.dfrobot.com/index.php?route=product/product&product_id=84). |
| 45 | +3. [Button](http://iotdk.intel.com/docs/master/upm/node/classes/grovebutton.html) |
| 46 | +4. [Rotary Dial]() |
| 47 | +5. [LCD Keypad Shield](http://iotdk.intel.com/docs/master/upm/node/classes/sainsmartks.html) |
| 48 | + |
| 49 | +## Software requirements |
| 50 | + |
| 51 | +1. Intel® XDK IoT Edition |
| 52 | +2. Microsoft\* Azure\*, IBM\* Bluemix\*, or AWS account (optional) |
| 53 | +3. Weather Underground\* API key (optional) |
| 54 | + |
| 55 | +### How to set up |
| 56 | + |
| 57 | +To begin, clone the **How-To Intel IoT Code Samples** repository with Git\* on your computer as follows: |
| 58 | + |
| 59 | + $ git clone https://github.com/intel-iot-devkit/how-to-code-samples.git |
| 60 | + |
| 61 | +To download a .zip file, in your web browser go to <a href="https://github.com/intel-iot-devkit/how-to-code-samples">https://github.com/intel-iot-devkit/how-to-code-samples</a> and click the **Download ZIP** button at the lower right. Once the .zip file is downloaded, uncompress it, and then use the files in the directory for this example. |
| 62 | + |
| 63 | +### Installing the program manually on the Intel® Edison board |
| 64 | + |
| 65 | +Alternatively, you can set up the code manually on the Intel® Edison board. |
| 66 | + |
| 67 | +Clone the **How-To Intel IoT Code Samples** repository to your Intel® Edison board after you establish an SSH connection to it, as follows: |
| 68 | + |
| 69 | + $ git clone https://github.com/intel-iot-devkit/how-to-code-samples.git |
| 70 | + |
| 71 | +Then, navigate to the directory with this example. |
| 72 | + |
| 73 | +To install Git\* on the Intel® Edison board (if you don’t have it yet), establish an SSH connection to the board and run the following command: |
| 74 | + |
| 75 | + $ opkg install git |
| 76 | + |
| 77 | +### Connecting the Grove\* sensors |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | +You need to have a Grove\* Shield connected to an Arduino\*-compatible breakout board to plug all the Grove\* devices into the Grove\* Shield. Make sure you have the tiny VCC switch on the Grove\* Shield set to **5V**. |
| 82 | + |
| 83 | +1. Plug one end of a Grove\* cable into the Grove\* Rotary Analog Sensor, and connect the other end to the A0 port on the Grove\* Shield. |
| 84 | + |
| 85 | +2. Plug one end of a Grove\* cable into the Grove Button, and connect the other end to the D4 port on the Grove\* Shield. |
| 86 | + |
| 87 | +3. Plug one end of a Grove\* cable into the Grove Buzzer, and connect the other end to the D5 port on the Grove\* Shield. |
| 88 | + |
| 89 | +4. Plug one end of a Grove\* cable into the Grove RGB LCD, and connect the other end to any of the I2C ports on the Grove\* Shield. |
| 90 | + |
| 91 | +### Connecting the DFRobot\* sensors |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | +You need to have a LCD Keypad Shield connected to an Arduino\*-compatible breakout board to plug all the DFRobot\* devices into the LCD Keypad Shield. |
| 96 | + |
| 97 | +1. Plug one end of a DFRobot\* cable into the Buzzer, and connect the other end to the A1 port on the LCD Keypad Shield. |
| 98 | + |
| 99 | +2. Plug one end of a DFRobot\* cable into the Button, and connect the other end to the A2 port on the LCD Keypad Shield. |
| 100 | + |
| 101 | +3. Plug one end of a DFRobot\* cable into the Rotary Analog Sensor, and connect the other end to the A3 port on the LCD Keypad Shield. |
| 102 | + |
| 103 | +### Manual Intel® Edison setup |
| 104 | + |
| 105 | +If you're running this code on your Intel® Edison board manually, you need to install some dependencies. |
| 106 | + |
| 107 | +Instructions here... |
| 108 | + |
| 109 | +### Intel® IoT Gateway setup |
| 110 | + |
| 111 | +You can run this example using an Intel® IoT Gateway connected to an Arduino\*/Genuino\* 101. |
| 112 | + |
| 113 | +Make sure your Intel® IoT Gateway is setup, by following the directions on the web site here: |
| 114 | + |
| 115 | +https://software.intel.com/en-us/node/633284 |
| 116 | + |
| 117 | +The Arduino\*/Genuino\* 101 needs to have the Firmata\* firmware installed. If you have IMRAA installed on your gateway, this will be done automatically. Otherwise, install the StandardFirmata or ConfigurableFirmata sketch manully on to your Arduino\*/Genuino\* 101. |
| 118 | + |
| 119 | +### Weather Underground\* API key |
| 120 | + |
| 121 | +To optionally fetch the real-time weather information, you need to get an API key from the Weather Underground\* website: |
| 122 | + |
| 123 | +<a href="http://www.wunderground.com/weather/api/">http://www.wunderground.com/weather/api</a> |
| 124 | + |
| 125 | +You cannot retrieve weather conditions without obtaining a Weather Underground* API key first. You can still run the example, but without the weather data. |
| 126 | + |
| 127 | +Pass your Weather Underground\* API key to the sample program as follows: |
| 128 | + |
| 129 | +Instructions here... |
| 130 | + |
| 131 | +### Data store server setup |
| 132 | + |
| 133 | +Optionally, you can store the data generated by this sample program in a back-end database deployed using Microsoft\* Azure\*, IBM\* Bluemix\*, or AWS, along with Node.js\*, and a Redis\* data store. |
| 134 | + |
| 135 | +For information on how to set up your own cloud data server, go to: |
| 136 | + |
| 137 | +[https://github.com/intel-iot-devkit/intel-iot-examples-datastore](https://github.com/intel-iot-devkit/intel-iot-examples-datastore) |
| 138 | + |
| 139 | +### MQTT server setup |
| 140 | + |
| 141 | +You can also optionally store the data generated by this sample program using MQTT, a machine-to-machine messaging server. You can use MQTT to connect to Microsoft\* Azure\*, IBM\* Bluemix\*, or AWS. |
| 142 | + |
| 143 | +For information on how to connect to your own cloud MQTT messaging server, go to: |
| 144 | + |
| 145 | +[https://github.com/intel-iot-devkit/intel-iot-examples-mqtt](https://github.com/intel-iot-devkit/intel-iot-examples-mqtt) |
| 146 | + |
| 147 | +## Configuring the example |
| 148 | + |
| 149 | +Instructions here... |
| 150 | + |
| 151 | +## Running the program |
| 152 | + |
| 153 | +To run the example on the Intel® Edison board, establish an SSH connection to the board and execute the following command: |
| 154 | + |
| 155 | + python alarm-clock.py |
| 156 | + |
| 157 | +### Setting the alarm |
| 158 | + |
| 159 | + |
| 160 | + |
| 161 | +The alarm is set using a single-page web interface served directly from the Intel® Edison board while the sample program is running. |
| 162 | + |
| 163 | +The web server runs on port `3000`, so if the Intel® Edison board is connected to Wi-Fi* on `192.168.1.13`, the address to browse to if you are on the same network is `http://192.168.1.13:3000`. |
| 164 | + |
| 165 | +### Determining the Intel® Edison IP address |
| 166 | + |
| 167 | +You can determine what IP address the Intel® Edison board is connected to by running the following command: |
| 168 | + |
| 169 | + ip addr show | grep wlan |
| 170 | + |
| 171 | +You will see the output similar to the following: |
| 172 | + |
| 173 | + 3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000 |
| 174 | + inet 192.168.1.13/24 brd 192.168.1.255 scope global wlan0 |
| 175 | + |
| 176 | +The IP address is shown next to `inet`. In the example above, the IP address is `192.168.1.13`. |
| 177 | + |
| 178 | +IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments. |
0 commit comments