How to implement Machine Learning on IoT based Data?

by Dec 17, 2020Projects


Introduction

The industrial scope for the convergence of the Internet of Things(IoT) and Machine learning(ML) is wide and informative. IoT renders an enormous amount of data from various sensors. On the other hand, ML opens up insight hidden in the acquired data. Moreover, ML analyses past behavior to identify the pattern and offers future prediction using different kinds of algorithms.

Components

The implementation of the project comprises three major parts as described.

  1. Internet of Things
  2. Data Logger
  3. Machine Learning

Architecture

IoT with ML architecture

1. Internet of Things

IoT part includes,

  • Sensors
  • An IoT device

Sensors – Firstly, Measurement of multiple parameters can be done using primary sensing elements or electronic sensors, For Project, DHT11(Temperature Humidity sensor).

An IoT device – After that, an IoT device is used to establish a stable connection with the Internet. In addition, it can make a connection with any data logger for data-storage and data-analysis. For Project, ESP8266(NodeMCU).

Circuit diagram

Circuit-diagram

Generally, DHT11 consists of three pins VCC, Data pin, and GND(ground). Interfacing of DHT11 with ESP8266 can be represented by connecting DHT11,

DHT11ESP8266
VCCVIN
Data pinD0
GNDGND
Connection between DHT11 and ESP8266

2. Data Logger

The main function of the data-logger is to store the acquired data with respective dates and timestamps in a server-based database. So that it could be accessed remotely. Moreover, based on the collected data logger provides specific features like,

  • Graphical Representation,
  • On-field and Off-field monitoring,
  • Mathematical analytics,
  • Future prediction of acquired data.

Google drive comes up with Google sheets in which data can be inserted using Google scripts over a network. Admin can publish Google sheets via Google scripts as a web app.

3. Machine Learning

The main aim of Machine Learning is to observe data and perceive upcoming events. It provides systems the ability to learn automatically and control actions over the measuring variable so that it does not exceed the limit.

The Random Forest algorithm is one of the most popular algorithms that works on a supervised technique. It can be used for both Classification and Regression problems in ML. Above all, It is based on the concept of ensemble learning. In other words, it is a process of combining multiple classifiers to solve a complex problem and to improve the performance of the model.

Working diagram

Random forest Algorithm

Firstly, It applies 75% of the data to the Training set and the remaining 25% of the data to the Test Set. Consequently, the decision tree comes up, and at the end prediction takes place with ±error and specific percent of accuracy.

Source – JavaTpoint

Working and Code Implementation

Part-I (Data Logger)

First of all open Data-logger for the project, Google sheets from Google drive account.

Open Google Sheets

Rename your sheet and give names to the 1st row of the spreadsheet as described below.

Step_2

Open Google scripts from Tools–Script editor.

Step_3

Insert the code in Google scripts.

Part-II (IoT)

After that start measurement of the temperature using DHT11. DHT11 contains in the structure NTC temperature sensor(Thermistor) to measure surrounding temperature. Measurement of the temperature includes three parts,

Request to DHT11 – Microcontroller unit (For instance, ESP8266 board) sends low to high pulse as a request to DHT11. Respond from DHT11 – After receiving the request DHT11 sends low to high pulse as a response to the ESP8266 board. Data transmission – At last, data transmission from DHT11 to the ESP8266 board done in 5 bytes(40 bits).

2 bytes for RH(Relative Humidity), 2 bytes for Temperature, and 1 byte for checksum which checks whether the data is received or not.

Source code

After making circuit connections as per the circuit diagram given above and managing board and library setting upload the code given below in Arduino IDE.

As a result, Output of the code in Serial Monitor of Arduino IDE.

Serial-monitor

Part-III (Machine Learning)

In the end, after gathering a large amount of the data at the end apply machine learning online using Python from Jupyter Notebook.

Jupyter Notebook

Jupyter Notebook2

After downloading the acquired data Google sheet Excel file, open it in Jupyter Notebook. Subsequently, In the terminal install the XLRD.

Open Code

Xlrd_error2

At the end open the given python code file into the Jupyter Notebook. Most importantly, change your excel file name.

Consequently, Prediction after Machine Learning,

Prediction

Actual Temperature

So basically I have collected the temperature data of Basel, Switzerland from 1st January 2019 to 31st October 2020. After that implemented machine learning on that data in python and made the prediction of the temperature.

In the above two photos, the left side photo is representing the predicted temperature of 25th November 2020 based on machine learning with ±4 °C error and the right side photo refers to the actual temperature on the same day.

Applications

Applications

Creating a multiplication Skill in Alexa using python

Written By Monisha Macharla

Hi, I'm Monisha. I am a tech blogger and a hobbyist. I am eager to learn and explore tech related stuff! also, I wanted to deliver you the same as much as the simpler way with more informative content. I generally appreciate learning by doing, rather than only learning. Thank you for reading my blog! Happy learning!

RELATED POSTS

How to Simulate IoT projects using Cisco Packet Tracer

How to Simulate IoT projects using Cisco Packet Tracer

In this tutorial, let's learn how to simulate the IoT project using the Cisco packet tracer. As an example, we shall build a simple Home Automation project to control and monitor devices. Introduction Firstly, let's quickly look at the overview of the software. Packet...

How to design a Wireless Blind Stick using  nRF24L01 Module?

How to design a Wireless Blind Stick using nRF24L01 Module?

Introduction Let's learn to design a low-cost wireless blind stick using the nRF24L01 transceiver module. So the complete project is divided into the transmitter part and receiver part. Thus, the Transmitter part consists of an Arduino Nano microcontroller, ultrasonic...

Smart Display Board based on IoT and Google Firebase

Smart Display Board based on IoT and Google Firebase

Introduction In this tutorial, we are going to build a Smart Display Board based on IoT and Google Firebase by using NodeMCU8266 (or you can even use NodeMCU32) and LCD. Generally, in shops, hotels, offices, railway stations, notice/ display boards are used. They are...

Smart Gardening System – GO GREEN Project

Smart Gardening System – GO GREEN Project

Automation of farm activities can transform agricultural domain from being manual into a dynamic field to yield higher production with less human intervention. The project Green is developed to manage farms using modern information and communication technologies....

How to build a Safety Monitoring System for COVID-19

How to build a Safety Monitoring System for COVID-19

It is expected that the world will need to battle the COVID-19 pandemic with precautious measures until an effective vaccine is developed. This project proposes a real-time safety monitoring system for COVID-19. The proposed system would employ an Internet of Things...

Air Quality Monitoring using NodeMCU and MQ2 Sensor – IoT

Air Quality Monitoring using NodeMCU and MQ2 Sensor – IoT

There have been many incidents like explosions and fire due to certain gases leakage. Such incidents can cause dangerous effects if the leakage is not detected at an early stage. Therefore, Measurement and control of these types of toxic gases present in the...

VIDEOS – FOLLOW US ON YOUTUBE

EXPLORE OUR IOT PROJECTS

IoT Smart Gardening System – ESP8266, MQTT, Adafruit IO

Gardening is always a very calming pastime. However, our gardens' plants may not always receive the care they require due to our active lifestyles. What if we could remotely keep an eye on their health and provide them with the attention they require? In this article,...

How to Simulate IoT projects using Cisco Packet Tracer

In this tutorial, let's learn how to simulate the IoT project using the Cisco packet tracer. As an example, we shall build a simple Home Automation project to control and monitor devices. Introduction Firstly, let's quickly look at the overview of the software. Packet...

All you need to know about integrating NodeMCU with Ubidots over MQTT

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

All you need to know about integrating NodeMCU with Ubidots over Https

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

How to design a Wireless Blind Stick using nRF24L01 Module?

Introduction Let's learn to design a low-cost wireless blind stick using the nRF24L01 transceiver module. So the complete project is divided into the transmitter part and receiver part. Thus, the Transmitter part consists of an Arduino Nano microcontroller, ultrasonic...

Sending Temperature data to ThingSpeak Cloud and Visualize

In this article, we are going to learn “How to send temperature data to ThingSpeak Cloud?”. We can then visualize the temperature data uploaded to ThingSpeak Cloud anywhere in the world. But "What is ThingSpeak?” ThingSpeak is an open-source IoT platform that allows...

Amaze your friend with latest tricks of Raspberry Pi and Firebase

Introduction to our Raspberry Pi and Firebase trick Let me introduce you to the latest trick of Raspberry Pi and Firebase we'll be using to fool them. It begins with a small circuit to connect a temperature sensor and an Infrared sensor with Raspberry Pi. The circuit...

How to implement Machine Learning on IoT based Data?

Introduction The industrial scope for the convergence of the Internet of Things(IoT) and Machine learning(ML) is wide and informative. IoT renders an enormous amount of data from various sensors. On the other hand, ML opens up insight hidden in the acquired data....

Smart Display Board based on IoT and Google Firebase

Introduction In this tutorial, we are going to build a Smart Display Board based on IoT and Google Firebase by using NodeMCU8266 (or you can even use NodeMCU32) and LCD. Generally, in shops, hotels, offices, railway stations, notice/ display boards are used. They are...

Smart Gardening System – GO GREEN Project

Automation of farm activities can transform agricultural domain from being manual into a dynamic field to yield higher production with less human intervention. The project Green is developed to manage farms using modern information and communication technologies....