0% found this document useful (0 votes)
21 views

Iot

The document introduces the Raspberry Pi platform and Python programming. It describes the features of Raspberry Pi including CPU, GPIO pins, HDMI output, and wireless connectivity. It also discusses applications such as education, DIY projects, home automation, and robotics. The advantages include affordability, versatility, and being a learning tool. The disadvantages are limited power and storage.

Uploaded by

Ammu Suda
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Iot

The document introduces the Raspberry Pi platform and Python programming. It describes the features of Raspberry Pi including CPU, GPIO pins, HDMI output, and wireless connectivity. It also discusses applications such as education, DIY projects, home automation, and robotics. The advantages include affordability, versatility, and being a learning tool. The disadvantages are limited power and storage.

Uploaded by

Ammu Suda
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 36

EXP.

NO DATE NAME OF THE EXPERIMENT MARK STAFF


SIGNATURE
1. Write 8051 assembly
language experiments using
simulator
2. Test the data transfer
between register and memory

3. Perform ALU operations in 8051

4. Write basic and arithmetic


program using embedded
C
5. Introduction to Arduino
platform and programming
6. Explore different
communication method with
IOT devices
(Zigbee,GSM,Bluetooth)
7. Introduction to Raspberry pi
platform and python programming

8. Interfacing sensors with


Raspberry pi
9. Communication between
Arduino and Raspberry pi using
any
wireless medium
10. Setup a cloud platform to log
the data
11. Log data using Raspberry pi
and upload to the cloud
platform
12. Design an IOT based system
Introduction to Arduino platform and programming

EXP.NO:05
DATE:

Aim:
To introduce Arduino platform and programming.

Arduino UNO :-
The Arduino UNO is a open source micro controller board with
the AT mega 328 D microcontroller, it contains analog and digital input and
output pins, USB programming. Arduino IDE making it versettle for various
projects,
including I0T & robotic PL's powered via USB or an external source it
operates at 5V & it is part of the opensource Arduino project.

features of Arduino UNO:


1, It contains 14 digital I/0 pins and 6 analog I/OPins.
2. It's clock speed is 16 mhz.
3, Flash memory & 32kB for storing your program.
4, SRAM is 2KB for data storage.
5, EEPROM is 1KB for non-volatile data storage.
6, USB interfaces for Programming and serial communication.
7, power supplied.
8, it has reset button for restarting the microcontroller.
9, LED indicator Built In LED on pin for pin 13 for basic testing.
Gaming:
Arduino UNO can be used to creative custom game controller&
interactive gaming experiences.
Robotics:
Arduino UNO is frequently used in robotics projects,controlling
motors,sensors and accutators for various robotics applications.

Advantage of IOT:
1,Data collection &
Analysis. 2, Automation &
Control
3, Cost Savings
4, Enhancing effeciently
5, Improved safely &
security. 6, Remote access
7, Environment benefits
8,Innovation & New business models
9, Healthcare & well-being
10, Smart-cities
11, Supplychain optimization
12, Efficient agriculture
13, Energy
management
14,Accessbility
15, Hardware integration
16, opensource
17,versality
18, Abundance of shield
19, Built-in libraries
Disadvantage of Arduino UNO:
1,limited processing power
2, limited memory
3, No Real-time operating system
4, Not ideal for Commercial
products 5, limited connectivity
6. Fixed voltage
7, Not for high power
8, limited 1/0 pins
9, lack of security feature
10, Non-real time
behaviour.

Example:
HC-05 Bluetooth module interfacing with arduino UNO
Program:
#include<SoftwareSerial.h>

/* Create object named bt of the class SoftwareSerial

*/ SoftwareSerial bt(2,3); /* (Rx,Tx) */

void setup() {

bt.begin(9600) ; /* Define baud rate for software serial communication */

Serial.begin(9600); /* Define baud rate for serial communication */

void loop() {

if (bt.available()) /* If data is available on serial port */

Serial.write(bt.read()); /* Print character received on to the serial monitor */

}
RESULT:
Thus the Arduino platform and programming was introduced
successfully.
EXP.NO:06
DATE:
Experiment explore the different communication methods with IOT
devices 1, Zigbee 2,GSM 3,Bluetooth

Aim:
To explore the different communication methods with iot devices
(Zigbee,GSM,Bluetooth).
6.1) Zigbee
Algorithm:
1: Start the program
2: Initiative requirement to the program
3: This consist of two devices master, slave.
4: For master initiate two definition setup, loop.
5. In setup begin the code using serial begin pin
6.for slave initiative two definition setup & Loop for
Output 7: if input is on turn on the LED else turn off the
LED
8: Stop the program.
CIRCUIT DIGRAM:
Output:
Master:
Enter command: Turn On
LED LED turned on
Slave:
Turn On LED

6.2)GSM
Algorithm:
1: start the program
2 :Initiate the requirement to run the program.
3: define functions setup, loop & send sms, make call
4: In setup begin, the begin - serial pinmode with input
5: In loop read the input and check the function then take a decision
send msg or make call.
6: In send sms & make call function put your mobile number and
message as input & perform
7: Stop the program
CIRCUIT DIAGRAM:
Program:
const int Input1=8;

int State1=0;

void setup(){

Serial.begin(9600);

pinMode(Input1, INPUT); }

void loop()

State1= digitalRead(Input1);

if(State1 == HIGH) {

sendsms();

delay(2000); }

void sendsms()

Serial.println("AT\r");

delay(1000);

Serial.println("AT+CMGF=1\r");

delay(1000);

Serial.println("AT+CMGS=\"XXXXXXXXXX\"\r");

delay(1000);

Serial.println("MESSAGE 1");

delay(1000);

Serial.println((char)26);

delay(100);

}
OUTPUT:
AT
OK
AT+CMGS=”=1234567890”
MESSAGE 1
+CMGS: 21
SMS sent
6.3) Bluetooth
Algorithm:
1: start the program
2: Initiative the requirements to run the Program
3: define function for setup & Coop
4: setup function consist of begin and soval begin
5: loop consist of bt available () in Condition and serial write with readed
value.
6:Stop the program
Program:
#include <SoftwareSerial.h>

/* Create object named bt of the class SoftwareSerial */

SoftwareSerial bt(2,3); /* (Rx,Tx) */

void setup() {

bt.begin(9600); /* Define baud rate for software serial communication */


Serial.begin(9600); /* De`ne baud rate for serial communication */ }

void loop() {

if (bt.available()) /* If data is available on serial port */

Serial.write(bt.read()); /* Print character received on to the serial


monitor */

}}
CIRCUIT DIAGRAM:
OUTPUT:

Mobile input

Input text:hi

Output:hi

RESULT:
Thus the different methods of communication with IOT device were
successfully executed.
EXP.NO:07
DATE:
Introduction to Raspberrypi, Platform and Python Programming

Aim:
To give the introduction about raspberry pi platform and python program
Raspberry Pi:
1, It's Small & affordable single board computer developed by the
raspberry pi foundation
2,It's versatile and can run various operating system
3,It's popular for task like programming, web browsing media playback
an move and also a great tool for learning about computing and
electronics
Features of Raspberry pi
1,Small from factor: Compact size, making them suitable for
various projects
2,Board cpu
support 3, Gpio
pins-26 pins 4,
HDMI output
5, multiple USB ports for peripherals.
6, Ethernet and wifi networking
option 7, Storage option:
Micro SD & USB ports for external
drivers 8,Audio output
9,Camera interface
10,Display Support
11,Operating system compability
12,low power consumption & cost
efficient Applications of Raspberry pi :
1. Education: It's a fantastic tool for teaching
programming, electronic & computer science.
2. DIY projects: It's used for creating Diy projects
3. Media centre with software like • On your Tv into a
media centre it can turn
4. Web server: It can be act as a for hosting our simple
websites hosting our simple websites
5. Home automation: Also used in home automation
technologies. 6.Robotics : Raspberry pi is also used in robotics
7.Programming and coding : Its an excellent platform for learning
and practicing programming in various languages

Advantages:
1.Affordability
2.versability
3. Community support

4. low power

consumption 5.Compact
size
6.Broad software
comptability. 7.Gpio pins
8. learning tools

9. media

compatability
10.Customization
Disadvantages:
1. limiting processing power
2. Limited RAM
3.Limited storage
4.limited graphics
performance 5.noisy audio
output 6.Compatability issues
7.power requirements
8.Complexity for
beginners 9.Lack of RTOS
10.Heating issues
11.Security concerns
Examples:

from w1thermsensor import W1ThermSensor


import RPi.GPIO as GPIO
import time
# Initialize the DS18B20 temperature sensor
ds18b20_sensor = W1ThermSensor()
# Set up GPIO for the soil moisture sensor
MOISTURE_PIN = 17 # Replace with the GPIO pin you've connected to
GPIO.setmode(GPIO.BCM)
GPIO.setup(MOISTURE_PIN, GPIO.IN)
def read_temperature():
try:
temperature = ds18b20_sensor.get_temperature()
return temperature
except Exception as
e:
print(f"Error reading temperature:
{e}") return None
def read_soil_moisture():
try:
moisture_level = GPIO.input(MOISTURE_PIN)
return moisture_level
except Exception as e:
print(f"Error reading soil moisture: {e}")
return None
def main():
while True:
temperature = read_temperature()
moisture_level =
read_soil_moisture() if temperature
is not None:
print(f"Temperature: {temperature}°C")
if moisture_level is not None:
if moisture_level == 0:
print("Soil is
wet") else:
print("Soil is dry")
time.sleep(5) # Adjust the interval as needed
if _name_ == "_main_":
try:
main()
except KeyboardInterrupt:
print("Exiting the
program.") finally:
GPIO.cleanup()

RESULT:
Thus the introduction about Raspberry pi platform and python program
was executed successfully.
EXP.NO:08
DATE:

Interfacing Sensors With Raspberry Pi

Aim:
To Interfacing sensors with raspberry pi
Algorithm:
1: start the program.
2: import the Libraries and initiate the requirements like pin.t etc…..
3:Create a function for temperature sensor and get the input
4: create a function for soil moisture sensor and get the input.
5:create a main function and get the temperature and soil moisture
function
6:check the condition for both temperature sensor and soil moisture
7:if the conditon is true print wet else day and sleep for certain
period. 8: Stop the program.

Program:
from w1thermsensor import W1ThermSensor
import RPi.GPIO as GPIO
import time
# Initialize the DS18B20 temperature sensor
ds18b20_sensor = W1ThermSensor()
# Set up GPIO for the soil moisture sensor
MOISTURE_PIN = 17 # Replace with the GPIO pin you've connected to
GPIO.setmode(GPIO.BCM)
GPIO.setup(MOISTURE_PIN, GPIO.IN)
def read_temperature():
try:
temperature = ds18b20_sensor.get_temperature()
return temperature
except Exception as e:
print(f"Error reading temperature:
{e}") return None
def read_soil_moisture():
try:
moisture_level = GPIO.input(MOISTURE_PIN)
return moisture_level
except Exception as e:
print(f"Error reading soil moisture: {e}")
return None
def main():
while True:
temperature = read_temperature()
moisture_level =
read_soil_moisture() if temperature
is not None:
print(f"Temperature: {temperature}°C")
if moisture_level is not None:
if moisture_level ==
0: print("Soil is wet")
else:
print("Soil is dry")
time.sleep(5) # Adjust the interval as needed
if _name_ == "_main_":
try:
main()
except KeyboardInterrupt:
print("Exiting the
program.") finally:
GPIO.cleanup()

OUTPUT:
Temperature: 25.3°C
Soil is wet
Temperature: 23.1°C
Soil is dry
Temperature: 21.8°C
Soil is wet
Temperature: 24.5°C
Soil is dry

RESULT:
Thus the interfacing sensors with raspberry pi is successfully executed.
EXP.NO:09
DATE:
Communicate between Arduino and Raspberry pi using any wireless
Medium.

Aim:
To communicate between Arduino and Raspberry pi using any wireless
Medium.

Algorithm:
1. start the program
2. For arduino void setup and void loop
3. In void setup begin (serial) In void loop write
(serial) If available read and write the data.
4.In raspberrypi initiate the requirements
5.import bluetooth, use bluetooth socket then bind and
Iisten. 6.accept the client sock the accept client info
7.If true sock-recv-C1024 then decode else disconnect and close
8.stop the program.

Program:
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(2, 3); // RX, TX
void setup() {
Serial.begin(9600);
BTSerial.begin(9600);
}
void loop() {
if (Serial.available()) {
char data =
Serial.read();
BTSerial.write(data);
}
if (BTSerial.available()) {
char data =
BTSerial.read();
Serial.write(data);
}
}
On the Raspberry Pi (Receiver):
import bluetooth
server_sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
server_sock.bind(("", bluetooth.PORT_ANY))
server_sock.listen(1)
port = server_sock.getsockname()[1]
bluetooth.advertise_service(server_sock, "SampleServer",
service_id=port)
print(f"Waiting for connection on RFCOMM channel {port}")
client_sock, client_info = server_sock.accept()
print(f"Accepted connection from {client_info}")
try:
while True:
data =
client_sock.recv(1024) if
len(data) == 0:
break
print(f"Received: {data.decode()}")
except IOError:
pass
print("Disconnected.")
client_sock.close()
server_sock.close()

OUTPUT:

Arduino (Sender):

Sent: hello

Received: world

Raspberry Pi (Receiver):

Waiting for connection on RFCOMM channel 1


Accepted connection from ('192.168.1.10', 1)
Received: hello

RESULT:
Thus the communicate between Arduino and Raspberry pi using any
wireless Medium was executed successfully.
EXP.NO:10
DATE:
Setup a cloud platform to log the data

Aim:
To setup a cloud platform to log the data
Algorithm:
1, Start the program
2, import the requirements for cloud platform
3,create private key, name, end point
4,Initiate requirements
5,Configure Aws 10T client
6,Connect if true and get temp and publish else disconnect
7,Stop the program
Program:
import AWSIoTPythonSDK.MQTTLib as
AWSIoT import os
from w1thermsensor import W1ThermSensor
# AWS IoT Core configuration
root_cert = "root-CA.crt"
private_key = "your-private-key.pem.key"
cert_file = "your-certificate.pem.crt"
iot_thing_name = "your-iot-thing-name"
iot_endpoint = "your-iot-endpoint.iot.us-east-1.amazonaws.com"
# Initialize the DS18B20 sensor
sensor = W1ThermSensor()
# Configure AWS IoT client
aws_iot = AWSIoT.MQTTConnection(iot_thing_name)
aws_iot.configureEndpoint(iot_endpoint, 8883)
aws_iot.configureCredentials(root_cert, private_key, cert_file)
try:
aws_iot.connect()
while True:
temperature = sensor.get_temperature()
aws_iot.publish("temperature", str(temperature), 1)
except KeyboardInterrupt:
print("Disconnecting...")
aws_iot.disconnect()

OUTPUT:
Connected to AWS IoT
Core Temperature: 23.1°C
Temperature: 22.8°C
Temperature: 24.5°C
Temperature: 21.6°C
Temperature: 25.2°C

RESULT:
Thus the setup a cloud platform to log the data was executed
successfully.
EXP.NO:11
DATE:
Log Data using Raspberry pi and upload to the cloud platform

Aim:
To log data using Raspberry pi and upload to the cloud platform

Algorithm:
1,start the program.
2,import the requirement and initiate the value
3,Aws S3 configuration by bucket name, access key. Key secrete
4, create an S3 client access aws secret key and Client
5,Read temp data by get
sensor. 6,upload data to sc
7,print temperature and data, upload to S3
8,stop the program.

Program:
import boto3
from w1thermsensor import W1ThermSensor
# Initialize the DS18B20 sensor
sensor = W1ThermSensor()
# AWS S3 configuration
bucket_name = "your-s3-bucket-name"
s3_access_key = "your-s3-access-key"
s3_secret_key = "your-s3-secret-key"
# Create an S3 client
s3 = boto3.client('s3', aws_access_key_id=s3_access_key,
aws_secret_access_key=s3_secret_key)
# Read temperature data
temperature = sensor.get_temperature()
# Upload data to S3
file_name = "temperature_data.txt"
data = f"Temperature: {temperature}
°C"
s3.upload_fileobj(data, bucket_name, file_name)
print("Data uploaded to S3.")

OUTPUT:
Data uploaded to S3.

RESULT:
Thus the log data using Raspberry pi and upload to the cloud platform
was executed successfully.
EXP.NO:12
DATE:

Design an IOT based system

Aim:
To design an iot based system

Algorithm:
1,Start the program
2, Initiate the requirement to run the program (Arduino)
3,Initialise the pin.
4,define setup function and loop function
5,Serial begin setup function
6,Read temperature sensor and soil humidity in loop()
7,Convert analog reading to percentage
8,Send data through bluetooth
9,Debugging data to serial
monitor 10,Import required data
11,Replace raspberry pi bluetooth serial port
12,decode the readline
13,Print received data
14,Stop the program

Program:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SoftwareSerial.h>
OneWire oneWire(DS18B20_PIN); // Define the DS18B20 data pin
DallasTemperature sensors(&oneWire);
int soilHumidityPin = A0; // Define the soil humidity sensor pin (analog
pin)
SoftwareSerial BTSerial(2, 3); // RX, TX for HC-05 Bluetooth module
void setup() {
Serial.begin(9600); // Initialize the hardware Serial for debugging
BTSerial.begin(9600); // Initialize software Serial for Bluetooth
sensors.begin(); // Initialize DS18B20 temperature sensor
}
void loop() {
// Read temperature from DS18B20 sensor
sensors.requestTemperatures();
float temperature = sensors.getTempCByIndex(0);
// Read soil humidity
int soilHumidity = analogRead(soilHumidityPin);
// Convert analog reading to a percentage (adjust the formula based on
your sensor)
float humidityPercentage = map(soilHumidity, 0, 1023, 0, 100);
// Send data via
Bluetooth
BTSerial.print("T:");
BTSerial.print(temperature);
BTSerial.print("C H:");
BTSerial.print(humidityPercentage);
BTSerial.println("%");
// For debugging, you can also send data to the Serial Monitor
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.print("°C Humidity: ");
Serial.print(humidityPercentage);
Serial.println("%");
delay(10000); // Adjust the delay as needed
}
import serial
# Replace with your Raspberry Pi's Bluetooth serial port
bt_port = "/dev/rfcomm0"
with serial.Serial(bt_port, 9600) as ser:
while True:
data = ser.readline().decode().strip()
print("Received Data:", data)
OUTPUT:
Arduino:
Temperature: 25.2°C Humidity: 52%

Raspberry pi:
Received Data: T: 25.2C H: 52%
RESULT:
Thus the IOT based system was designed successfully.

You might also like