HOW TO BUILD IOT DEVICES AND APPLICATIONS USING ARDUINO AND PYTHON

This article is prepared to help you understand the basis of IoT devices and to give you a clue of how to build them using arduino and Python and how arduino and python serial communication works.

Article Content

•    Introduction
      IoT
      Embedded Systems
      Arduino
•    IoT Protocols

      MQTT
      PlainTalk
•    OpenIoT System Architecture
•    Demonstration
 
how to build iot devices and applications using arduino and python

What is IoT

•    The Internet of Things (IoT) is the network of physical objects—devices, vehicles, buildings and other items—embedded with electronics, software, sensors, and network connectivity that enables these objects to collect and exchange data.

•    IoT allows objects to be sensed and controlled remotely across existing network infrastructure.


Click the link to download the PDF copy of  this article for free: HOW TO BUILD IOT DEVICES AND APPLICATIONS USING ARDUINO AND PYTHON.

See Also: INDUSTRIAL AUTOMATION USING PROGRAMMABLE LOGIC CONTROLLER (PLC)

See Also: LONG TERM EVOLUTION TECHNOLOGIES, 3G AND 4G

Introduction

•    We are at the brink of a new Industrial revolution, one characterised by Cyber- Physical Systems. It is the 4th Industrial revolution

•    1st: Steam Engine - Mechanisation


•    2nd: Electricity - Mass production


•    3rd: Computer and Automation


•    Estimated spending on IoT by 2020 is $6T.


•    It is the next big business and employment opportunity.

IoT Applications

•    Environmental Monitoring
•    Home and Building Automation
•    Manufacturing
•    Infrastructure Management
•    Medical and healthcare systems
•    Transportation

IoT Components

•    Physical objects: Things that can sense or affect the physical environment.

•    Virtual objects: e.g. electronic tickets, id cards, wallets.


•    People - humans who control the environment via mobile apps.


•    Services: e.g. cloud services used to optimize business processes by integrating device data.


•    Platforms: middleware used to connect IoT components together.


•    Networks: various wireless and wire line technologies, standards, and protocols.

IoT Platform provides

•    Access to devices
•    Ensure proper installation/behaviour of device
•    Data analytics
•    Interoperable connection to local network, cloud or other devices.

Embedded Systems

•    Embedded Systems: a computer system with a dedicated function within a larger system, often with real-time constraint.

•    Examples: washing machines, Automobile, TV-sets, Microwave ovens.

Common Embedded Platforms

•    8-bit Microcontrollers such as 8051, PIC, AVR
•    32-bit Arm Microcontroller, the Cortex-M family
•    DSPs
•    FPGAs

Arduino

•    An IDE that simplifies embedded system development on the AVR platform.
•    It is very good for prototyping.

What is OpenIoT?

•    OpenIoT is an open source framework that covers the entire IoT stack, right from devices, to mobile phone apps, to gateways and cloud service.

•    OpenIoT is the framework that enables everyone to built their own IoT systems with ease.

OpenIoT objectives

•    Enable hobbyists to create IoT devices in minutes and provide an easy path for them to go commercial.

•    Provide a full stack that is free (as in freedom) and mostly free (as in free beer), that developers can adopt and extend.


•    Platform should be be easily interoperable with other leading products and frameworks.


•    Low cost, high performance and ease of use.

Arduino Architecture

Arduino Architecture

·        OpenIoT deploys as a distributed system or system of systems.
·        The gateway is at the heart of the OpenIoT system and is responsible for coordinating communication between nodes and also between nodes and the cloud.
·        It is also responsible for auto-discovery which enables automatic enumeration of all nodes and their capabilities on the OpenIoT system.

The Node and Demonstrations

·        The nodes are the endpoints of the system.
·        Each node is a specialized hardware that is designed to carry out a specific task such as measurement or actuation.
·        A node is a device that has one or two input and/or output ports.

The network

·        Wifi
·        Zigbee
·        rs485
·        uar

Software Architecture

The schematic diagram below shows the IoT software architecture. 


IoT software architecture

 Software

•    The software consists of application software on a smartphone, a command processor and a scripting (rules) engine running on the gateway, and embedded software on the nodes.
•    OpenIoT supports Applications targeting different platforms including smartphones (android and iOS), PC, Macintosh and Linux as well as web (html5) applications.

IoT Protocols

•    HTTP
•    Web socket
•    XMPP
•    CoAP
•    MQTT

PlainTalk

•    PlainTalk is a custom protocol designed for OpenIoT.
•    Easy processing by microcontrollers and human readable.
•    Helps to separate the IoT device implementation from communication network and protocols.
•    Most of the communication functions can be moved to the gateway, thereby allowing low cost microcontrollers to be used as nodes.
•    Usually uses the MCUs serial port.
•    You can directly use PlainTalk to talk to an OpenIoT node by connecting the node’s serial I/O to your computers USB port through a uart-USB cable.

PlainTalk Format

The PlainTalk format is as follows NODE Command parameter sender
•    Where NODE is the name of the node the command is meant for.
•    And sender is the sender of the command or the node that should receive the response.
Example
To send the value ‘1’ to port 4 of NODE002, type the following:
NODE002 setportvalue 4 1 remote

How auto discovery and auto layout works

When a node is first switched on, it announces its presence by repeatedly sending a command to the gateway to identify itself. The nodename for the gateway is cp.

For example: cp ThisIs NODE002
The gateway responds by sending:
NODE002 ack cp


This switches the NODE into normal mode and stops the annunciation.


To determine to nodes that are currently registered by the gateway you can send:
Cp getnodes remote

Demonstrations

Nodes are characterized by the number and nature of ports they are equipped with. OpenIoT supports auto-configuration and nodes must be able to provide details about their ports when queried. 

In order to determine the number of ports on a node, we send:
NODEE002 getnoports remote

 
The ports are numbered 0, 1, 2,… To deermine the nature of any particular port we send:
NODE002 getportproperties 1 remote
Where ‘1’ is the port number.


We can set the value of a port by sending:
NODE002 setportvalue 1 0 remote
This sets the value of port ‘i’ of NODE002 to zero.


We can determine the value of a port by sending:
NODE002 getportvalue 1 remote
This queries the value of port ‘1’.


See Also: INDUSTRIAL AUTOMATION USING PROGRAMMABLE LOGIC CONTROLLER (PLC)

See Also: LONG TERM EVOLUTION TECHNOLOGIES, 3G AND 4G

Click the link to download the PDF copy of  this article for free: HOW TO BUILD IOT DEVICES AND APPLICATIONS USING ARDUINO AND PYTHON


By: Ahmad Sadiq
Company: Microscale Embedded
Email: ahmad@microscale.net

Hope you learnt a lot from this article? Comment below if you have any confusion. Don’t forget to share this article with your friends. Also subscribe to get our latest posts.

Share this

Related Posts

Previous
Next Post »

WHAT'S ON YOUR MIND?
WE LOVE TO HEAR FROM YOU!

Like Our Page Today