0% found this document useful (0 votes)
76 views27 pages

OCS352 Lab Record

The document outlines a series of laboratory exercises focused on interfacing various components with Arduino and Raspberry Pi, including programming for LED control, Zigbee, GSM, Bluetooth modules, and cloud data logging. Each exercise includes hardware setup, software configuration, programming examples, and expected results. The aim is to provide practical experience in IoT concepts and applications using these platforms.

Uploaded by

deepaa0031988
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views27 pages

OCS352 Lab Record

The document outlines a series of laboratory exercises focused on interfacing various components with Arduino and Raspberry Pi, including programming for LED control, Zigbee, GSM, Bluetooth modules, and cloud data logging. Each exercise includes hardware setup, software configuration, programming examples, and expected results. The aim is to provide practical experience in IoT concepts and applications using these platforms.

Uploaded by

deepaa0031988
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

OCS352 -IOT CONCEPTS AND APPLICATIONS LABORATORY

EX.NO:1

DATE: Introduction to Arduino Platform and Programming

AIM:

The aim of this lab exercise is to introduce participants to the Arduino platform
and programming environment.

PROCEDURE:

1. Hardware Setup:
 Connect the Arduino board to your computer using a USB cable.
 Ensure that the board is receiving power either from the USB connection or an
external power source.
 Install any necessary drivers for your Arduino board if prompted by your
operating system.
2. Software Installation:
 Download and install the Arduino IDE from the official Arduino website
(https://www.arduino.cc/en/Main/Software).
 Launch the Arduino IDE once installation is complete.
3. Writing the Program:
 Open the Arduino IDE.
 Write a simple program (referred to as a sketch) to blink an LED connected to
pin 13 on the Arduino board.
1. Uploading the Program:
 Connect the Arduino board to your computer if not already connected.
 Select the correct board type and port from the Tools menu in the Arduino
IDE.
 Click the "Upload" button (right arrow icon) in the Arduino IDE to compile
and upload the program to the Arduino board.
2. Observing the Output:
 Once the program is uploaded successfully, observe the LED connected to pin
13 on the Arduino board.
 The LED should blink on and off at one-second intervals as specified in the
program.

PROGRAM:

void setup()
{
pinMode(13, OUTPUT); // Set pin 13 as an output
}

void loop()
{
digitalWrite(13, HIGH); // Turn the LED on
delay(1000); // Wait for 1 second
digitalWrite(13, LOW); // Turn the LED off
delay(1000); // Wait for 1 second
}

OUTPUT:

RESULT:
After uploading the program to the Arduino board, the LED connected to pin 13 will blink on
and off at one-second intervals. So Arduino successfully implemented.
EXNO:2

DATE: Interfacing Arduino to Zigbee Module


AIM:

The aim of this lab exercise is to interface an Arduino board with a Zigbee module.

PROCEDURE:

1. Hardware Setup:
 Connect the Zigbee module to the Arduino board using jumper wires.
 Ensure that the connections are made according to the pinout specifications
provided by the Zigbee module datasheet.
 Power the Zigbee module appropriately, either through the Arduino's power
pins or using an external power source.
2. Software Configuration:
 Install any necessary libraries or dependencies for Zigbee communication on
the Arduino IDE.
 Open the Arduino IDE and create a new sketch for interfacing with the Zigbee
module.
3. Programming:
 Write a program to initialize the serial communication between the Arduino
and Zigbee module.
 Implement functions to send and receive data wirelessly using the Zigbee
module.
 Ensure that the program can handle data packets in the appropriate format for
Zigbee communication.
4. Testing and Debugging:
 Upload the program to the Arduino board.
 Monitor the serial output on the Arduino IDE's serial monitor to verify that
communication with the Zigbee module is established.
 Test various data transmission scenarios to ensure reliable communication
between the Arduino and Zigbee module.

PROGRAM:

#include <SoftwareSerial.h>

SoftwareSerial zigbeeSerial(2, 3); // RX, TX pins for Zigbee module

void setup()

Serial.begin(9600); // Initialize serial communication with PC

zigbeeSerial.begin(9600); // Initialize serial communication with Zigbee module


}

void loop() {

// Send data to Zigbee module

zigbeeSerial.println("Hello, Zigbee!");

// Check for incoming data from Zigbee module

if (zigbeeSerial.available()) {

String receivedData = zigbeeSerial.readString();

Serial.println("Received from Zigbee: " + receivedData);

delay(1000); // Wait for 1 second

}
OUTPUT:

RESULT :

Upon successful execution of the program and establishment of communication between


the Arduino and Zigbee module.
EX.NO:3

DATE: Interfacing Arduino to GSM Module

AIM:

The aim of this lab exercise is to interface an Arduino board with a GSM (Global System
for Mobile Communications) module.

PROCEDURE:

1. Hardware Setup:
 Connect the GSM module to the Arduino board using jumper wires.
 Ensure that the connections are made according to the pinout specifications
provided by the GSM module datasheet.
 Power the GSM module appropriately, either through the Arduino's power
pins or using an external power source.
2. SIM Card Installation:
 Insert a valid SIM card into the SIM card slot on the GSM module. Ensure that
the SIM card is activated and has sufficient credit for sending SMS messages.
3. Software Configuration:
 Install any necessary libraries or dependencies for GSM communication on the
Arduino IDE.
 Open the Arduino IDE and create a new sketch for interfacing with the GSM
module.
4. Programming:
 Write a program to initialize the serial communication between the Arduino
and GSM module.
 Implement functions to send AT commands to the GSM module for sending
SMS messages.
 Ensure that the program handles responses from the GSM module and
provides appropriate error checking and handling.
5. Testing and Debugging:
 Upload the program to the Arduino board.
 Monitor the serial output on the Arduino IDE's serial monitor to verify that
communication with the GSM module is established.
 Test sending SMS messages to verify that the GSM module can send
messages successfully.

PROGRAM:

#include <SoftwareSerial.h>

SoftwareSerial gsmSerial(2, 3); // RX, TX pins for GSM module


void setup()

Serial.begin(9600); // Initialize serial communication with PC

gsmSerial.begin(9600); // Initialize serial communication with GSM module

void loop() {

// Send AT command to check if GSM module is ready

gsmSerial.println("AT");

delay(1000); // Wait for response

// Check for response from GSM module

if (gsmSerial.available())

String response = gsmSerial.readString();

Serial.println("GSM Response: " + response);

// Send SMS message

gsmSerial.println("AT+CMGF=1"); // Set SMS mode to text mode

delay(1000);

gsmSerial.println("AT+CMGS=\"+123456789\""); // Replace with recipient's phone


number

delay(1000);

gsmSerial.println("Hello from Arduino!"); // Replace with message content


delay(1000);

gsmSerial.write(0x1A); // Send Ctrl+Z (End of message)

delay(1000);

}
OUTPUT:

RESULT:

Upon successful execution of the program and establishment of communication


between the Arduino and GSM module.
EX.NO:4

DATE: Interfacing Arduino to Bluetooth Module

AIM:

The aim of this lab exercise is to interface an Arduino board with a Bluetooth module.

PROCEDURE:

1. Hardware Setup:
 Connect the Bluetooth module to the Arduino board using jumper wires.
 Ensure that the connections are made according to the pinout specifications
provided by the Bluetooth module datasheet.
 Power the Bluetooth module appropriately, either through the Arduino's power
pins or using an external power source.
2. Software Configuration:
 Install any necessary libraries or dependencies for Bluetooth communication
on the Arduino IDE.
 Open the Arduino IDE and create a new sketch for interfacing with the
Bluetooth module.
3. Pairing Bluetooth Module:
 Ensure that the Bluetooth module is in discoverable mode.
 Pair the Bluetooth module with a Bluetooth-enabled device such as a
smartphone or computer. Note down the Bluetooth device address for later
use.
4. Programming:
 Write a program to initialize the serial communication between the Arduino
and Bluetooth module.
 Implement functions to send and receive data wirelessly using the Bluetooth
module.
 Ensure that the program can handle data packets in the appropriate format for
Bluetooth communication.
5. Testing and Debugging:
 Upload the program to the Arduino board.
 Monitor the serial output on the Arduino IDE's serial monitor to verify that
communication with the Bluetooth module is established.
 Test sending and receiving data wirelessly between the Arduino and Bluetooth
module.

PROGRAM:

#include <SoftwareSerial.h>
SoftwareSerial bluetoothSerial(2, 3); // RX, TX pins for Bluetooth module

void setup()

Serial.begin(9600); // Initialize serial communication with PC

bluetoothSerial.begin(9600); // Initialize serial communication with Bluetooth module

void loop()

// Check for incoming data from Bluetooth module

if (bluetoothSerial.available()) {

char receivedChar = bluetoothSerial.read();

Serial.print("Received from Bluetooth: ");

Serial.println(receivedChar);

// Send data to Bluetooth module

if (Serial.available())

char sendChar = Serial.read();

bluetoothSerial.write(sendChar);

}
OUTPUT:

RESULT:

Upon successful execution of the program and establishment of communication


between the Arduino and Bluetooth modu
EX.NO:5 Introduction to Raspberry Pi Platform and Python

DATE: Programming

AIM:
Introducing the Raspberry Pi platform and Python programming, aiming to provide a
fundamental understanding for beginners.
PROCEDURE:
Get a Raspberry Pi:

 Purchase a Raspberry Pi board and a microSD card.


 Download and install the Raspberry Pi OS using the Raspberry Pi Imager.
Initial Setup:
 Assemble the Raspberry Pi with keyboard, mouse, and monitor.
 Power on the Raspberry Pi and complete the setup process.
Understand Raspberry Pi GPIO:
 Raspberry Pi has General Purpose Input/Output (GPIO) pins that allow it to
interact with the real world.
 You can control hardware components like LEDs, motors, and sensors using
Python.
Explore Python Libraries:
 Python has many libraries that make working with Raspberry Pi hardware
easy, such as RPi. GPIO and GPIOzero.
Expand Your Projects:
 With this foundation, you can explore various projects, from simple LED
blinking to complex IoT applications, robotics, and more.

PROGRAM:

# raspberry_pi_intro.py

# Importing required libraries


import RPi.GPIO as GPIO
import time
# Setting up GPIO mode
GPIO.setmode(GPIO.BCM)

# Define the pin connected to the LED


led_pin = 18

# Setting up the LED pin as output


GPIO.setup(led_pin, GPIO.OUT)

# Blinking the LED


try:
while True:
print("LED on")
GPIO.output(led_pin, GPIO.HIGH) # Turn on the LED
time.sleep(1) # Wait for 1 second

print("LED off")
GPIO.output(led_pin, GPIO.LOW) # Turn off the LED
time.sleep(1) # Wait for 1 second

except KeyboardInterrupt:
GPIO.cleanup()
OUTPUT:

RESULT:
The result of the "Introduction to Raspberry Pi Platform and Python Programming"
program is an LED blinking on and off every second
EX.NO:6

DATE: Interfacing sensors to raspberry pi

AIM:
Interfacing sensors to Raspberry Pi: Establishing a connection between various sensors
and the Raspberry Pi platform for data collection and processing.
PROCEDURE:
Select the Sensor:
 Choose a sensor suitable for your project requirements, considering factors
such as type, interface, and compatibility with Raspberry Pi.
Connect the Sensor:
 Wire the sensor to the Raspberry Pi's GPIO pins or through an appropriate
interface (e.g., I2C, SPI).
Install Required Libraries:
 Install necessary Python libraries for the sensor (if applicable) using pip or
download from the source.
Write the Python Script:
 Create a Python script to read data from the sensor using libraries and
interface with the Raspberry Pi.
Run the Program:
 Execute the Python script on the Raspberry Pi to collect and process data
from the sensor.

PROGRAM:
# interfacing_sensor.py
import RPi.GPIO as GPIO
import time
# Set up GPIO
sensor_pin = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(sensor_pin, GPIO.IN)

try:
while True:
if GPIO.input(sensor_pin) == GPIO.HIGH:
print("Sensor activated - Something detected!")
else:
print("Sensor deactivated - Nothing detected.")
time.sleep(0.5)

except KeyboardInterrupt:
GPIO.cleanup()

OUTPUT:

RESULT:
The result of the "Interfacing Sensors to Raspberry Pi" program will be messages
indicating whether the sensor is activated (something detected) or deactivated (nothing
detected)
EX.NO:7 Communication between Arduino and raspberry pi using any
DATE: wireless medium

AIM:
Communication between Arduino and Raspberry Pi using wireless medium:
Establishing a wireless communication link to exchange data between Arduino and Raspberry
Pi.
PROCEDURE:
Select Wireless Medium:
 Choose a suitable wireless communication method (e.g., Bluetooth, Wi-Fi,
Zigbee) based on range, data rate, and power consumption.
Connect Wireless Module:
 Connect a compatible wireless module (e.g., HC-05 Bluetooth module,
ESP8266 Wi-Fi module) to the Arduino.
Write Arduino Code:
 Write Arduino code to send or receive data using the selected wireless
module.
Connect Raspberry Pi:
 Interface the Raspberry Pi with the same wireless medium.
Write Python Script:
 Develop a Python script to exchange data with the Arduino over the
wireless medium.

PROGRAM:
#include <SoftwareSerial.h>
SoftwareSerial bluetooth(2, 3); // RX, T
void setup()
{
Serial.begin(9600);
bluetooth.begin(9600);
}

void loop() {
bluetooth.println("Hello from Arduino");
delay(1000);
}
Raspberry Pi Python Script (Receiver):
import serial
import time
bluetooth_port = "/dev/rfcomm0"
bluetooth = serial.Serial(bluetooth_port, 9600)
bluetooth.flushInput()
try:
while True:
if bluetooth.in_waiting > 0:
bluetooth_data = bluetooth.readline().decode("utf-8").rstrip()
print("Received from Arduino:", bluetooth_data)
time.sleep(1)
except KeyboardInterrupt:
bluetooth.close()

OUTPUT:

RESULT:
The result of the communication between Arduino and Raspberry Pi using Bluetooth as the
wireless medium is a continuous stream of messages like: "Received from Arduino: Hello
from Arduino"
EX.NO:8

DATE: Setup a cloud platform to log the data

AIM:
Setting up a cloud platform to log the data: Establishing a cloud-based infrastructure to
store and manage data collected from various sources.

PROCEDURE:
Select a Cloud Provider:
 Choose a cloud platform provider such as AWS, Google Cloud, or
Microsoft Azure.
Create an Account:
 Sign up for an account on the selected cloud platform.
Set Up a Database Service:
 Configure a database service such as AWS RDS, Google Cloud SQL, or
Azure SQL Database to store the data.
Develop an API:
 Develop an API using a serverless function or a virtual machine to handle
data ingestion from Raspberry Pi and Arduino.
Establish Data Logging:
 Implement data logging by sending data to the cloud database through the
API. Ensure security measures are in place to protect the data during
transmission.

PROGRAM:
import serial
import requests
import json
import time
# Define the serial port
ser = serial.Serial('/dev/ttyACM0', 9600, timeout=1)
# URL of the API endpoint
API_ENDPOINT = "https://your_api_endpoint_here.execute-
api.your_region_here.amazonaws.com/prod/data"
while True:
# Read data from Arduino
data = ser.readline().strip().decode("utf-8")
# Create the data payload
payload = {"data": data}
# Send data to the API
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
requests.post(url=API_ENDPOINT, data=json.dumps(payload),
headers=headers)
time.sleep(1)
Python script to run on AWS Lambda (API endpoint):
import json
import boto3

def lambda_handler(event, context):


# Retrieve data from the request
data = json.loads(event['body'])['data']

# Store data in the RDS database


rds = boto3.client('rds-data')
sql_statement = f"INSERT INTO sensor_data (data) VALUES ('{data}')"
response = rds.execute_statement(
secretArn='your_secret_arn_here',
database='your_database_name_here',
resourceArn='your_resource_arn_here',
sql=sql_statement
)

# Return response
return {
'statusCode': 200,
'body': json.dumps('Data logged successfully!')
}

OUTPUT:

RESULT:
The result of setting up a cloud platform to log data is the successful logging of data
from Raspberry Pi to the cloud platform.
EX.NO:9 Log data using raspberry pi and upload to the cloud
DATE: platform

AIM:
Log data using Raspberry Pi and upload to the cloud platform: Establishing a
connection between Raspberry Pi and a cloud platform to log and upload data for storage and
analysis.
PROCEDURE:
Set up Raspberry Pi:
 Connect Raspberry Pi to the sensors and ensure proper functionality.
Select a Cloud Platform:
 Choose a cloud platform provider (e.g., AWS, Google Cloud, Microsoft
Azure).
Create Cloud Database:
 Set up a database service (e.g., AWS RDS, Google Cloud SQL, Azure
SQL Database) to store the data.
Develop Python Script:
 Write a Python script to read data from sensors and upload it to the cloud
platform.
Run the Program:
 Execute the Python script on the Raspberry Pi to collect and upload data to
the cloud platform.

PROGRAM:

Python script to run on Raspberry Pi:


import serial
import requests
import json
import time

# Define the serial port


ser = serial.Serial('/dev/ttyACM0', 9600, timeout=1)

# URL of the API endpoint


API_ENDPOINT = "https://your_api_endpoint_here.execute-
api.your_region_here.amazonaws.com/prod/data"
while True:
# Read data from Arduino
data = ser.readline().strip().decode("utf-8")

# Create the data payload


payload = {"data": data}

# Send data to the API


headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
response = requests.post(url=API_ENDPOINT, data=json.dumps(payload),
headers=headers)

# Check response
if response.status_code == 200:
print("Data logged successfully!")
else:
print("Failed to log data.")
time.sleep(1)
Python script to run on AWS Lambda (API endpoint):
import json
import boto3
def lambda_handler(event, context):
# Retrieve data from the request
data = json.loads(event['body'])['data']

# Store data in the RDS database


rds = boto3.client('rds-data')
sql_statement = f"INSERT INTO sensor_data (data) VALUES ('{data}')"
response = rds.execute_statement(
secretArn='your_secret_arn_here',
database='your_database_name_here',
resourceArn='your_resource_arn_here',
sql=sql_statement
)

# Return response
return {
'statusCode': 200,
'body': json.dumps('Data logged successfully!')
}

OUTPUT:

RESULT:
Data collected by the Raspberry Pi has been successfully uploaded to the cloud
platform (AWS Lambda), ready for further processing and analysis.
EX.NO:10

DATE: Design An IOT Based System

Introduction:
Introducing an innovative IoT-based system designed to revolutionize connectivity and
automation in various domains. Leveraging smart sensors, actuators, and robust
communication protocols, this system enables seamless data exchange and remote control.
With a focus on efficiency, scalability, and security, it empowers users to monitor, manage, and
optimize processes in real time. From smart homes to industrial IoT applications, this system
offers tailored solutions to meet diverse needs. Join the IoT revolution and unlock new
possibilities with our cutting-edge system.

Define Objectives and Requirements:

 Identify the purpose and goals of the IoT system.


 Determine the target users, their needs, and the intended environment of deployment.
 Specify functional and non-functional requirements, including data security,
scalability, and interoperability.

Select Hardware and Software Components:

 Choose appropriate hardware components such as sensors, actuators,


microcontrollers, and communication modules based on the system requirements.
 Select software components, including operating systems, middleware, and
development frameworks, considering compatibility and functionality.

Design System Architecture:

 Define the architecture of the IoT system, including hardware, software, and network
components.
 Determine how data will flow between devices, gateways, and cloud servers.
 Design protocols and interfaces for communication, data storage, and processing.

Develop Firmware and Software:

 Develop firmware or embedded software for IoT devices to collect, process, and
transmit data.
 Develop backend software for data storage, processing, and analysis.
 Create user interfaces (web or mobile apps) for interacting with the IoT system.

Implement Communication Protocols:


 Choose appropriate communication protocols for data exchange between IoT devices
and backend servers (e.g., MQTT, HTTP, CoAP).
 Implement secure communication protocols to protect data integrity and
confidentiality.

Integrate Hardware and Software:

 Connect IoT devices to the backend infrastructure using communication interfaces


(e.g., Wi-Fi, Bluetooth, Zigbee).
 Test the integration to ensure data flows smoothly between devices and backend
servers.

Implement Data Storage and Processing:

 Set up databases or data storage systems to store sensor data collected from IoT
devices.
 Develop algorithms and analytics tools to process and analyze the collected data.
 Implement real-time or batch processing techniques as required.

Ensure Security and Privacy:

 Implement security measures such as authentication, encryption, and access control to


protect IoT devices and data.
 Comply with privacy regulations and standards to safeguard user data and privacy.

Test and Validate:

 Conduct thorough testing of the entire IoT system to validate its functionality,
performance, and reliability.
 Perform integration testing, unit testing, and end-to-end testing to identify and fix any
issues or bugs.

Deploy and Monitor:

 Deploy the IoT system in the target environment (e.g., homes, offices, industrial
facilities).
 Monitor the system's performance, uptime, and user interactions.
 Provide ongoing maintenance and support to address any issues or updates.

Iterate and Improve:

 Gather feedback from users and stakeholders to identify areas for improvement.
 Continuously iterate on the IoT system by adding new features, optimizing
performance, and enhancing user experience.

You might also like