Skip to content

Project

Task 1

Research

The Internet of Things (IoT):

The Internet of Things (IoT) is changing how we live, work, travel, and do business. It is even the basis of a new industrial transformation, known as Industry 4.0, and key in the digital transformation of organizations, cities, and society overall. Industry 4.0 takes the emphasis on digital technology from recent decades to a whole new level with the help of interconnectivity through the Internet of Things (IoT).

IOT is a giant network of connected devices. These devices gather and share data about how they are used and the environment in which they are operated. It’s all done using sensors, sensors are embedded in every physical device. It can be your mobile phone, appliances, barcode sensors, traffic lights and almost everything that you come across. These sensors continuously emit data about the working state of the devices.

IOT provides a common platform (internet) and language (protocols) for all devices to communicate with each other. Data is emitted from various sensors and sent to the IOT platform. The IOT platform integrates the collected data from various sources. Further analytics is performed on the data and valuable information is extracted as per request. The result is shared with other devices for better user experience automation and improved efficiencies.

IoT Is A Game Changer For Travelers With Connected RVs.

Perhaps the biggest difference IoT has made to RV travel is increased security, allowing travelers peace of mind when they’re camping in isolated spots. Because the majority of RV travelers use their vehicle on vacation, convenience is often a priority. They want to be able to explore their destination without worrying about domestic arrangements. IoT makes this much easier, and linking energy supplies and thermostats to their networks allows them to keep a track of the system remotely. Many systems allow users to control the temperature and lighting from their smart devices, allowing them to warm the vehicle up for the evening in advance of getting back from a long day out. The features which is possible because of IOT also give owners confidence in leaving their vehicles in covered RV ports when they’re not using them.

Here is an example of a system using which you can easily monitor many things in your RV with multiple wireless sensors: RV Monitor Station

IOT Is Changing The Way We Live.

Smart Homes are one example of IOT, which is changing the way we live.  Home Automation, often referred to as “Smart Home Technology”, is the use of technology to automate your home. Home automation allows you to control almost every aspect of your home through the Internet of Things (IoT). The concept of Home Automation aims to bring the control of operating your every day home electrical appliances to the tip of your finger, thus giving user affordable lighting solutions, better energy conservation with optimum use of energy. Apart from just lighting solutions, the concept also further extends to have a overall control over your home security as well as build a centralised home entertainment system and much more. The Internet of Things (IoT) based Home Automation system, aims to control all the devices of your smart home through internet protocols or cloud based computing.The IoT based Home Automation system offer a lot of flexibility over the wired systems as it comes with various advantages like ease-of-use, ease-of-installation, avoid complexity of running through wires or loose electrical connections, easy fault detection and triggering and above and all it even offers easy mobility. IoT based Home Automation system consist of a servers and sensors. These servers are remote servers located on Internet which help you to manage and process the data without the need of personalised computers. The internet based servers can be configured to control and monitor multiple sensors installed at the desired location.

Home automation main parts, sensors, protocols, architectures, gateways, and platforms are briefly described here: Home Automation Using the Internet of Things (IoT)

Nodes:

A node is a point of intersection/connection within a data communication network. In an environment where all devices are accessible through the network, these devices are all considered nodes.

IOT protocols:

IoT protocols are an integral part of the IoT technology stack. Without IoT protocols and standards, hardware would be deemed useless. This is because IoT protocols enable hardware to exchange data. And, out of these transferred pieces of data, useful information can be extracted by the end-user.

Some most commonly used IoT protocols:

MQTT:

MQTT (Message Queuing Telemetry Transport) is an OASIS standard messaging protocol for the Internet of Things (IoT). It is designed as an extremely lightweight publish/subscribe messaging transport that is ideal for connecting remote devices with a small code footprint and minimal network bandwidth.

AMQP:

AMPQ (Advanced Message Queuing Protocol) is an open standard protocol designed to be used for transactional messages between two or more servers. AMQP’s main functions are message storage, receiving and placing messages into queues, and creating relationships between these components.

CoAP:

CoAP (Constrained Application Protocol ) is a specialized web transfer protocol for use with constrained nodes and constrained networks in the Internet of Things. CoAP is designed to enable simple, constrained devices to join the IoT even through constrained networks with low bandwidth and low availability.

API:

An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. In the context of APIs, the word Application refers to any software with a distinct function. Interface can be thought of as a contract of service between two applications. This contract defines how the two communicate with each other using requests and responses.

Microprocessors:

ESP32:

ESP32 is a low-cost, low-power system on a chip (SoC) series with Wi-Fi & dual-mode Bluetooth capabilities.ESP32 is highly integrated with built-in antenna switches, RF balun, power amplifier, low-noise receive amplifier, filters, and power management modules. Engineered for mobile devices, wearable electronics, and IoT applications, ESP32 achieves ultra-low power consumption through power saving features including fine resolution clock gating, multiple power modes, and dynamic power scaling.

ESP8266:

It is a cost-effective and highly integrated Wi-Fi MCU for IoT applications. The ESP8266 WiFi Module is a self contained SOC with integrated TCP/IP protocol stack that can give any microcontroller access to your WiFi network. The ESP8266 is capable of either hosting an application or offloading all Wi-Fi networking functions from another application processor. Each ESP8266 module comes pre-programmed with an AT command set firmware, meaning, you can simply hook this up to your Arduino device and get about as much WiFi-ability as a WiFi Shield offers (and that’s just out of the box)! The ESP8266 module is an extremely cost effective board with a huge, and ever growing, community.

Choosing the right IoT protocol.

Choosing the right protocol in a given situation is key to an application’s success or failure, as an unsuitable wireless technology can cripple key aspects of the application’s performance and render it unusable. Choosing the wrong protocol can also cause headaches down the line by restricting what you can do with your hardware and affect its performance.

Testing AMQP:

We started testing Iot protocols with AMQP, because we thought this protocol would be more suitable for our project.

How Does It Work?

AMQP refers to Advanced Message Queuing Protocol is a globally recognized standard that works on the application layer essentially, it is mainly used for developing unmatched communication operability between client and broker parties. The publisher bears the responsibility of message generation while clients collect and administer them. The role of brokers, such as RabbitMQ, in this whole process is to make a sure message, part of the exchange, goes directly from the publisher to the client. Speaking of its key functionality, routing, message orientation, and queuing are the top ones. Use of AMQP makes interoperability an achieved goal, featuring different configurations and infrastructure. It allows developers to bring all the protocol-approved compliant client library and broker offered into action.

Components of AMQP:

  1. Exchanges: Exchange handles the responsibility of fetching messages and placing them carefully in the right queue. Its 4 categories are: Fanout, Headers, Topic, and Direct. It is an indispensable component of the broker.
  2. Channel: Channel refers to a multiplexed virtual connection among AMQP peers, which is built inside an existing connection.
  3. Message Queue: It is an identified entity that helps link messages with their resources or point of origin.
  4. Binding: Bindings denote a set of predefined instructions related to queues as well as exchanges. It administers the sending of message and their delivery.
  5. Virtual Hosts: vhost is a platform offering the segregation facility inside the broker. Based upon users and their access rights, there could be multiple vhost functional at a time.

Here are more details about how AMPQ works: How AMQP works?

RabbitMQ

RabbitMQ is a message-queueing software also known as a message broker or queue manager. It is software where queues are defined, to which applications connect in order to transfer a message or messages. It is lightweight and easy to deploy on premises and in the cloud. It supports multiple messaging protocols. RabbitMQ can be deployed in distributed and federated configurations to meet high-scale, high-availability requirements. RabbitMQ

AMQP is the core protocol for RabbitMQ (a Message Broker), but it also supports STORM, MQTT and HTTP through the use of plugins. Here is a quick guide to understand AMQP and RabbitMQ: RabbitMQ & AMQP

The RabbitMQ Management

RabbitMQ provides provides an HTTP-based API for the management and monitoring of your RabbitMQ server. From the management interface, it is possible to handle, create, delete and list queues. It is also possible to monitor queue length, check message rate, or change and add users permissions and much more. By default, RabbitMQ listen on port 5672 on all available interfaces.

Hello World!

To wrote a simple Hello world program. First of all, we downloaded Python from here: Download Python

We had to use Pika 1.0.0, which is the Python client recommended by the RabbitMQ team. To install it we used the pip package management tool:

python -m pip install pika --upgrade

Now we had Pika installed, we wrote some code in Visual Studio Code (In Visual Studio Code we downloaded some pakages to write Python code).

Code

send.py

#!/usr/bin/env python
import pika

connection = pika.BlockingConnection(
    pika.ConnectionParameters(host='localhost'))
channel = connection.channel()

channel.queue_declare(queue='hello')

channel.basic_publish(exchange='', routing_key='hello', body='Hello World!')
print(" [x] Sent 'Hello World!'")
connection.close()

receive.py

#!/usr/bin/env python
import pika, sys, os

def main():
    connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
    channel = connection.channel()

    channel.queue_declare(queue='hello')

    def callback(ch, method, properties, body):
        print(" [x] Received %r" % body.decode())

    channel.basic_consume(queue='hello', on_message_callback=callback, auto_ack=True)

    print(' [*] Waiting for messages. To exit press CTRL+C')
    channel.start_consuming()

if __name__ == '__main__':
    try:
        main()
    except KeyboardInterrupt:
        print('Interrupted')
        try:
            sys.exit(0)
        except SystemExit:
            os._exit(0)

We received messages in rabbitmq, but it took so much time because so many things were running on the same raspberry pi.


Task 2

IoT Architecture

Architecture is the group of rules and guidelines that determine how components must behave with each other in a system in order to reach a specific goal. In other words, it’s a blueprint for the implementation of computer systems, how they are organized, and how they function.

IoT architecture consists of the devices, network structure, and cloud technology that allows IoT devices to communicate with each other. Architecture in IoT is a framework that defines: - How the physical components behave (IoT devices). - How the network is configured for communication. - How the data is handled (how it’s stored and gathered). - What procedures are executed for operation. - How the system is organized. - How the system functions.

layers

IoT architecture is defined and categorized in what is called “layers”. Since there is no clear consensus of what IoT architecture entails, different IoT developers and manufacturers define these categories differently, and some include more layers than others. In general, everyone agrees that layers differ from one another in what functional area they fall into. In a nutshell, IoT architecture consists of smart devices that gather data, networks that allow for communication between devices, middleware IoT platforms, and applications that users can use to interact with the IoT system.

Developing an IOT platform

Connecting to Rasberry Pi

The Raspberry Pi is a low cost series of small single-board computers, computer that runs Linux, but it also provides a set of GPIO (general purpose input/output) pins, allowing you to control electronic components for physical computing and explore the Internet of Things (IoT).

To connect to Raspberry Pi remotely via SSH from our laptop we downloaded PuTTY Application from here.

PuTTY is one of the most widely used open-source SSH clients used to connect to Cloud server, Networking devices, and Virtual private servers. It can also allow users to remotely access computers over SSH, Telnet, Rlogin network protocols and remains a standard tool to connect with remote devices for a number of years. It supports several network protocols, including SCP, SSH, Telnet, rlogin, and raw socket connection. It can also connect to a serial port.

Docker

After connected to Rasberry Pi, we followed this tutorial to install Docker on Rasberry Pi.

Docker is an open source platform that enables developers to build, deploy, run, update and manage containers—standardized, executable components that combine application source code with the operating system (OS) libraries and dependencies required to run that code in any environment.Docker allows you to isolate applications from a local infrastructure. This makes software deployment faster, easier and more secure. It provides a portable and consistent runtime environment for software applications.


Task 3

Creating a webapplication using React js and express js

React Js Frontend

React is one of the most popular and widely used libraries (it’s not a framework) for frontend development. To give you a gentle introduction, React is an open-source JavaScript library used for frontend development, which was developed by Facebook.

Installing create-react-app

npm install -g create-react-app

Creating the application

npx create-react-app reactapp

Starting the application

cd reactapp
npm start

Creating API call

import React from 'react';
import logo from './logo.svg';
import './App.css';
function App() {
  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App.js</code> and save to reload.
        </p>
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React
        </a>
      </header>
    </div>
  );
}
export default App;
import React, { Component } from 'react';
class App extends Component {
  render() {
    return (
      <p>Hello world!</p>
    );
  }
}
export default App;

Express Js Backend

Express. js is a Node js web application server framework, which is specifically designed for building single-page, multi-page, and hybrid web applications. It has become the standard server framework for node. js. Express is the backend part of something known as the MEAN or MERN stack.


Last update: September 11, 2022