Introduction: Intel IoT EDI - Monitoring a Comfortable and Safe Environment (with Intel Edison)

Before to start, I would like to thank Intel and Instructables for that opportunity: I've been selected among others winner of a marvelous Intel IoT Edison & Grove Kit... That was very surprising to me, and I am very grateful for it. Thanks! :-)

Introduction

The purpose of that first tutorial/instructable is to learn in working with the dev kit received, its sensors and their capabilities when they are working together. I'm not a english speaker, therefore, sorry if you find some mistake (I'm thinking if I should translate also this guide into italian and spanish... if you have doubts, please, don't hesitate to ask me (in any of those languages if you feel better :-P).

What is the purporse of a "comfortable and safe environment? I live in a shared flat with other 2 mates, and each one has its own room, its private space, its own world. Thinking about the sensors I've found in the kit it could be a good idea to develop a system in order to monitorize my room, at least, three basic factors: temperature, light and gas. WTF?!?!? Gas??? Yeah... Although inside of a room that sensor could be a nonsense, this prototype could be exported to other part of the house or make it more scalable.

I have more ideas to scale this prototype and make it bigger and more usable... if you are interested in it, keep the contact to my profile or contact me to provide you further details/info.

Step 1: Step 1: Material and Elements

The materials we'll need are:

  • Intel Edison (obviously) with Arduino Breakout.
  • Grove Base Shield v2 (to connect the sensors).
  • Grove RGB Backlight LCD.
  • Grove Temperature sensor.
  • Grove Light sensor.
  • Gas sensor MQ5 (LPG, natural gas, town gas).
  • Grove Push-button.
  • Grove LED socket with a red LED.
  • Some wires for the sensors.
  • A piece of polystyrene to allocate all elements.
  • A glass of your favorite drink! :-)

I'll avoid all steps related to install the last yocto image, setting up the WiFi connection, etc. because there are a lot of tutorials and that one is focused in other topic; however, if you have any problem or doubt, feel free to share with me your problems and I'll try to help you :-)

Regarding to the software side, the components that we will need are:

  • Node.js
  • Nano or vim.
  • MRAA library.
  • UPM library.

From those elements, all are installed in the yocto image except the nano editor... maybe, the unique one you are interested in is that editor, because many people are more comfortable using it... as you prefer! We you are one of them, here are the command that you should execute in a command line (all in one step):

wget http://www.nano-editor.org/dist/v2.2/nano-2.2.6.t... && tar xvf nano-2.2.6.tar.gz && cd nano-2.2.6 && ./configure && make && make install

or

opkg install nano

if the repositories have been added previously.

This project could be also made with arduino and writing the code into .ino source, but since there are lot of them written in that language (C or pseudo-C), I'd preferred to change it and show you other way to work with Intel IoT Edison (moreover, I'll develop a IoT version connected to the cloud).

Once you have all elements you'll be ready to start... let's go?

Step 2: Step 2: Wiring, Wiring, Wiring...

The second step will cover the process of mounting and wiring elements against the Edison board. Besides, I'll try to pretty them to improve its presentation.

With that configuration we'll be able to:

  • Read values from Temperature, Light and Gas sensors.
  • Detect a touch on the button; if so, we'll switch on the LCD display to improve the readability of the text.
  • Show the information from the sensors in the LCD display, besides of the time (hh:mm:ss).
  • Show an extra warning through a LED light.

The ports used in the connections are neither fixed nor mandatory to use the same as me; so, feel free to change them, but remember your new configurations (number of ports) when you download the code, because you'll have to update it.

To resume my configuration:

  • LCD display connected to the first I2C port.
  • Temperature sensor connected to AIO(0).
  • Light sensor wired to AIO(1).
  • Gas sensor addressed manually to AIO(2) because my wire doesn't fit with the connector on the Grove Shield Board, I mean, I don't connect it directly to the AIO port but to the pin #2 of analog pins. Remember also to connect (if you have/use the same sensor) the red-wire (VCC, 5V) and the black-wire (GND, 0V).
  • Button switch connected to D2 (digital).
  • Led socket wired to D4 (digital).

All analog ports and the button port will be configured as IN ports, due to we'll read their values. The simplest lecture is from the button, because it will return only zero or one values; the temperature, light and gas will return values inside a wider range.

The last wire that we need is the mini-usb in order to power the board (or an alternative method if you prefer: battery, wall-charger...).

Step 3: Step 3: Coding, Coding, Coding...

In that step I'll show you the code developed to manage and handle the sensors, retrieve the data and work with it accordingly. I've added some extra comments into the code in order to improve its readability and to make it auto-comment, even if you are not familiar with JavaScript language.

The source could be found in my GitHub account:

https://github.com/semagarcia/intel-iot-edi-basic-...

To clone the repo, remember:

  1. You have installed Git in your machine.
  2. git clone https://github.com/semagarcia/intel-iot-edi-basic-info-home
  3. cdintel-iot-edi-basic-info-home
  4. node Server.js

If you feel lost yet after read my code, I write you some tips/highlights:

  • The main file (entry point) is Server.js.
  • The ./constants/RestEndPoints.js is the file like acts as an enum, I mean, a file with "global" constants.
  • The ./boot/Boot.js is the file where is located all the heavy logic and initial setup of sensors.
  • The ./info/Handlers.js is the file to return the values from all sensors inside a JSON object to be consumed by the petitioner/requester (further details into the step 5).

If we imagine a timeline, every second the board reads and analyzes the temperature/light/gas values. By other hand, each 100ms the state of the button is read in order to detect an interaction (if the user has pressed it).

Step 4: Step 4: Let's Go! Show Me a Demo!

Since a picture is worth a thousand word... what about a "24 images/sec * 6mins" video?? A bunch of images!!! :-)

So, here is the video... enjoy! And... please... feel free to write your comments :-)

Step 5: Step 5: Connecting Through Internet

As we said previously in the third step, in our server we have one file called "./info/Handlers.js" and with the main file (Server.js) we could send requests from outside the WiFi home-network. But... why??

Very simple, just imagine the following scenario: a very cold evening of winter, returning back to home... you could imagine that your room (or your entire flat) will be very cold, but... what temperature? Mmm... and... if you could press a butto into your mobile phone in order to turn on a heater inside your room?? Sounds great, isn't it?

Although this awesome feature is not yet fully developed, this is the starting point. I'd like to write another tutorial tutorial deepen this to maximize the powerful of the Intel Edison and the concept of the IoT (at least, in a beginer way).

Once started up the server, we'll have the following URLs (or endpoints, talking in a Restful API context):

  • 192.168.X.X:3000: to request if the server is either avaliable or not; if so, we'll return a "status : online" JSON as response.
  • 192.168.X.X:3000/info: to request the information of all sensors (temperature, light and gas). The response will have the following structure:

{ temp: X, light: Y, gas: Z }

where X, Y and Z will be the values retrieved from the sensors (see the screenshots attached to this step in order to see some examples).

  • 192.168.X.X:3000/info/temp: to request only the temperature value.
  • 192.168.X.X:3000/info/light: to request only the light value.
  • 192.168.X.X:3000/info/gas: to request only the gas value.

If you are really interested in this step, I mean, you are interested to be able to send requests from the outside of your private WiFi, you should have and enable your NAT feature in your router in order to perform "port fordwarding" or "port mapping"; in other words, a method of forwarding a network port from one network node to another. With this configuration you can allow an external user (for instance, your mobile or a browser) to reach a port on a private IP address (inside a LAN, the port of node.js server) from the outside using a NAT-enabled router. This process is out of the boundaries of this tutorial.

Step 6: Step 5: Conclusions

  • I'm very happy for being one of the winners of the Intel Edison dev kit.
  • I thought that the Intel Edison could be more or less like a Raspberry Pi, but now I'm discovering the difference between them, and the possible uses of each one.
  • I would like to be able to install the ubilinux image, but I had a lot of problems installing the UPM libraries, calling them from node/python, etc. In the end, I returned back to yocto image to avoid those problems and to work with the Intel Edison.
  • The possibility to execute programs written in C, JavaScript, C++ or Python is a great feature and a big door to develop the best app that better fits with our needs.
  • The quantity of sensors and the zero-complexity to use them through the Base Shield and the libraries such as MRAA or UPM... that was incredible!! I only needed 3-4 lines of code to play with the sensors and actuators.
  • The possibility to develop applications and embed them inside a very small component in order to be nearer and reach the full concepto of wereables.
  • I'm very impressed for the bunch of ideas that I'm putting on my "personal backlog", and very impressed also for that awesome hardware... really that was a great work by Intel!

Step 7: Step 6: Future Tutorials and Own Roadmap

As some of my future ideas and projects over Intel Edison

  • Perform a fully bidirectional communication between the server and any authorized client (me, my girlfriend, etc...)
  • Can send notifications to a mobile client based on preconfigured alerts, I mean, register into the system rules in this way:
    • When the temperature is below of X ºC, send me a notification... because I could like enable the "watering plant" system.
    • When I have more than X measures of temperature value, draw me a graph to see the evolution of the temperature along the day.
    • Etc.
  • I've also developed a domotic system at home with a X10 system + raspberry... I would like to export it over Intel Edison to check the performance, the consumption, etc.
  • I like to investigate the Bluetooth 4.0 LE (BT Low Energy) and its interaction with mobile clients (Android, iOS, BlackBerry and Windows Phone).

And you... would you like to share with my same idea?? Do you thing that some of them could be improved?! Let me know!!! :-)

I hope that first [english] instructable would be helpful for you. If you want to contact with me, don't hesitate to write me!!!