Intel Maker IOT Boiler Plate

Rishi Gaurav Bhatnagar
4 min readJun 13, 2015

--

~No, it is not a internet controlled hot plate~

Hi,
If you have stumbled upon this link, it would be because of two possible reasons :
1. You want to build an internet controlled plate(?).
2. You saw/heard about one of my repositories somewhere and want to get the bare bones of code to build scale-able, real world application.

Well if you are here for the first reason, let me assure you, I will write a tutorial on that too, but this one is strictly for second reason.
Let’s get started?
I am guessing you already know what IOT means. What it stands for. From and industry point of view, a prototype is not going to suffice. It is not going to be scaleable , affordable and sustainable. My aim here is to give out the bares bones of what is needed to build something that addresses all of the above 3 catch words.
A typical IOT project consists of 3 parts:
1. Sensors which are read by a processor.
2. A server which handles/stores/manipulates/makes sense of all the data coming in from sensors.
3. A application web/mobile which could show you what is really happening in the sensor systems.

Intel Edison — Python Core

So let’s start with 1. How do you interface sensors with an IOT capable board like Intel Edison ? How do you read data, how do you make I/O functions work? How do you ultimately send the data to the servers? We are going to address all these problems here.

My choice of programming language here is Python[ok, let’s be politically correct, my choice of scripting language here is Python].

First import the library we are going to use .

import mraa

This is how we declare pins

x = mraa.Aio(0) #Analog Reading
''' Digital Pin Declaration '''
x = mraa.Gpio(8)
x.dir(mraa.DIR_OUT)#Output
y = mraa.Gpio(7)
y.dir(mraa.DIR_INP) #Input

Almost all your projects will require the above basic setup for the sensors you integrate. Grove sensor kit is great way to start your projects. I received one at Intel IOT Roadshow in Bangalore last year (Yay!).
But if you don’t have one, you don’t need to worry, you can always work with the sensors you have :)

Connecting Intel Edison to the server/cloud

So to connect your Edison to the server, you first need to have a server running. More coming up on how to write you own server in the next section.
Usually there will be two main things you would do with a server, from your board:
1. POST some values to the server .
2.GET some values from the server to act on it.

Both POST and GET are HTTP request which we are going to make using an amazing python module called Requests.
This is how we go about using it :
First of all you will need python package manger called pip to be installed on your Edison. After connecting with the internet, do the following:

$curl -OL https://bootstrap.pypa.io/get-pip.py
$python get-pip.py install

Next install Requests.

$pip install requests

Now that you have your board ready with the core modules, look through the codes here to see how to:
1. Send GPIO values to the cloud.
2. Send Images to the cloud.
3. Test the cloud for its working.

More how to’s with Python will be updated on the above link itself.

Servers

So the next thing to do is to write servers. Servers, like I said before are a very important part of your project. It is the place where all the communication between your mobile app and the board happens. The servers written here are the very basic sketch on how you can use NodeJs with your IOT application. Intially you will host a server on your work computer/laptop. This will create something called the local host. To access this you will have to go to your browser and type localhost:3000/routeName .
routeName
is the link you direct your requests to for accepting GET or POST requests.
Let’s get started?

Install NodeJs on your system

Follow this link to get started with NodeJs on your system. It is relatively easy to install on a Mac and a Linux system :)

Install Heroku Tool belt

Follow this link . I use Heroku to test all my applications. If you have installed NodeJs on your system, it won’t be hard for you to install it on Heroku at all! It is easy to use and has good support. You could use another service of your choice for testing stuff.

Run the servers using:

$node serverName.js

I will be using various examples to show the same.

Mobile /Web App

So now comes the part where we are going to write an application (or client in developers language) to get your app running.
More on this coming up soon. Please follow this link :)

--

--

Rishi Gaurav Bhatnagar

Forbes 30 under 30 | Author | Intel Software Innovator | Product Guy | Storyteller