OCS352 Lab Record
OCS352 Lab Record
EX.NO:1
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
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>
void setup()
void loop() {
zigbeeSerial.println("Hello, Zigbee!");
if (zigbeeSerial.available()) {
}
OUTPUT:
RESULT :
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>
void loop() {
gsmSerial.println("AT");
if (gsmSerial.available())
delay(1000);
delay(1000);
delay(1000);
}
OUTPUT:
RESULT:
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()
void loop()
if (bluetoothSerial.available()) {
Serial.println(receivedChar);
if (Serial.available())
bluetoothSerial.write(sendChar);
}
OUTPUT:
RESULT:
DATE: Programming
AIM:
Introducing the Raspberry Pi platform and Python programming, aiming to provide a
fundamental understanding for beginners.
PROCEDURE:
Get a Raspberry Pi:
PROGRAM:
# raspberry_pi_intro.py
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
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
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
# 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:
# 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']
# 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
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 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 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.
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.
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 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.
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.