A smart gas valve for home safety

[ A smart gas valve for home safety ]

By in raspberry-pi 

 

Screenshot 2016-11-02 05.48.25.png
systemStructure.png
Screenshot 2016-10-25 11.26.56.png
MQTT-Gas-VV_phone.png.PNG
IMG_0198.PNG

Introduction

This instructable will cover the basic steps that you need to follow to get started with open sources such as Node-RED, MQTT v3.1, and Watson NodeRED for IBM Bluemix. MQTT(Message Queueing Telemetry Transport) is a Machine-To-Machine(M2M) or Internet of Things (IoT) connectivity protocol that was designed to be extremely lightweight and useful when low battery power consumption and low network bandwidth is at a premium. It was invented in 1999 by Dr. Andy Stanford-Clark and Arlen Nipper and is now an Oasis Standard.

The different tutorials can cause a great deal of confusion, which is why I have tried to make the easiest setup possible. Specifically, this instructable will cover how to code the Node-RED on Raspberry Pi2 as an MQTT client by connecting to your home wireless network and how to send sensor data. When you finish this project, I suggest you another M2M communication approach.

http://www.instructables.com/id/Smart-JPEG-Camera-for-Home-Security/

Step 1: Table of Contents

  • Step 0: Introduction
  • Step 1: Table of Contents
  • Step 2: Bill of Materials
  • Step 3: Setting up a smart gas valve with Raspberry Pi
  • Step 4: Programming NodeRED on Raspberry Pi2
  • Step 5: Setting up MQTT v3.1 on Raspberry Pi2
  • Step 6: Checking your NodeRED codes with MQTT on Raspberry Pi2
  • Step 7: Adding & Setting up IBM Watson, Play-Audio, E-Mail, Twitter, and Twilio
  • Step 8: Adding autostart files for every boot.
  • Step 9: Download list
  • Step 10: List of references

Step 2: Bill of Materials

  • Raspberry Pi2 X 1ea
  • Wifi dongle X 1ea
  • PIR motion sensor X 1ea
  • Android smartphone’s portable battery X 1ea
  • Nod-RED software X 1ea
    • Free open source
    • Use the version pre-installed in Raspbian Jessie image since November 2015
    • Installation guide
  • MQTT v3.1 software X 1ea
    • Free open source
    • Installation guide includes at Step 5
  • NodeRED’s Watson Nodes for IBM Bluemix
    • Text to speech node X 1ea
  • Speaker X 1ea

Step 3: Setting up a smart gas valve with Raspberry Pi

Setting up a smart gas valve with Raspberry Pi
580ee5a94936d4e9150001eb.jpeg
580ee8be937ddb575f0017df.jpeg
IMG_0286.JPG
580eea512e7fb659a400126b.jpeg
IMG_0285.JPG

Assembly steps

(1) Connect the Raspberry Pi2 with a magnetic switch sensor as shown above in the circuit diagram.

(2) Add a pull-up resistor(4.7 k ohm). If you use a really long wire, you could change approximately 1 k ohm. It depends on your environment.

(3) Connect the magnetic switch sensor with raspberry pi.

  • Magnetic sensor <—-> Raspberry Pi2
    • COM — Ground
    • NO — GPIO 18

(4) Assemble the magnetic switch sensor with a gas valve at home.

(The magnetic switch sensor should include an adhesive tape on the base.)

(5) Connect a portable battery with Raspberry Pi2.

(Use any portable battery to connect with the same size connector cable on Raspberry Pi2. )

Step 4: Programming NodeRED on Raspberry Pi2

How to start Node-RED on the web browser.

(1) Write down command shown below to a terminal window.

node-red-start

(2) You can find an IP address as below.

‘Once Node-RED has started, point a browser at http://169.254.170.40:1880

(3) Open your web browser.

(4) Copy the IP address and paste on the web browser.

(5) It will display a visual editor of Node-RED on the web browser.

(6) You can start coding with visual editor on the web browser.

(7) Try dragging & dropping any node from the left-hand side to right-hand side. It’s really easy to code.

( You can conveniently use the visual editor offline as well as online. )

Download the ‘SmartGasValve_NodeRED.txt’ file.

(1) Click the number (1) at the right-hand side corner shown in NodeRED on the web browser.

(2) Click the Import button on the drop down menu.

(3) Open the Clipboard shown in the above 1st picture.

(4) Lastly, paste the given JSON format text of ‘SmartGasValve_NodeRED.txt’ in Import nodes editor.

Step 5: Setting up MQTT v3.1 on Raspberry Pi2

Setting up MQTT v3.1 on Raspberry Pi2
Screenshot 2016-10-20 22.53.56.png
Screenshot 2016-10-20 22.56.15.png
Screenshot 2016-10-20 22.50.40.png
580eef472e7fb659a4001280.jpeg

Setting up MQTT v3.1 on Raspberry Pi2

This message broker(Mosquitto) is supported by MQTT v3.1 and it is easily installed on the Raspberry Pi and somewhat less easy to configure. Next, we step through installing and configuring the Mosquitto broker.

We are going to install & test the MQTT “mosquitto” on a terminal window.

curl -O http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
rm mosquitto-repo.gpg.key
cd /etc/apt/sources.list.d/
sudo curl -O http://repo.mosquitto.org/debian/mosquitto-jessie.list
sudo apt-get update

Next install the broker and command line clients:

  • mosquitto – the MQTT broker (or in other words, a server)
  • mosquitto-clients – command line clients, very useful in debugging
  • python-mosquitto – the Python language bindings
sudo apt-get install mosquitto mosquitto-clients python-mosquitto

As is the case with most packages from Debian, the broker is immediately started. Since we have to configure it first, stop it.

sudo /etc/init.d/mosquitto stop

Now that the MQTT broker is installed on the Pi we will add some basic security.

Create a config file:

cd /etc/mosquitto/conf.d/
sudo nano mosquitto.conf

Let’s stop anonymous clients connecting to our broker by adding a few lines to your config file. To control client access to the broker we also need to define valid client names and passwords. Add the lines:

allow_anonymous false
password_file /etc/mosquitto/conf.d/passwd
require_certificate false

Save and exit your editor (nano in this case).

From the current /conf.d directory, create an empty password file:

sudo touch passwd

We will use the mosquitto_passwd tool to create a password hash
for user pi:

sudo mosquitto_passwd -c /etc/mosquitto/conf.d/passwd pi

You will be asked to enter your password twice. Enter the password you wish to use for the user you defined.

Testing Mosquitto on Raspberry Pi

Now that Mosquitto is installed we can perform a local test to see if it is working:

Open three terminal windows. In one, make sure the Mosquitto broker is running:

mosquitto

In the next terminal, run the command line subscriber:

mosquitto_sub -v -t 'topic/test'

You should see the first terminal window echo that a new client is connected.

In the next terminal, run the command line publisher:

mosquitto_pub -t 'topic/test' -m 'helloWorld'

You should see another message in the first terminal window saying another client is connected. You should also see this message in the subscriber terminal:

topic/test helloWorld

We have shown that Mosquitto is configured correctly and we can both publish and subscribe to a topic.

  • When you finish testing all, let’s set up below that.
sudo /etc/init.d/mosquitto start

Step 6: Checking your NodeRED codes with MQTT on Raspberry Pi2

Checking your NodeRED codes with MQTT on Raspberry Pi2
topicgasvalve.png
topicPW.png
Screenshot 2016-10-20 18.05.26.png
Screenshot 2016-10-20 18.05.11.png
Screenshot 2016-10-20 18.03.05.png

When you have already used the JSON format of the ‘SmartGasValve_NodeRED.txt’ on Node-RED, it’s automatically set up & coded each data. I have already set up the each data in each node.

(1) Click each node.

(2) Check information inside each node has been prefilled.

(3) Please don’t change the set data.

(The above can be customized for more advanced users.)

Step 7: Adding & Setting up IBM Watson, Play-Audio, E-Mail, Twitter, and TwilioAdding & Setting up E-Mail, Twitter, and Twilio

Searching the Nodes

Node-RED comes with a core set of useful nodes, but there are a growing number of additional nodes available for install from both the Node-RED project as well as the wider community.
You can search for available nodes in the Node-RED library or on the npm repository.

  • For example, we are going to search Twilio at the npm web. Click here.
  • Next step, we are going to install Twilio on the raspberry pi.

Installing npm packaged node

To add additional nodes you must first install the npm tool, as it is not included in the default installation. The following commands install npm and then upgrade it to the latest 2.x version.

sudo apt-get update
sudo apt-get install npm
sudo npm install -g npm@2.x
hash -r
cd /home/pi/.node-red
  • For example, ‘npm install node-red-{example node name}’
  • Copy the ‘npm install node-red-node-twilio’ from the npm web. Paste it on terminal.
  • Then, we are going to install both node-red-node-watson and node-red-contrib-play-audio.
npm install node-red-node-twilio

<p>npm install node-red-node-watson node-red-contrib-play-audio</p>
  • You will need to restart Node-RED for it to pick-up the new nodes.
node-red-stop
node-red-start
  • Close your web browser and reopen the web browser.

Step 8: Adding autostart files for every boot.

Adding autostart files for every boot.

How to make an autostart file at every boot.

cd /etc/xdg/autostart/

(If there is no ‘autostart’ folder, make it below)

mkdir autostart
cd autostart
sudo nano flyMosquitto.desktop

Type the below (this will enclose the file) Or Put ‘flyMosquitto.desktop’ file into autostart folder.

[Desktop Entry] 
Type=Application
Name=flyMosquitto
Comment=Fly my mosquitto
Exec=cd /etc/mosquitto/conf.d/
Exec=mosquitto

Make it to autostart the Node-RED at every boot

sudo systemctl enable nodered.service

As shown in the above picture, please check the last line is as below.

23 Oct 06:21:22 – [info] [mqtt-broker:2be4dc46.47a5b4] Connected to broker: mqtt://localhost:1883

This is clearly working as a message broker(Mosquitto) on Raspberry Pi2.

 

 

A smart JPEG camera for home security

By in raspberry-pi    

First Prize IoT Builders Contest 2016 (IBM Watson IoT)

Screenshot 2016-11-05 18.18.12.png
Screenshot 2016-11-05 18.26.44.png
Screenshot 2016-11-05 18.28.35.png
thumb_IMG_0615_1024.jpg
Screenshot 2016-11-04 22.09.36.png
Screenshot 2016-11-04 22.35.22.png
Screenshot 2016-11-05 18.06.44.png
14877793_1118884861498137_1672939215_n.jpg

Introduction

This instructable will cover the basic steps that you need to follow to get started with open sources such as Watson nodes(Visual Recognition V3, Text To Speech) for IBM Bluemix, Node-RED, OpenCV, MQTT v3.1. MQTT(Message Queueing Telemetry Transport) is a Machine-To-Machine(M2M) or Internet of Things (IoT) connectivity protocol that was designed to be extremely lightweight and useful when low battery power consumption and low network bandwidth is at a premium. It was invented in 1999 by Dr. Andy Stanford-Clark and Arlen Nipper and is now an Oasis Standard.

I’ve already published an instructable of the Smart Gas Valve For Safety. In addition, I’m going to communicate between A Smart JPEG Camera and A Smart Gas Valve for M2M Communication by MQTT. Specifically, this instructable will cover how to code the Node-RED on Raspberry Pi2 as a MQTT client by connecting to your home wireless network and how to send sensor data. I will be using A Smart Gas Valve for M2M communication by MQTT.

Step 1: Table of Contents

  • Step 0: Introduction
  • Step 1: Table of Contents
  • Step 2: Bill of Materials
  • Step 3: Setting up the Camera & PIR Sensor with Raspberry Pi
  • Step 4: Programming NodeRED on Raspberry Pi2
  • Step 5: Setting up MQTT v3.1 on Raspberry Pi2
  • Step 6: Checking your NodeRED codes with MQTT on Raspberry Pi2
  • Step 7: Programming Python JPEG Camera
  • Step 8: Adding IBM Watson, IBM NoSQL DB, Play-Audio, and Twilio
  • Step 9: Adding autostart files for every boot
  • Step 10: Testing M2M Communication
  • Step 11: (Optional) Using OpenCV
  • Step 12: Download list
  • Step 13: List of references

Step 2: Bill of Materials

  • Wifi dongle X 1ea
  • PIR motion sensor X 1ea
  • Android smartphone’s portable battery X 2ea
  • Nod-RED software X 1ea
    • Free open source
    • Use the version pre-installed in Raspbian Jessie image since November 2015
    • Installation guide
  • MQTT v3.1 software X 1ea
    • Free open source
    • Installation guide includes at Step 5
  • NodeRED’s IBM Watson Nodes for Bluemix
    • Text to speech node X 1ea
    • Visual Recognition X 1ea
  • Speaker X 1ea
  • Minion X 1ea
    • You can easily buy it from eBay.

Step 3: Setting up the Camera & PIR Sensor with Raspberry Pi

Setting up the  Camera & PIR Sensor with Raspberry Pi
Screenshot 2016-10-29 17.50.26.png

Assembly steps for Smart JPEG Camera

(1) Connect the Raspberry Pi2 with a PIR motion sensor as shown above in the circuit diagram.

(2) Connect the PIR motion sensor with Raspberry Pi2.

  • Raspberry Pi2 PIR motion Sensor
    • 5V —————- VCC
    • GND ————- GND
    • GPIO 18 ——– OUT

(4) Assemble carefully the Pi camera with Raspberry Pi2.

(5) Connect a portable battery with Raspberry Pi2. (Use any portable battery to connect with the same size connector cable on Raspberry Pi2. )

Assembly steps for Smart Gas Valve : here

Step 4: Programming NodeRED on Raspberry Pi2

Programming NodeRED on Raspberry Pi2
581db15415be4d4ed700153d.jpeg
581db1e345bceb7607000d17.jpeg
581db2994fbadef11c001536.jpeg
581db31c4936d4c09200053f.jpeg
581db24315be4d1908000c68.jpeg
581db3dd4fbadef11c00153e.jpeg
Screenshot 2016-11-04 08.36.16.png

How to start Node-RED on web-browser.

(1) Write down command shown below to a terminal window. node-red-start

(2) You can find an IP address as below. ‘Once Node-RED has started, point a browser at http://169.254.170.40:1880&#8217; (It depends on your IP address)

(3) Open your web browser.

(4) Copy the IP address and paste on the web browser.

(5) It will display a visual editor of Node-RED on the web browser.

(6) You can start coding with visual editor on the web browser.

(7) Try dragging & dropping any node from the left-hand side to right-hand side. It’s really easy to code. ( You can conveniently use the visual editor offline as well as online. ) Download the ‘SmartGasValve_NodeRED.txt’ file. (1) Click the number (1) at the right-hand side corner shown in NodeRED on the web browser.

(2) Click the Import button on the drop down menu.

(3) Open the Clipboard shown in the above 1st picture.

(4) Lastly, paste the given JSON format text of ‘SmartJPGCameraNoCredits_NodeRED_ver0.1.txt‘ in Import nodes editor.

Step 5: Setting up MQTT v3.1 on Raspberry Pi2

Setting up MQTT v3.1 on Raspberry Pi2
Screenshot 2016-10-25 23.12.34.png
Screenshot 2016-10-25 23.13.03.png
Screenshot 2016-10-25 23.11.12.png
Screenshot 2016-10-25 23.10.09.png

Setting up MQTT v3.1 on Raspberry Pi2

This message broker(Mosquitto) is supported by MQTT v3.1 and it is easily installed on the Raspberry Pi and somewhat less easy to configure. Next, we step through installing and configuring the Mosquitto broker. We are going to install & test the MQTT “mosquitto” on the terminal window.

curl -O http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
rm mosquitto-repo.gpg.key
cd /etc/apt/sources.list.d/
sudo curl -O http://repo.mosquitto.org/debian/mosquitto-jessie.list
sudo apt-get update

Next install the broker and command line clients:

  • mosquitto – the MQTT broker (or in other words, a server)
  • mosquitto-clients – command line clients, very useful in debugging
  • python-mosquitto – the Python language bindings
sudo apt-get install mosquitto mosquitto-clients python-mosquitto

As is the case with most packages from Debian, the broker is immediately started. Since we have to configure it first, stop it.

sudo /etc/init.d/mosquitto stop

Now that the MQTT broker is installed on the Pi we will add some basic security.
Create a config file:

cd /etc/mosquitto/conf.d/

sudo nano mosquitto.conf

Let’s stop anonymous clients connecting to our broker by adding a few lines to your config file. To control client access to the broker we also need to define valid client names and passwords. Add the lines:

allow_anonymous false

password_file /etc/mosquitto/conf.d/passwd

require_certificate false

Save and exit your editor (nano in this case).
From the current /conf.d directory, create an empty password file:

sudo touch passwd

We will use the mosquitto_passwd tool to create a password hash for user pi:

sudo mosquitto_passwd -c /etc/mosquitto/conf.d/passwd pi

You will be asked to enter your password twice. Enter the password you wish to use for the user you defined.

Testing Mosquitto on Raspberry Pi

Now that Mosquitto is installed we can perform a local test to see if it is working:
Open three terminal windows. In one, make sure the Mosquitto broker is running:

mosquitto

In the next terminal, run the command line subscriber:

mosquitto_sub -v -t 'topic/test'

You should see the first terminal window echo that a new client is connected.
In the next terminal, run the command line publisher:

mosquitto_pub -t 'topic/test' -m 'helloWorld'

You should see another message in the first terminal window saying another client is connected. You should also see this message in the subscriber terminal:

topic/test helloWorld

We have shown that Mosquitto is configured correctly and we can both publish and subscribe to a topic.
When you finish testing all, let’s set up below that.

sudo /etc/init.d/mosquitto start

Step 6: Checking your NodeRED codes with MQTT on Raspberry Pi2

Checking your NodeRED codes with MQTT on Raspberry Pi2
Screenshot 2016-10-25 23.25.14.png
Screenshot 2016-11-05 20.48.11.png
Screenshot 2016-10-25 23.26.11.png
Screenshot 2016-10-25 23.26.28.png
Screenshot 2016-11-05 20.46.30.png

When you have already used the JSON format of the ‘SmartGasValve_NodeRED.txt’ on Node-RED, it’s automatically set up & coded each data. I have already set up the each data in each node.

(1) Click each node.

(2) Check information inside each node has been prefilled.

(3) Please don’t change the set data.

(The above can be customized for more advanced users.)

Step 7: Programming Python JPEG Camera

Programming Python JPEG Camera
Screenshot 2016-10-26 01.35.49.png
Screenshot 2016-10-26 00.46.23.png
Screenshot 2016-10-26 01.35.31.png
14885984_1118885038164786_1036372151_n.jpg

Programming Python JPEG Camera

First of all, you should test the camera module in the terminal window.

raspistill -o test.jpg

You should see the test.jpg in ‘/home/pi’

cd /home/pi
mkdir pythonPir
cd pythonPir
sudo nano pircameraNodeRED.py

Type the below (the enclosed file) Or Put ‘pircameraNodeRED.py’ file into ‘/home/pi/pythonPir’ folder.

import RPi.GPIO as GPIO 
import time
import picamera
import datetime 

timeFormat = 0

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN)  # For M2M Communication from Gas Valve signal
GPIO.setup(18, GPIO.IN)
camera = picamera.PiCamera()

while True:
        input17 = GPIO.input(17)  #Pin number 17 activates
        input18 = GPIO.input(18)  #Pin number 18 activates
        now = datetime.datetime.now()
        timeFormat = now.strftime("%Y%m%d_%H%M_%S.%s") #To put date and time in images

        if input17 == True or input18 == True:  #If PIR Sensor detects something, the Picamera will take.
                print('Motion_Detected_%s' %timeFormat)
                camera.capture('image_%s.jpg' %timeFormat) #To take a picture

                time.sleep(1) #sleeping time 1 second

When you finish typing, you should press the keys ‘Control‘ + ‘x‘ and press ‘y‘ to save this file.

Making an image file server

cd /home/pi
mkdir camserver
sudo nano requirements.txt

Type the below (the enclosed file) Or Put ‘requirements.txt’ file into ‘/home/pi/camserver’ folder.

numpy==1.10.1
websocket-client==0.35.0
websocket-server==0.4
ibmiotf==0.2.3
pip install --user -r requirements.txt

Execute an image file server in /home/pi/ below.

cd /home/pi
python -m SimpleHTTPServer 7000

Step 8: Adding IBM Watson, IBM NoSQL DB, Play-Audio, and Twilio

Adding IBM Watson, IBM NoSQL DB, Play-Audio, and Twilio
Screenshot 2016-11-04 08.35.52.png
Screenshot 2016-11-04 08.36.16.png
Screenshot 2016-11-04 08.33.28.png
Screenshot 2016-11-04 08.35.43.png

Searching the Nodes

Node-RED comes with a core set of useful nodes, but there are a growing number of additional nodes available for installing from both the Node-RED project as well as the wider community. You can search for available nodes in the Node-RED library or on the npm repository.

  • For example, we are going to search Twilio at the npm web. Click here.
  • Then, we are going to install Twilio on Raspberry pi.

Installing npm packaged node

To add additional nodes you must first install the npm tool, as it is not included in the default installation. The following commands install npm and then upgrade it to the latest 2.x version.

sudo apt-get update
sudo apt-get install npm
sudo npm install -g npm@2.x
hash -r
cd /home/pi/.node-red
  • For example, ‘npm install node-red-{example node name}’
  • Copy the ‘npm install node-red-node-twilio’ from the npm web. Paste it on a terminal window.
  • Ex: node-red-node-watson, node-red-contrib-play-audio, node-red-dashboard, and node-red-node-pidcontrol.
npm install node-red-node-twilio
  • You will need to restart Node-RED for it to pick-up the new nodes.
node-red-stop

node-red-start
  • Close your web browser and reopen the web browser.

Step 9: Adding autostart files for every boot.

Adding autostart files for every boot.

How to make autostart files at every boot.

  • Mosquitto
cd /etc/xdg/autostart/
sudo nano flyMosquitto.desktop

Type the below (this will enclose the file) Or Put ‘flyMosquitto.desktop’ file into autostart folder.

[Desktop Entry] 
Type=Application
Name=flyMosquitto
Comment=Fly my mosquitto
Exec=cd /etc/mosquitto/conf.d/
Exec=mosquitto
  • Node-RED
sudo systemctl enable nodered.service
  • Python JPEG Camera
cd /etc/xdg/autostart/
sudo nano pircameraNodeRED.desktop

Type the description below or put the ‘pircameraNodeRED.desktop’ file into /etc/xdg/autostart/ folder.

[Desktop Entry]
Type=Application
Name=pircameraNodeRED.py
Comment=Start my security camera
NoDisplay=false
Exec=python /home/pi/pythonPir/pircameraNodeRED.py
NotShowIn=GNOME;KDE;XFCE;
Name[en_US]=pircamera.py
  • Image file Server
cd /etc/xdg/autostart/
sudo nano imageFileServer.desktop

Type the description below or put the ‘imageFileServer.desktop’ file into /etc/xdg/autostart/ folder.

[Desktop Entry]
Type=Application 
Name=imageFileServer 
Comment=Start an image file server 
NoDisplay=false 
Exec=cd /home/pi 
Exec=python -m SimpleHTTPServer 7000

Step 10: Testing M2M Communication.

Testing M2M Communication.
Screenshot 2016-10-29 18.29.58.png
IMG_0395.JPG
IMG_0400.JPG

Importing the enclosed files in each NodeRED.

(1) Using a smart JPEG camera

Import the ‘M2M_SmartJPGCamera.txt‘ into the NodeRED of the smart JPEG camera.

(2) Using a smart gas valve

Import the ‘M2M_SmartGasValve.txt‘ into the NodeRED of the smart gas valve.

(3) Check an IP address of the smart gas valve in the Raspberry Pi2.

Type ‘ifconfig’ on a terminal window as shown below.

ifconfig

When you see the IP address, copy the IP address in a terminal window.

(4) Put the IP address into the MQTT node in other Raspberry Pi2.

  1. Click the MQTT node.
  2. Put the IP address into Server.

Step 11: (Optional) Using OpenCV

(Optional) Using OpenCV
Screenshot 2016-11-05 18.11.14.png

Installing & Using OpenCV on Raspberry Pi2

We have already used the IBM Watson Visual Recognition. Watson Visual Recognition is very excellent whereas we can’t use it without connecting wifi. OpenCV is possible to use without internet connection but It’s not very easy for a beginner to install & code into OpenCV. So, I’m going to install the OpenCV.

  • Download ‘opencv-3.1.0.zip from opecv.org
  • Install dependencies
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python-dev python-numpy libjpeg-dev libpng-dev libtiff-dev libjasper-dev
  • (Optional) Install OpenCV 2
sudo apt-get install python-opencv
  • Install OpenCV 3
unzip ~/Downloads/opencv-3.1.0.zip
cd opencv-3.1.0/
mkdir build
cd build/
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=NO -DBUILD_PERF_TESTS=NO ..
make -j3
sudo make install
sudo ldconfig
  • Check which version of OpenCV you have in Python
python
import cv2
cv2.__version__
  • Run the simple face detect sample, and look at its code to see how it works:
  • Before, you should connect an USB-cam with Raspberry Pi2
cd /home/pi
cd opencv-3.1.0
python ./facedetect.py

PID Control For CPU Temperature of Raspberry Pi

[ PID Control For CPU Temperature of Raspberry Pi ]

By in raspberry-pi

PID Control For CPU Temperature of Raspberry Pi
2
3
4
5
6
7

Introduction

My motivation for PID Control For CPU Temperature of Raspberry Pi came for many reasons such as very hot CPU, very noisy fan’s sound and fast battery consumption because the hot CPU makes the system really unstable while using Raspberry Pi for a long time. So, I have optimized the failing by using PID node on Node-RED. It’s visually helpful for a trainee to understand the PID control system for an educational purpose.

This will cover the basic steps that you need to follow to get started with open sources like PID node, MQTT node in the Node-RED. Also, it’s really painful and hard to tune 3 gains like KP, KI, and KD as manual tuning(Trial and error) method. There are many tuning methods such as Manual tuning, Ziegler–Nichols, Tyreus Luyben, Cohen–Coon, Åström-Hägglund and Software tools such as Simulink in Matlab or Excel PID Simulator (enclosed). I’ve already provided my source codes in the Download List but If you use a different fan, you should tune PID gains because most physical fan’s characteristics are different. You can get more information from the linked web (PID controller).

MQTT(Message Queueing Telemetry Transport) is a Machine-To-Machine(M2M) or Internet of Things (IoT) connectivity protocol that was designed to be extremely lightweight and useful when low battery power consumption and low network bandwidth is at a premium. It was invented in 1999 by Dr. Andy Stanford-Clark and Arlen Nipper and is now an Oasis Standard. I’ve already published about how to approach the MQTT below the linked webs.

http://www.instructables.com/id/Smart-JPEG-Camera-for-Home-Security/

http://www.instructables.com/id/Smart-Gas-Valve-Checker-for-Home-Safety/

Step 1: Table of Contents

Step 0: Introduction

Step 1: Table of Contents

Step 2: Bill of Materials

Step 3: Setting up an acrylic clear case, a fan with Raspberry Pi

Step 4: Programming NodeRED on Raspberry Pi2

Step 5: Setting up MQTT v3.1 on Raspberry Pi2

Step 6: Checking your NodeRED codes with MQTT on Raspberry Pi2

Step 7: Adding & Setting up PID node, Dashboard on Raspberry Pi2

Step 8: Using a dashboard for PID control

Step 9: Tuning PID controller

Step 10: Download list

Step 11: List of references

Step 2: Bill of Materials

Step 3: Setting up an acrylic clear case with a circuited fan with Raspberry Pi

8
9
10
11

Assembly steps

(1) I suggest you should use a breadboard before soldering and wiring all.

(2) Connect the Raspberry Pi2 with a PNP 1015 transistor, a fan, and a variable 102(1k) resistor as shown above in the circuit diagram.

(3) I used a glue gun to attach with the clear case.

(4) Lastly, connect a portable battery with Raspberry Pi2. (Use any portable battery to connect with the same size connector cable on Raspberry Pi2. )

Step 4: Programming NodeRED on Raspberry Pi2

12
13
14

How to start Node-RED on web-browser.

(1) Write down command shown below to a terminal window.

node-red-start

(2) You can find an IP address as below. ‘Once Node-RED has started, point a browser at http://169.254.170.40:1880&#8217; (It depends on your IP address)

(3) Open your web browser.

(4) Copy the IP address and paste on web-browser.

(5) It will display a visual editor of Node-RED on web-browser.

(6) You can start coding with visual editor on web-browser.

(7) Try dragging & dropping any node from the left-hand side to right-hand side. It’s really easy to code. ( You can conveniently use the visual editor offline as well as online. ) Download the ‘PID_Control_For_CPU_TEM_ver0.5.txt’ file. (1) Click the number (1) at the right-hand side corner shown in NodeRED on web-browser. (2) Click the Import button on the drop down menu. (3) Open the Clipboard shown in the above 1st picture. (4) Lastly, paste the given JSON format text of ‘PID_Control_For_CPU_TEM_ver0.5.txt’ in Import nodes editor.

Step 5: Setting up MQTT v3.1 on Raspberry Pi2

Setting up MQTT v3.1 on Raspberry Pi2

This message broker(Mosquitto) is supported by MQTT v3.1 and it is easily installed on the Raspberry Pi and somewhat less easy to configure. Next we step through installing and configuring the Mosquitto broker. We are going to install & test the MQTT “mosquitto” on terminal window.

curl -O http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
rm mosquitto-repo.gpg.key
cd /etc/apt/sources.list.d
sudo curl -O http://repo.mosquitto.org/debian/mosquitto-jessie.list
sudo apt-get update

Next install the broker and command line clients:

  • mosquitto – the MQTT broker (or in other words, a server)
  • mosquitto-clients – command line clients, very useful in debugging
  • python-mosquitto – the Python language bindings
sudo apt-get install mosquitto mosquitto-clients python-mosquitto

As is the case with most packages from Debian, the broker is immediately started. Since we have to configure it first, stop it.

sudo /etc/init.d/mosquitto stop

Now that the MQTT broker is installed on the Pi we will add some basic security.

Create a config file:

cd /etc/mosquitto/conf.d/
sudo nano mosquitto.conf

Let’s stop anonymous clients connecting to our broker by adding a few lines to your config file. To control client access to the broker we also need to define valid client names and passwords. Add the lines:

allow_anonymous false
password_file /etc/mosquitto/conf.d/passwd
require_certificate false

Save and exit your editor (nano in this case).

From the current /conf.d directory, create an empty password file:

sudo touch passwd

We will to use the mosquitto_passwd tool to create a password hash for user pi:

sudo mosquitto_passwd -c /etc/mosquitto/conf.d/passwd pi

You will be asked to enter your password twice. Enter the password you wish to use for the user you defined.

Testing Mosquitto on Raspberry Pi

Now that Mosquitto is installed we can perform a local test to see if it is working: Open three terminal windows. In one, make sure the Mosquitto broker is running:

mosquitto

In the next terminal, run the command line subscriber:

mosquitto_sub -v -t 'topic/test'

You should see the first terminal window echo that a new client is connected.In the next terminal, run the command line publisher:

mosquitto_pub -t 'topic/test' -m 'helloWorld'

You should see another message in the first terminal window saying another client is connected. You should also see this message in the subscriber terminal:

topic/test helloWorld

We have shown that Mosquitto is configured correctly and we can both publish and subscribe to a topic.When you finish testing all, let’s set up below that.

sudo /etc/init.d/mosquitto start

Step 6: Checking your NodeRED codes with MQTT on Raspberry Pi2

15
16
17

1819

When you will use the JSON format of the ‘PID_Control_For_CPU_TEM_ver0.5.txt‘ on Node-RED, it’s automatically set up & coded each data. I have already set up the each data in each node.

(1) Click each node.

(2) Check information inside each node has been prefilled.

(3) Please don’t change the set data. (The above can be customized for more advanced users.)

Step 7: Adding & Setting up PID node, Dashboard on Raspberry Pi2

Searching the Nodes

Node-RED comes with a core set of useful nodes, but there are a growing number of additional nodes available for installing from both the Node-RED project as well as the wider community. You can search for available nodes in the Node-RED library or on the npm repository.

  • For example, we are going to search ‘node-red-node-pidcontrol‘ at the npm web. Click here.
  • Then, we are going to install npm package, node-red-node-pidcontrol, node-red-dashboard on Raspberry Pi.

To add additional nodes you must first install the npm tool, as it is not included in the default installation. The following commands install npm and then upgrade it to the latest 2.x version.

sudo apt-get update
sudo apt-get install npm
sudo npm install -g npm@2.x
hash -r
cd /home/pi/.node-red
  • For example, ‘npm install node-red-{example node name}’
  • Copy the ‘npm install node-red-node-pidcontrol’ from the npm web. Paste it on a terminal window.
  • Ex: node-red-dashboard, and node-red-node-pidcontrol
npm install node-red-node-pidcontrol node-red-dashboard
  • You will need to restart Node-RED for it to pick-up the new nodes.
node-red-stop
node-red-start
  • Close your web browser and reopen the web browser.

Step 8: Using a dashboard for PID control

21
22
23
24
25

The dashboard is a visual UI tool like gauge, chart. There is a basic tutorial of a Node-RED dashboard using node-red-dashboard. http://developers.sensetecnic.com/article/a-node-red-dashboard-using-node-red-contrib-ui/

How to use the dashboard on Raspberry Pi.

(1) Click the number (1) of the gauge node.

(2) Set the group property.

(3) Set the properties from (3) to (7) shown from above the picture.

(4) Click the number (8) to go the dashboard window.

(5) Press the number (9) to display the gauge on the web browser.

(6) You can see the gauge which displays ‘40.1’ from the web browser.

(7) The chart to display on the web browser is same as the gauge (1 – 9 steps).

Step 9: Tuning PID controller

26
27
screenshot-2016-11-14-03-23-03
Screenshot 2016-11-14 23.34.39.png
screenshot-2016-11-14-03-20-28
screenshot-2016-11-18-02-00-28
screenshot-2016-11-14-03-11-13
7

There are many tuning methods such as manual tuning, Ziegler–Nichols, Tyreus Luyben, Cohen–Coon, Åström-Hägglund and software tools such as Simulink in Matlab or Excel PID Simulator(enclosed). I’ve used 2 tuning methods like manual tuning, Ziegler-Nichols method and software tools such as Matlab, Simulink, and Excel. (According to Wikipedia: PID Controller)

  • Manual Tuning(Trial and error)

How do the PID parameters affect system dynamics?

We are most interested in four major characteristics of the closed-loop step response. They are

– Rise Time: the time it takes for the plant output y to rise

– Overshoot: how much the peak level is higher than the steady state, normalized against the steady – state.
– Settling Time: the time it takes for the system to converge to its steady state.

– Steady-state Error: the difference between the steady-state output and the desired output.

(NT: No definite trend. Minor change.)

How do we use the table?

Typical steps for designing a PID controller are Determine what characteristics of the system needs to be improved.

– Use KP to decrease the rise time.

– Use KD to reduce the overshoot and settling time.

– Use KI to eliminate the steady-state error.

– This works in many cases, but what would be a good starting point? What if the first parameters we choose are totally crappy? Can we find a good set of initial parameters easily and quickly?

  • Ziegler–Nichols method

– Ziegler and Nichols conducted numerous experiments and proposed rules for determining values of KP, KI, and KD based on the transient step response of a plant.

– They proposed more than one methods, but we will limit ourselves to what’s known as the first method of Ziegler-Nichols in this tutorial. It applies to plants with neither integrators nor dominant complex-conjugate poles, whose unit-step response resemble an S-shaped curve with no overshoot. This S-shaped curve is called the reaction curve. This S-shaped curve is called the reaction curve.

– The S-shaped reaction curve can be characterized by two constants, delay time L and time constant T, which are determined by drawing a tangent line at the inflection point of the curve and finding the intersections of the tangent line with the time axis and the steady-state level line.

The Ziegler-Nichols Tuning Rule Table

Using the parameters L and T, we can set the values of KP, KI, and KDaccording to the formula shown in the table above.

These parameters will typically give you a response with an overshoot about 25% and good settling time. We may then start fine-tuning the controller using the basic rules that relate each parameter to the response characteristics. KP, KI, and KD based on the transient step response of a plant.

  • PID tuning software

– Matlab: PID Controller Tuning

– Simulink: PID Controller Tuning

– Excel PID simulator

– Etc

  • PID control VS On/Off control

On/Off control: An on-off controller is the simplest form of temperature control device. The output from the device is either on or off, with no middle state. An on-off controller will switch the output only when the temperature crosses the setpoint. For heating control, the output is on when the temperature is below the setpoint, and off above setpoint. Since the temperature crosses the setpoint to change the output state, the process temperature will be cycling continually, going from below setpoint to above, and back below. In cases where this cycling occurs rapidly, and to prevent damage to contactors and valves, an on-off differential, or “hysteresis,” is added to the controller operations. This differential requires that the temperature exceeds setpoint by a certain amount before the output will turn off or on again. On-off differential prevents the output from “chattering” or making fast, continual switches if the cycling above and below the setpoint occurs very rapidly. On-off control is usually used where a precise control is not necessary, in systems which cannot handle having the energy turned on and off frequently, where the mass of the system is so great that temperatures change extremely slowly, or for a temperature alarm. One special type of on-off control used for alarm is a limit controller. This controller uses a latching relay, which must be manually reset, and is used to shut down a process when a certain temperature is reached.

PID control: This controller provides proportional with integral and derivative control, or PID. This controller combines proportional control with two additional adjustments, which helps the unit automatically compensate for changes in the system. These adjustments, integral and derivative, are expressed in time-based units; they are also referred to by their reciprocals, RESET, and RATE, respectively. The proportional, integral and derivative terms must be individually adjusted or “tuned” to a particular system using trial and error. It provides the most accurate and stable control of the three controller types, and is best used in systems which have a relatively small mass, those which react quickly to changes in the energy added to the process. It is recommended in systems where the load changes often and the controller is expected to compensate automatically due to frequent changes in setpoint, the amount of energy available, or the mass to be controlled.

MQTT v3.1의 IoT가스밸브체커 실험

My Instruction Manual:  http://www.instructables.com/id/Smart-Gas-Valve-Checker-for-Home-Safety

YouTube : My demonstration For home safety with automatic voice

YouTube : My demonstration for M2M communication by MQTT

이번주는 사물인터넷의 통신 프로토콜의 하나인 MQTT(Message Queue Telemetry Transport) 통신 실험을 저렴한 라즈베리파이로 이용해보았다. 다음엔 CoAP 프로토콜을 실험할예정이다. 오늘 아침에 이 프로토콜의 사물인터넷 임베디드안에 수 많은 공통 토픽 메시지가 있으면 공통으로 묶어서 보내주고 트래픽잼을 줄이면서 효율적으로 데이타 큐로 처리된다는것을 발견했다. 예를 들면 Publisher(발행자) 가 ‘Hello’ 라는 메시지를 보내면 Subscriber(수령자)가 메시지 Broker(모스키토) 를 통해서 그 메시지를 받는 것이다. 구독하지 않은 토픽과 Subscriber 는 메시지를 받을 수 없다. 나의 가스밸브체커 실험안에  메시지 발행자(Publisher)가 ‘topic/gasvalve’방에 메시지를 발행하면 메시지브로커인(모스키토)가  가스벨브센서 데이타값(o/1)을 받아갈수 있도록 수령자(Subscriber)한테 ‘topic/gasvalve’ 방을 연결해준다. 아주쉽게 말하면 우편배달부(e-mail/p2p)는  아니고 우체국 혹은 게시판 개념과 비슷하다고 볼수있다. 처음에는 이해 못했지만 실제로 실험 해보니깐 조금씩 깨달아갔다.  MQTT는 IBM에 의하면 프로토콜의 장점은 저 전력 소모, 낮은 네트워크 대역폭, 적은 코드작성이다. MQTT 는 1999년에 IBM  Andy Stanford-Clark 가  발명했다. 나는 Andy Stanford-Clark의 TED동영상을 링크할것이다.  Facebook messenger도 이 통신 프로토콜을 사용한다.

Screenshot 2016-10-22 11.18.54.png

AddingPullupResistor4.7kohm.png

나의 가스밸브 체커로 나의 MQTT실험을 Node-RED로 구현한것이다.  제작방법과 코드작성은 너무나 길어서 생략하겠다.  제작 및 코딩방법은 여기 http://www.instructables.com/id/Smart-Gas-Valve-Checker-for-Home-Safety 에 링크했다.

가스밸브이 장착되어있는 마그네틱센서와 가스밸브이다.

gasvv

오픈 소스의 노드레드를 이용해서 MQTT v3.1 을 비주얼 (JavaScript) 프로그래밍했다. 비주얼 프로그래밍이라서 쉬울줄알았는데 생각보다 쉽지않았다. 각 펑션에 자바스크립트로 코딩해야기때문이다. 노드와 노드끼리 잘 연결할수있도록 context.global / context.flow 잘써서 센서 데이타를 전달해주어야기때문에 삽질 정말 많이했다. 약 3주 정도 삽집했었다. ..

mqtt-gas-vv01mqtt-gas-vv02

여기에 메시지 브로커 모스키토가 토픽 3개( ping, cpuTemp, 그리고 gasvalve) 물건(데이타)를 잘전달할수있도록 수령자에 소개해준다.  우편배달부 개념은 아닌것같다.  IBM에서 강의를 들을때 P2P, e-mail 전혀 틀리다고 들었다.  게시판 개념과 비슷하다고 볼수있다.

screenshot-2016-10-19-12-58-16

screenshot-2016-10-24-11-59-13

mqtt-gas-vv_phone-png

mqtt-gas-vv_web

Wireless IoT Networks

Wireless IoT Networks

In addition to Wi-Fi, the ARTIK development boards support a variety of low-power wireless interface options that are ideal for IoT applications. While each technology has its strengths and it is difficult to make precise comparisons, we offer the table below to provide an overview.

TECHNOLOGY DATA RATE RANGE APPLICATION
Bluetooth 1-3Mb/s 0.5-20m personal entertainment
Bluetooth BLE 1Mb/s 0.5-20m smart home, health/fitness
ZigBee 250kb/s 10-200m sensor monitoring
Thread 250kb/s 10-200m home automation
Z-Wave 40 or 100kb/s 10-200m home automation
SIGFOX 12 bytes/msg
140 msg/day
3-15km distant sensor monitoring

All of these technologies have an ultra low-power “sleep” mode when not active and most of the time are drawing current in the microamp range.

ZigBee, Thread, and Z-Wave are all appropriate choices for the home automation space, with Z-Wave having been around the longest. In their latest versions, all three have the ability to form mesh networks, with Thread having the most sophisticated ability to re-establish connectivity when a “child” is moved from one “parent” to another.

The Bluetooth, Bluetooth LE, and ZigBee circuitry is located on the ARTIK module itself; the Z-Wave modem is located on the development board. Refer to the SIGFOX article for information on its circuitry and use.

This documentation covers the hardware included in the Beta developer kit. Subscribe to our newsletter to receive updates on upcoming ARTIK releases.

Understanding Internet of Things

Everyone is eyeing the next big thing after the .com boom which will make riches. World has never being the same after advent of the internet. Investment gurus and statisticians may have many proposals to make but one thing is for sure, the next big move which will shape the century will depend on internet and embedded technology. That is, in other words internet of things definition is what interests major players now. What we do, how we do and when we do is never going to be the same when the physical environment around us gets lively and starts communicating.

The Internet of Things (IoT) is here and is becoming an increasing topic of interest among technology giants and business communities. The hype is not baseless as there are enough evidences to support the success of “Internet of Things” in the coming years. According to a report by Gartner there will be 30% increase in the number of connected devices in 2016 as compared to 2015 with 6.4 billion IoT devices entering the realm of internet of things. The number is further expected to increase to 26 billion by 2020.

 

BY 2020 IT IS EXPECTED THAT 26 BILLION DEVICES WILL BE PART OF INTERNET OF THINGS.

 

So one might simply ask “What is Internet of Things” and how it is going to impact our lives and career opportunities. There is a lot of complicated technology and terminologies at work in the IoT world but here I will try to keep things simple to explain the concept of Internet of Things easily.

Internet of Things Definition

IoT is simply the network of interconnected things/devices which are embedded with sensors, software, network connectivity and necessary electronics that enables them to collect and exchange data making them responsive.

More than a concept Internet of Things is essentially an architectural framework which allows integration and data exchange between the physical world and computer systems over existing network infrastructure.

Important Internet of Things Components

Many people mistakenly think of IoT as an independent technology. Interestingly internet of things is being enabled by the presence of other independent technologies which make fundamental components of IoT.

The fundamental components that make internet of things a reality are:

  • Hardware-Making physical objects responsive and giving them capability to retrieve data and respond to instructions
  • Software-Enabling the data collection, storage, processing, manipulating and instructing
  • Communication Infrastructure-Most important of all is the communication infrastructure which consists of protocols and technologies which enable two physical objects to exchange data

Get complete insight into fundamentals of internet of things here.

Why Internet of Things/IoT will be successful in the coming years?

 

s the telecommunication sector is becoming more extensive and efficient, broadband internet is widely available. With technological advancement it is now much cheaper to produce necessary sensors with built-in wifi capabilities making connecting devices less costly.

Most important, the smart phone usage has surpassed all the predicted limits and telecommunication sector is already working on its toes to keep their customers satisfied by improving their infrastructure. As IoT devices need no separate communication than the existing one building IoT tech is very cheap and highly achievable.

 

Internet of Things Infographic

understanding-internet-of-things-by-internetofthingswiki.com_1.jpeg

 

The Impact of Internet of Things on You

To put things simply any object that can be connected will be connected by the IoT. This might not make sense for you on the forefront but it is of high value. With interconnected devices you can better arrange your life and be more productive, safer, smarter and informed than ever before.

For instance how easy it will be for you to start your day if your alarm clock is not only able to wake you up but also able to communicate with your brewer to inform it that you are awake at the same time notifies your geezer to start water heating. Or you wearable wrist health band keeps track of your vitals to inform you when you are most productive during the day. These are just few examples but applications of internet of things are numerous.

On large scale transportation, healthcare, defence, environment monitoring, manufacturing and every other field you can imagine of can be benefited from IoT. It is very to conceive the whole application domain of internet of things at the moment but you can clearly understand why it is such an interesting and hot topic at the moment.

 

The Challenges of Internet of Things

Like any other technology there are challenges which make the viability of IoT doubtful. Security is one of the major concerns of experts who believe virtually endless connected devices and information sharing can severely compromise one’s security and well being. Unlike other hacking episodes which compromise online data and privacy with IoT devices can open gateway for an entire network to be hacked.

One such flaw is well presented by Andy Greenberg on wired.com where he works with hackers to remotely kill his Jeep on the highway. Another very relevant example is provided by W. David Stephenson in his post Amazon Echo: is it the smart home Trojan Horse?. You can estimate the amount of personal and private data the connected devices will be producing once they are on a network. The major challenge for IoT tech companies is to figure out how the communication in the internet of things realm can be made truly secure.

 

What to Expect

ANY OBJECT THAT CAN BE CONNECTED WILL BE CONNECTED BY THE IOT.

Internet of Things is truly a game changing concept and whatever challenges may be present, there will be rapid growth in the number of connected devices. There is still need for us to understand concepts of IoT and the flaws that are underlying. As more and more devices start to connect the need will force technocrats to come up with most advanced concepts and methods to ensure growth of this technology.

By the time what we can do best is to educate ourselves on various IoT technologies and keep experimenting with new stuff.

The Fundamental Components of The Internet of Things

With the changing scope of applications of internet shifting towards making physical world smarter there is no doubt that people will witness a shift in the number of connected devices soon. Within 5 years it is estimated that 50 billion devices will be online. What’s more interesting is of these devices the mostly will be conventional physical objects. PCs, laptops and smart devices which dominate the internet at present will be dwarfed by these physical objects. The prerequisites of Internet of Things are many. Still the main components can be categorized into three categories i.e. intelligence, sensing and communication.

Internet of Things is going to sustain a $14 trillion market which means scope of this tech is no very large. After understanding internet of things definition you should know about the fundamentals of IoT architecture which is important to start building applications and devices.

There is no limit to applications providedprerequisites of Internet of Things are met. Healthcare, personal security, home automation, industrial automation, traffic control and environment monitoring all can be done more efficiently using this IoT tech.

Intelligence and Sensing

Wireless networks are utmost important for the success of the IoT infrastructure. Sensors should be able to communicate without constraints of physical wiring. It makes them more independent as well as increases their domain use. Sensing of capabilities of the IoT nodes should not only be efficient but also exhibit power use efficiency. The smart connected devices will be lying down dormant for most of the period. They will activate only when there is need to read or send data or to make a decision. In simple words 90% of their time sensors will not need power for relaying data or carry out any high power-consuming function. This requires the intelligent hardware to have ultra-low energy consuming sleep mode capability. Many companies are already producing microcontrollers sporting this requirement.

 

WIRELESS CONNECTIVITY WITH LOW POWER CONSUMPTION IS VITAL FOR THE SUCCESS OF IOT.

 

One important factor affecting the power efficiency of IoT devices is the architecture. While 32bit cores low cost microcontrollers have the advantage of being more compatible to large number of open-source software still they have high power consumption. Atmel, Texas Instruments, Freescale, and STMicroelectronics are offering such microcontrollers that make application building very fast. However the 8-bit AVR platform from Atmel still makes it obvious that there is scope of improvement in existing architectures.

Smart Communication

To lower the power consumption by an IoT node only hardware changes is not the way. Smart communication protocols like ZigBee help in making exchange of data between devices less power consuming.

 

ZigBee

A low power consuming IEEE 802.15.4(2003) standard based specification, ZigBee is a brain child of 16 automation companies. What makes it novel is the use of mesh networking which makes utilization of communication resources much more efficient. ZigBee based IoT nodes can connect to central controller making use of in-between nodes for propagating the data. It makes transmission and handling of data robust.

Bluetooth Low Energy (BLE)

Nokia originally introduced this protocol as Wibree in 2006. Also known as Bluetooth Smart this protocol provides the same range coverage with much reduced power consumption as the original Bluetooth. It has similar bandwidth with narrow spacing as used by ZigBee. Low power latency and lower complexity makes BLE more suitable to incorporate into low cost microcontrollers.

 

LOW POWER LATENCY AND LOWER COMPLEXITY MAKES BLE MORE SUITABLE TO INCORPORATE INTO LOW COST MICROCONTROLLERS.   

 

As far as application is concerned BLE is in healthcare sector. As wearable health monitors are becoming prevalent the sensors of these devices can easily communicate with a smart phone or any medical instrument regularly using BLE protocol.

Wi-Fi

Counted as the most mature wireless radio technology, Wi-Fi is predominant communication technology chosen for IoT applications. Already existing protocols like WPS make the integration of internet of things devices easier with the existing network. If we talk about transmission then Wi-Fi offers the best power-per-bit efficiency. However power consumption when devices are dormant is much higher with conventional Wi-Fi designs. The solution is provided by protocols like BLE and ZigBee that reduce power consumption by sensors when devices are dormant.

The ideal solution is to mix the two technologies for optimum power utilization. GainSpan’s GS2000 is one such tech which used both ZigBee and Wi-Fi. It makes optimum use of power by putting the device into energy-saving standby mode when no data transmission is taking place. Only when device is awaked or checked for connection failure the high power consumption connection of Wi-Fi is used. BLE and Wi-Fi together can be used without interference as they are compliable to coexistence protocols. The Bluegiga APx4 is one such solution which supports both BLE and Wi-Fi and is based on 450MHz ARM9 processor.

Most important use of Wi-Fi is in the applications where IP stack compliance is needed and there is high data transmission. For instance in applications sharing audio, video or remote device controlling.

As the prerequisites of internet of things are scaling up, companies are working on more integrated solutions. But even at present there are many solutions available for anyone who is trying to build up internet of things applications around the major three IoT components. Vendors like Atmel, STMicroelectronics, Texas Instruments, CSR and Freescale are offering many integrated microcontrollers and support chipsets making application building a lot easier based on protocols like ZigBee, BLE and Wi-Fi.