You are on page 1of 22

K.L.N.

COLLEGE OF ENGINEERING
POTTAPALAYAM - 6 3 0 6 1 2

(AN ISO 9001:2015 CERTIFIED INSTITUTION –


AFFILIATED TO ANNA UNIVERSITY, CHENNAI)

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

FOR VII SEMESTER


ELECTRONICS AND COMMUNICATION ENGINEERING
(Odd Semester 2022 - 2023)
20EC703-IOT ENABLED SYSTEM DESIGN

Compiled By

Prof. S. INDUMATHI, Associate Professor/ECE

Prof. Dr.P.KARPAGAVALLI, , Associate Professor / ECE


20CE703- IOT ENABLED SYSTEM DESIGN

SYLLABUS

LIST OF EXPERIMENTS

1.Study of different operating systems and installation for Raspberry Pi

2.Interface various sensors and communication modules with Raspberry Pi.

3.Write a server application to interface IoT protocols and cloud by using data analytics

4.Interface the Raspberry Pi with cloud to trans-receive data from sensors and actuators

5.Design business model and deploy Home Automation using Raspberry Pi


Expt-1 STUDY OF DIFFERENT OPERATING SYSTEMS AND
INSTALLATION FOR RASPBERRY PI

AIM: To Study different operating systems and installation for Raspberry Pi

THEORY:

WHAT IS RASPBIAN?

 Raspbian is a Debian-based computer operating system for Raspberry Pi. Since 2015 till now it is
officially provided by the Raspberry Pi Foundation as the primary operating system for the family of
Raspberry Pi single-board computers.
 Raspbian was created by Mike Thompson and Peter Green as an independent project.
 The initial build was completed in June 2012.
 He operating system is still under active development.
 Raspbian is highly optimized for the Raspberry Pi line's low-performance ARM CPUs
 Raspbian uses PIXEL, Pi Improved Xwindows Environment, Lightweight as its main desktop
environment as of the latest update.
 It is composed of a modified LXDE desktop environment and the Open-box stacking window manager
with a new theme and few other changes.
 The distribution is shipped with a copy of computer algebra program Mathematica and a version of
Minecraft called Minecraft Pi as well as a lightweight version of Chromium as of the latest version .

DOWNLOAD
BASIC FEATURES

Developer Raspberry Pi Foundation

OS family Unix-like

Source model Open source

Latest release Raspbian Jessie with PIXEL / 16.02.2017

Marketing target Raspberry Pi

Update method APT

Package manager dpkg

Platforms ARM

Kernel type Monolithic

Userland GNU

Default user interface PIXEL, LXDE

License Free and open-source software licenses (mainly GPL)

Official website https://www.raspberrypi.org/downloads/raspbian/

GUI
HOW TO WRITE DISK IMAGE?

FINALIZATION

• Complete the disk image writing process.

• Now insert the SD card in Raspberry Pi.

• Plug-in the power supply to the kit.

PROGRAMMING LANGUAGES

• Python [Recommended for coding]

•C

• C++

• Java

• Scratch
SOFTWARE MANAGEMENT ON PI

• sudo apt-get update

• sudo apt-get upgrade

• sudo apt-get install <package>

• sudo apt-get download <package>

• sudo apt-get remove <package>

• sudo apt-get purge <package>

• sudo apt-get dist-upgrade

ACCESSING PI IN LINUX

• The Rpi can be accessed in Linux terminal by secure shell.

• ssh pi@raspberrypi

• ssh pi@192.168.1.3

• The Pi GUI can be accessed using VNC server.

REFERENCES

Web Resources http://mitu.co.in,http://tusharkute.com

Blogs http://digitallocha.blogspot.in,http://kyamputar.blogspot.in

RESULT: Thus, the Raspberry pi installation and its different operating systems have been studied
successfully.
EXPT-2 INTERFACE VARIOUS SENSORS AND COMMUNICATION
MODULES WITH RASPBERRY PI

AIM: To Interface various sensors and communication modules with Raspberry Pi. Here we are
experimenting this using ultra sonic sensor

APPARATUS REQUIRED:

 Raspberry pi 3B+
 Ultrasonic sensor
 Breadboard
 Wires
 Resistors.

CIRCUIT DIAGAM:
PROGRAM CODE:

PROCEDURE:

 Identify the sensors and communication modules: Determine the specific sensors and communication
modules you want to interface with your Raspberry Pi 3B+. This could include sensors like
temperature, humidity, motion, or any other desired modules such as Bluetooth, Wi-Fi, or GSM.

 Check compatibility: Ensure that the sensors and communication modules you have chosen are
compatible with the Raspberry Pi 3B+. Verify the technical specifications and ensure that they use
compatible communication protocols such as GPIO, I2C, SPI, UART, or USB.

 Connect the hardware: Connect the sensors and communication modules to the Raspberry Pi 3B+. Use
the appropriate cables or connectors based on the communication protocol supported by each module.

 Install required software libraries: Install the necessary software libraries or drivers required to
interface with the sensors and communication modules. Most sensor manufacturers provide software
libraries or APIs that can be used to access sensor data. Install these libraries or drivers on your
Raspberry Pi 3B+ by following the manufacturer's instructions.
 Write code to interface with the modules: Use a programming language like Python to write code that
interacts with the sensors and communication modules. Refer to the documentation or examples
provided by the sensor manufacturers or the Raspberry Pi community for guidance on how to access
sensor data or control the communication modules.

 Test and integrate: Run your code on the Raspberry Pi 3B+ and test the interface with the sensors and
communication modules. Verify that you can successfully read data from the sensors or send/receive
data using the communication modules. Make any necessary adjustments or modifications to your code
as needed.

SOME OTHER SENSORS THAT CAN BE USED

1.BLUETOOTH

A Bluetooth sensor is a wireless device that utilizes Bluetooth


technology to transmit data to compatible devices such as
smartphones, tablets, or microcontrollers. These sensors are compact
and can measure various parameters like temperature, humidity,
motion, or proximity.

By establishing a Bluetooth connection, they enable real-time


monitoring, data logging, and analysis. Bluetooth sensors are widely
used in applications such as home automation, healthcare monitoring,
fitness tracking, industrial automation, and environmental monitoring.

They offer a convenient and wire-free solution, allowing easy


integration into existing systems and enabling remote access to sensor
data for efficient control and monitoring purposes

2. HUMIDITY SENSOR

A humidity sensor is a device designed to measure and monitor


the level of moisture or humidity in the surrounding
environment. It detects and quantifies the amount of water vapor
present in the air or other substances.

These sensors are commonly used in various applications such


as weather monitoring. They provide valuable information for
maintaining optimal conditions, safety in indoor and outdoor
environments. By accurately measuring humidity levels, these
sensors help in making informed decisions and implementing
effective control strategies.

RESULT: Thus, interfacing various sensors with raspberry pi has been executed successfully.
.

EXPT -3 WRITE A SERVER APPLICATION TO INTERFACE IOT PROTOCOLS AND CLOUD


BY USING DATA ANALYTICS

AIM: To Write a server application to interface IoT protocols and cloud by using data analytics

APPARAUS REQUIRED:

 Raspberry pi 3B+
 Cloud Account
 A data analytics tool (Tableau,Excel)

CIRCUIT DIAGRAM:
PROGRAM

import sqlite3

import time

import random

# Step 1: Define Requirements - Choose IoT Protocol (Simulate data for example)

# For simplicity, we will simulate IoT data using random numbers.

# Step 2: Set Up the IoT Interface

class IoTDevice:

def get_data(self):

# Simulate IoT data: Replace this with actual data retrieval logic

temperature = random.uniform(20, 30)

humidity = random.uniform(40, 60)

return temperature, humidity

# Step 3: Data Storage

class DataStorage:

def __init__(self):

self.conn = sqlite3.connect('iot_data.db')

self.create_table()

def create_table(self):

# Create a table to store IoT data if it doesn't exist


with self.conn:

self.conn.execute('''CREATE TABLE IF NOT EXISTS iot_data (id INTEGER PRIMARY KEY


AUTOINCREMENT, timestamp INTEGER, temperature REAL, humidity REAL)''')

def store_data(self, timestamp, temperature, humidity):

# Store IoT data in the database

with self.conn:

self.conn.execute('INSERT INTO iot_data (timestamp, temperature, humidity) VALUES (?, ?, ?)',

(timestamp, temperature, humidity))

# Step 4: Data Analytics (Simple example)

def analyze_data(data):

# Perform simple analytics on the data (e.g., calculating average temperature and humidity)

temperatures = [entry[1] for entry in data]

humidities = [entry[2] for entry in data]

avg_temperature = sum(temperatures) / len(temperatures)

avg_humidity = sum(humidities) / len(humidities)

return avg_temperature, avg_humidity

# Step 5: Main Function to Run the Experiment

if __name__ == '__main__':

iot_device = IoTDevice()

data_storage = DataStorage()

try:

while True:

timestamp = int(time.time())
temperature, humidity = iot_device.get_data()

# Step 2: IoT Interface - Receive data from IoT device (simulated)

print(f"Received data - Timestamp: {timestamp}, Temperature: {temperature}, Humidity:


{humidity}")

# Step 3: Data Storage - Store data in the database

data_storage.store_data(timestamp, temperature, humidity)

# Step 4: Data Analytics - Retrieve data from the database and perform analysis

with data_storage.conn:

cursor = data_storage.conn.execute('SELECT * FROM iot_data')

data = cursor.fetchall()

if len(data) > 0:

avg_temperature, avg_humidity = analyze_data(data)

print(f"Average Temperature: {avg_temperature}, Average Humidity: {avg_humidity}")

time.sleep(5) # Wait for 5 seconds between data points (simulating real-time data)

except KeyboardInterrupt:

print ("Experiment terminated by the user.")


PROCEDURE:

Step 1: Define Requirements and Goals

 Clearly define the project's objectives, including the IoT data you want to collect and analyze, the
type of analytics you'll perform, and the cloud platform (if any) you'll use.

Step 2: Choose IoT Protocols

 Decide on the IoT communication protocols you want to support (e.g., MQTT, CoAP, HTTP) based
on your IoT device capabilities and the server application's requirements.

Step 3: Set Up the Server Environment

 Set up a development environment for the server application. Install Python and any required
libraries or frameworks.

Step 4: Simulate IoT Devices (Optional)

 If you don't have physical IoT devices, you can simulate IoT data using Python scripts to generate
random sensor data.

Step 5: Create the Server Application

 Start by building the core server application responsible for receiving and processing data from IoT
devices.

Step 6: Implement IoT Protocol Handlers

 Implement handlers for the chosen IoT protocols in the server application to receive data from IoT
devices.

Step 7: Data Storage

 Set up a database (e.g., SQLite, MySQL) to store the incoming IoT data. Design the database schema
to accommodate the data fields.

Step 8: Data Preprocessing (Optional)

 Implement data preprocessing if necessary, such as cleaning data, handling missing values, and
converting data types.

Step 9: Real-Time Data Analytics (Optional)

 If you require real-time data analytics, implement algorithms to analyze data as it arrives.
Step 10: Data Storage and Cloud Integration

 If you plan to use a cloud platform, integrate the server application with the chosen cloud service
(e.g., AWS, Azure).

Step 11: Data Analytics and Machine Learning (Optional)

 Implement data analytics algorithms, such as computing averages, aggregations, or applying machine
learning models for predictive analytics.

Step 12: Real-Time Monitoring and Visualization

 Develop a user interface or dashboard to visualize real-time data and analytics results.

Step 13: Security and Privacy

 Implement security measures like encryption, secure communication protocols (e.g., SSL/TLS), and
access controls.

Step 14: Scalability and Performance Optimization

 Optimize the server application for scalability to handle a large number of IoT devices and data
streams.

Step 15: Testing and Quality Assurance

 Thoroughly test the application for data correctness, functionality, and performance. Perform unit
tests and integration tests.

Step 16: Deployment

 Deploy the server application and any associated services to a suitable infrastructure (e.g., cloud, on-
premises server).

Step 17: Maintenance and Updates

 Regularly maintain the application, update dependencies, and handle bug fixes or security patches.

Step 18: Monitor and Improve

 Continuously monitor the system's performance and usage. Collect user feedback and make
improvements based on requirements and feedback.

RESULT: Thus, a server application to interface IoT protocols and cloud by using data analytics has been
executed successfully
Expt-4 INTERFACE THE RASPBERRY PI WITH CLOUD TO TRAN-RECEIVE DATA FROM
SENSORS AND ACTUATORS

AIM: To Interface the Raspberry Pi with cloud to trans-receive data from sensors and actuators

APPARATUS REQUIRED:

 Raspberry pi 3B+
 DHT11 sensor
 Breadboard
 Wires.
 Cloud Account (ThingSpeak)

CIRCUIT DIAGRAM:
PROGRAM

import Adafruit_DHT

# Set sensor type: Options are DHT11, DHT22 or AM2302


sensor=Adafruit_DHT.DHT11

# Set GPIO sensor is connected to


gpio=4

# Use read_retry method. This will retry up to 15 times to


# get a sensor reading (waiting 2 seconds between each retry).
humidity, temperature = Adafruit_DHT.read_retry(sensor, gpio)

# Reading the DHT11 is very sensitive to timings and occasionally


# the Pi might fail to get a valid reading. So check if readings are valid.
if humidity is not None and temperature is not None:
print('Temp={0:0.1f}*C Humidity={1:0.1f}%'.format(temperature, humidity))
else:
print('Failed to get reading. Try again!')

import Adafruit_DHT
import os,sys
import paho.mqtt.client as paho
import urlparse
import time

# Set sensor type: Options are DHT11,DHT22 or AM2302


sensor=Adafruit_DHT.DHT11

# Set GPIO sensor is connected to


gpio=4

def on_connect(self, mosq, obj, rc):


self.subscribe("Fan", 0)

def on_message(mosq, obj, msg):


print (msg.topic + " " + str(msg.qos) + " " + str(msg.payload))
# Give 5 second delay

def on_publish(mosq, obj, mid):


print ("mid: " + str(mid))

def on_subscribe(mosq, obj, mid, granted_qos):


print ("Subscribed: " + str(mid) + " " + str(granted_qos))

mqttc = paho.Client() # object declaration


# Assign event callbacks
mqttc.on_message = on_message # called as callback
mqttc.on_connect = on_connect
mqttc.on_publish = on_publish
mqttc.on_subscribe = on_subscribe

url_str = os.environ.get('CLOUDMQTT_URL', 'tcp://broker.emqx.io:1883')


url = urlparse.urlparse(url_str)
mqttc.connect(url.hostname, url.port)
rc = 0
while rc == 0:
rc = mqttc.loop()
# Use read_retry method. This will retry up to 15 times to
# get a sensor reading (waiting 2 seconds between each retry).
humidity, temperature = Adafruit_DHT.read_retry(sensor, gpio)
# Reading the DHT11 is very sensitive to timings and occasionally
# the Pi might fail to get a valid reading. So, check if readings are valid.
if humidity is not None and temperature is not None:
print('Temp={0:0.1f} *C Humidity={1:0.1f} %’. format (temperature, humidity))
mqttc.publish("humidity",str(humidity))
mqttc.publish("Temp",str(temperature))
time.sleep(1)

else:
print ('Failed to get reading. Try again!')
PROCEDURE:

 Sign up for a ThingSpeak account: Visit the ThingSpeak website (https://thingspeak.com) and create
an account. This will provide you with a platform to store, analyze, and visualize your sensor data.

 Set up your channels: In ThingSpeak, create channels to represent the sensors and actuators you
want to interface with. Each channel will have a unique API key that will be used for data
transmission.
 Connect the Raspberry Pi to ThingSpeak: Install the ThingSpeak client library on your Raspberry Pi.
This library allows communication between the Raspberry Pi and ThingSpeak. You can use the
ThingSpeak library for Python, which provides easy-to-use functions for sending and receiving data.
 Collect and transmit sensor data: Write a Python script on the Raspberry Pi that collects data from
the sensors. Use the ThingSpeak library to transmit this data to the corresponding channels in
ThingSpeak. Configure the script to run periodically or based on specific events to ensure
continuous data transmission
 Monitor and control actuators: Set up the necessary control mechanisms in ThingSpeak to activate
or control your actuators based on the received data. This could involve writing custom MATLAB
code or using the ThingSpeak React feature to define rules and actions that trigger based on certain
conditions.

RESULT: Thus, interfacing of Raspberry Pi with cloud to trans-receive data from sensors and actuators has
been executed successfully
Expt-5 DESIGN BUSINESS MODEL AND DEPLOY HOME AUTOMATION USING
RASPBERRY PI

AIM: To Design business model and deploy Home Automation using Raspberry Pi.

APPARATUS REQUIRED:
 Raspberry pi 3B+
 LED s
 Resistors
 Breadboard
 Wires.

CIRCUIT DIAGRAM:
PROGRAM

from flask import Flask

from flask import Flask, render_template

import RPi.GPIO as GPIO

import time

app = Flask(__name__)

led1 = 2

led2 = 3

led3 = 4

GPIO.setwarnings(False)

GPIO.setmode (GPIO.BCM)

GPIO.setup(led1, GPIO.OUT)

GPIO.setup(led2, GPIO.OUT)

GPIO.setup(led3, GPIO.OUT) GPIO.output (ledi, 0)

GPIO.output (led2, 0)

GPIO.output(led3. 0)

print ("Done")

@app.route(""):

def index():

return render_template('index.html')

@app.route('/A')

def ledion():

GPIO.output (led1, 1)

return render_template('index.html')

@app.route('/a')

def ledtoff ():


PROCEDURE:

 Define your business model: Determine the specific aspects of your home automation business model.
Identify your target customers, the value proposition you offer, revenue streams, and key activities. Consider
whether you will sell products, offer services, or both. Determine if you will operate on a subscription-based
model, one-time purchases, or a combination.

 Plan your home automation system: Define the scope of your home automation system. Identify the
specific devices and functionalities you want to offer, such as smart lighting, security systems, temperature
control, or entertainment systems. Consider compatibility with the Raspberry Pi 3B+ and the availability of
compatible sensors, actuators, and communication modules.

 Procure necessary components: Purchase the required hardware components, such as Raspberry Pi 3B+
boards, sensors, actuators, and communication modules based on your planned home automation system.
Ensure compatibility and quality of the components, and consider scalability for future expansion.

 Install and configure the Raspberry Pi: Set up the Raspberry Pi 3B+ by installing the operating system
(such as Raspbian) and necessary software libraries or frameworks for home automation. Configure network
settings, security measures, and remote access capabilities.

 Connect and program the devices: Interface the sensors and actuators with the Raspberry Pi 3B+. Use
appropriate connection methods, such as GPIO pins, I2C, SPI, or USB, based on the devices' specifications.
Write code in a suitable programming language, such as Python, to interact with the devices, control their
functionalities, and collect data.

 Develop a user interface: Design and develop a user-friendly interface to allow homeowners to control
and monitor their home automation system. This could be a web-based dashboard, a mobile application, or a
combination of both. Ensure seamless integration with the Raspberry Pi and the ability to remotely access
and control the system.

 Test, deploy, and support: Thoroughly test the home automation system to ensure its functionality,
reliability, and security. Deploy the system at customers' homes and provide necessary support and
maintenance. Continuously gather feedback from customers to improve the system, add new features, and
address any issues that arise

RESULT: Thus, Business model and deployment of Home Automation using Raspberry Pi has been executed
successfully.

You might also like