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

Industrial IoT Lab Manual

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)
19 views

Industrial IoT Lab Manual

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/ 33

QIS College of Engineering & Technology

(Autonomous)
Ongole

Department of CSE IoT

Lab Manual

on

Industrial IoT

Class/Sem : III IoT / II

AY: 2023-24
QIS COLLEGE OF ENGINEERING AND TECHNOLOGY
(AUTONOMOUS)
Permanent Affiliation: JNTU-Kakinada | UGC-Recognized
Vengamukkapalem(V), Ongole, Prakasam dist., Andhra Pradesh-523272

DEPARTMENT OF CSIOT

INDUSTRIL IOT LAB MANUAL


NAME OF THE STUDENT :
ROLL NO :
YEAR :
SECTION :
BRNCH :
INDEX

SNO EXPTNO EXPT NAME SIGN


Industrial IoT (IIoT) Laboratory

Objective
The lab is equipped with popular boards in addition to the facilities in IoT Lab. The
equipment/device in the lab will be used to design and develop projects to create new smart
solutions.

List of Experiments

1. Study the function of Raspberry Pi3 B Board, Arduino Boards, Xbee modules with explorer
and shield, SIM900 GPRS/GSM module, LoRaWAN module and Ethernet Shield.

2. Setting up of Raspberry Pi and connect to a network

3. Familiarization with GPIO pins and control hardware through GPIO pins.

4. Speed Control of motors using PWM with python programming.

5. Use sensors to measure temperature, humidity, light and distance.

6. Web based hardware control

7. Connect IOT devices through cloud using IoT protocol such as MQTT.

8. Controlling IoT devices using Arduino.

9. Create Wireless network of sensors using Zigbee.


Experiment-1

Study the function of Raspberry Pi3 B Board, Arduino Boards, Xbee modules with explorer and
shield, SIM900 GPRS/GSM module, LoRaWAN module and Ethernet Shield.

Aim:
To study the each of mentioned devices serves different purposes and has distinct functionalities
within the realm of electronics and IoT. Let's discuss into their functions:

1. Raspberry Pi 3 B Board:
The Raspberry Pi 3 B is a single-board computer that offers various features such as a quad-core
CPU, built-in Wi-Fi, Bluetooth, GPIO pins, USB ports, HDMI output, and more.
Function: It can be used for a wide range of applications including desktop computing, media
centers, home automation, IoT projects, and as a development platform for programming and
electronics projects.

2. Arduino Boards:
Arduino boards are microcontroller-based development platforms with various models available
(e.g., Arduino Uno, Arduino Mega, Arduino Nano).
Function: Arduino boards are commonly used for prototyping and creating embedded systems
and IoT devices. They are programmed using the Arduino IDE (Integrated Development
Environment) and can interface with various sensors, actuators, and other electronic components.

3. XBee Modules with Explorer and Shield:


XBee modules are radio frequency (RF) transceivers used for wireless communication in IoT
applications.
The Explorer and Shield are accessories that provide convenient ways to interface XBee modules
with other devices.
Function: XBee modules facilitate wireless communication between devices over short to
medium ranges, making them ideal for applications such as remote monitoring, sensor networks,
and home automation.

4. SIM900 GPRS/GSM Module:


The SIM900 module is a GSM/GPRS modem that allows devices to connect to the internet or
communicate via SMS using the GSM cellular network.
Function: It enables IoT devices to transmit data wirelessly over the cellular network, making it
suitable for applications such as remote monitoring, asset tracking, and mobile data
communication.

5. LoRaWAN Module:
LoRaWAN (Long Range Wide Area Network) modules utilize the LoRa wireless technology to
provide long-range communication with low power consumption.
Function: LoRaWAN modules enable IoT devices to transmit data over long distances (several
kilometers) with low power consumption, making them suitable for applications such as smart
agriculture, smart cities, and industrial monitoring.

6. Ethernet Shield:
An Ethernet shield is an expansion board that allows Arduino boards to connect to a wired
Ethernet network.
Function: It enables Arduino-based devices to communicate with other devices or servers over
a local area network (LAN) using the Ethernet protocol. This is useful for applications where a
wired network connection is preferred over wireless.
Each of these devices plays a crucial role in the development and implementation of IoT solutions,
providing different communication options, processing capabilities, and interfacing capabilities to
suit various project requirements.
Experiment 2

Setting up Raspberry Pi and Connecting to a Network

Aim: To set up Raspberry Pi and establish a connection to a network.

Materials Required:
Raspberry Pi board (any model)
MicroSD card (16GB recommended)
MicroSD card reader
HDMI cable
Monitor or TV with HDMI input
USB keyboard
USB mouse
Power supply (compatible with Raspberry Pi)
Ethernet cable or Wi-Fi dongle (if using Wi-Fi)
Internet connection (Ethernet or Wi-Fi)

Procedure:

1. Prepare the Operating System:


Download the latest version of the Raspbian OS from the Raspberry Pi website.
Use a computer to format the MicroSD card using the SD Card Formatter tool.
Use the Raspberry Pi Imager tool to write the Raspbian OS image to the MicroSD card.

2. Connect the Peripherals:


Insert the MicroSD card into the slot on the Raspberry Pi board.
Connect the HDMI cable from the Raspberry Pi to the monitor or TV.
Plug in the USB keyboard and mouse into the USB ports on the Raspberry Pi.
If using Ethernet, connect one end of the Ethernet cable to the Ethernet port on the Raspberry
Pi and the other end to your router or switch. If using Wi-Fi, insert the Wi-Fi dongle into one of
the USB ports.

3. Power On Raspberry Pi:


Connect the power supply to the power port on the Raspberry Pi.
Power on the Raspberry Pi by plugging in the power supply to a power outlet.
4. Initial Configuration:
On the first boot, Raspbian will guide you through the initial setup process. Follow the on-
screen instructions to set your language, time zone, keyboard layout, and password for the default
user (pi).
If using Wi-Fi, Raspbian will prompt you to connect to a Wi-Fi network. Enter the Wi-Fi
credentials as required.

5. Update Software:
Once the setup is complete and you are logged in, open a terminal window.
Run the following commands to update the software packages:
sudo apt update
sudo apt upgrade

6. Reboot Raspberry Pi:


After updating the software, reboot Raspberry Pi using the following command:
sudo reboot
7. Connect to the Internet:
Once Raspberry Pi has rebooted, ensure it is connected to the internet. You can open a web
browser and try accessing a website to verify the connection.

Result:

Thus we have successfully set up Raspberry Pi and connected it to the network. We can now
proceed with further experiments and projects in the Industrial IoT lab.

Note:Ensure to handle the Raspberry Pi and peripherals carefully to avoid damage. Always follow
safety precautions, such as disconnecting the power supply before connecting or disconnecting
any peripherals.
Experiment 3

Familiarization with GPIO Pins and Control Hardware through GPIO Pins

Aim : To understand GPIO pins and interface external components for control using Raspberry
Pi.

Materials Required:
Raspberry Pi board (any model)
Breadboard
LED (Light Emitting Diode)
Resistor (220Ω recommended)
Jumper wires

Procedure:

1. Prepare Raspberry Pi:


Set up Raspberry Pi according to Experiment 2 of the lab manual.

2. Gather Components:
Gather the breadboard, LED, resistor, and jumper wires.

3. Identify GPIO Pins:


Refer to the GPIO pinout diagram specific to your Raspberry Pi model. You can find this
information in the Raspberry Pi documentation or online resources.
Identify the GPIO pins you will use for connecting the LED.

4. Connect LED to GPIO Pins:


import RPi.GPIO as GPIO
Place the LED and resistor on the breadboard. Connect one leg of the resistor to the longer leg
(anode) of the LED.
Connect the other leg of the resistor to one of the GPIO pins on Raspberry Pi.
Connect the shorter leg (cathode) of the LED to the ground (GND) pin on Raspberry Pi using a
jumper wire.

5. Write Python Script:


Open a text editor or Python IDE on Raspberry Pi.
Write a Python script to control the LED connected to GPIO pins. Below is a sample script to
blink the LED:

import time

# Set GPIO mode and pins


GPIO.setmode(GPIO.BCM)
led_pin = 18 # Example GPIO pin (change as per your setup)

# Setup LED pin as output


GPIO.setup(led_pin, GPIO.OUT)

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

# Turn LED off


GPIO.output(led_pin, GPIO.LOW)
time.sleep(1) # Delay for 1 second

except KeyboardInterrupt:
# Cleanup GPIO
GPIO.cleanup()
6. Save and Run Script:
Save the Python script with an appropriate filename (e.g., gpio_control.py).
Open a terminal window and navigate to the directory where the script is saved.
Run the script using the following command:
python gpio_control.py

7. Observation:
Observe the LED blinking at regular intervals as programmed in the Python script.
You can modify the script to experiment with different GPIO pins, control patterns, and timings.

8. Cleanup:
After completing the experiment, press `Ctrl + C` in the terminal to stop the Python script.
Disconnect the components from Raspberry Pi and the breadboard.

Result :

Thus, We have successfully familiarized with GPIO pins on Raspberry Pi and controlled hardware
using GPIO pins. This knowledge can be applied to more complex IoT projects involving sensor
interfacing, motor control, and more.

Note: Ensure proper connections and resistor values to prevent damage to Raspberry Pi and LED.
Always handle electronic components with care and follow safety precautions.
Experiment 4

Speed Control of Motors Using PWM with Python Programming

Aim: To control the speed of a motor using Pulse Width Modulation (PWM) technique with
Raspberry Pi and Python programming.

Materials Required:
Raspberry Pi (any model with GPIO pins)
Motor (DC motor or servo motor)
Motor driver (if required)
Breadboard and jumper wires
Power supply for motor (if required)

Procedure:

1. Setup Hardware:
Connect the motor to the Raspberry Pi using jumper wires. If using a DC motor, connect it to
the GPIO pins via a motor driver. If using a servo motor, connect it directly to the GPIO pins.
Ensure the power supply for the motor is connected and appropriate precautions are taken to
prevent damage to the Raspberry Pi and the motor.

2. Enable PWM on Raspberry Pi:


Open a terminal window on Raspberry Pi.
Enter the following command to edit the Raspberry Pi configuration:
```
sudo raspi-config
```
Navigate to "Interfacing Options" and select "PWM". Enable PWM and exit the configuration
tool.

3. Write Python Script for PWM:


Open a text editor (e.g., Nano) on Raspberry Pi.
Write a Python script to control the motor speed using PWM. Below is a sample script for
controlling a DC motor:
import RPi.GPIO as GPIO
import time

# Set GPIO mode and pins


GPIO.setmode(GPIO.BCM)
motor_pin = 18

# Set PWM frequency and duty cycle


frequency = 1000 # Hz
duty_cycle = 50 # 0-100 (%)

# Initialize PWM
GPIO.setup(motor_pin, GPIO.OUT)
pwm = GPIO.PWM(motor_pin, frequency)
pwm.start(duty_cycle)

try:
# Main loop
while True:
# Change duty cycle to control motor speed
new_duty_cycle = float(input("Enter new duty cycle (0-100): "))
pwm.ChangeDutyCycle(new_duty_cycle)
time.sleep(1)

except KeyboardInterrupt:
# Clean up GPIO on Ctrl+C
pwm.stop()
GPIO.cleanup()

4. Save and Run the Script:


Save the Python script with a suitable name (e.g., motor_control.py) in a desired directory on
Raspberry Pi.
Open a terminal window and navigate to the directory where the script is saved.
Run the script using the following command:
python3 motor_control.py

5. Test Motor Control:


Follow the prompts in the script to input new duty cycles (0-100%) and observe the
corresponding changes in motor speed.
Verify that the motor responds correctly to changes in duty cycle, thereby controlling its speed.

Result:

Thus, We have successfully controlled the speed of a motor using PWM with Raspberry Pi and
Python programming. We can now modify the script or experiment with different motors and
PWM configurations for various applications.

Note: Ensure to properly connect and handle the motor and power supply to avoid damage. Always
follow safety precautions, such as powering off the motor when not in use and providing adequate
cooling if running the motor for extended periods.
Experiment 5

Use sensors to measure temperature, humidity, light and distance

Aim: Use sensors to measure temperature, humidity, light, and distance, and display the data on
a web server hosted on Raspberry Pi.

Materials Required:
Raspberry Pi (any model)
DHT11 or DHT22 temperature and humidity sensor
Light-dependent resistor (LDR) or any light sensor
Ultrasonic distance sensor (e.g., HC-SR04)
Breadboard and jumper wires
Ethernet cable or Wi-Fi dongle (for connecting Raspberry Pi to the internet)
Monitor (optional, for initial setup)
USB keyboard and mouse (optional, for initial setup)

Procedure:

1. Setting up Raspberry Pi:


Follow the steps outlined in Experiment 1 to set up Raspberry Pi, ensuring it is connected to
the internet.
Install necessary software packages:
sudo apt update
sudo apt install python3-pip
sudo pip3 install adafruit-circuitpython-dht

2. Wiring the Sensors:


Connect the sensors to Raspberry Pi as follows:
DHT11/DHT22 temperature and humidity sensor:
Connect the VCC pin to 3.3V (or 5V) on Raspberry Pi.
Connect the data pin to GPIO pin (e.g., GPIO4).
Connect the GND pin to ground (GND) on Raspberry Pi.
Light-dependent resistor (LDR):
Connect one leg of the LDR to 3.3V (or 5V) on Raspberry Pi.
Connect the other leg to a GPIO pin (e.g., GPIO17).
Connect a resistor (e.g., 10kΩ) from the GPIO pin to ground (GND).
Ultrasonic distance sensor (HC-SR04):
Connect the VCC pin to 5V on Raspberry Pi.
Connect the GND pin to ground (GND) on Raspberry Pi.
Connect the Trig pin to a GPIO pin (e.g., GPIO23).
Connect the Echo pin to another GPIO pin (e.g., GPIO24).

3. Writing Python Script:


Create a Python script to read data from the sensors and display it on a web server. Below is an
example script (`sensor_data.py`):
import time
import board
import adafruit_dht
import RPi.GPIO as GPIO

# Initialize DHT sensor


dht_sensor = adafruit_dht.DHT22(board.D4)

# Initialize GPIO for LDR and Ultrasonic sensor


GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN)
GPIO.setup(23, GPIO.OUT)
GPIO.setup(24, GPIO.IN)

# Function to read temperature and humidity


def read_dht_sensor():
try:
temperature = dht_sensor.temperature
humidity = dht_sensor.humidity
return temperature, humidity
except Exception as e:
print("Error reading DHT sensor:", e)
return None, None

# Function to read light intensity


def read_light_sensor():
try:
# Add code to read from LDR
return None # Replace with actual reading
except Exception as e:
print("Error reading light sensor:", e)
return None

# Function to read distance


def read_distance_sensor():
try:
# Trigger the Ultrasonic sensor
GPIO.output(23, True)
time.sleep(0.00001)
GPIO.output(23, False)

# Wait for the echo response


while GPIO.input(24) == 0:
pulse_start = time.time()
while GPIO.input(24) == 1:
pulse_end = time.time()

# Calculate distance from time difference


pulse_duration = pulse_end - pulse_start
distance = pulse_duration 17150
return distance
except Exception as e:
print("Error reading distance sensor:", e)
return None

# Main function
if __name__ == "__main__":
try:
while True:
temperature, humidity = read_dht_sensor()
light_intensity = read_light_sensor()
distance = read_distance_sensor()

# Print sensor data


print("Temperature:", temperature)
print("Humidity:", humidity)
print("Light Intensity:", light_intensity)
print("Distance:", distance)

time.sleep(1)
except KeyboardInterrupt:
GPIO.cleanup()

4. Creating Web Interface:


Create a simple HTML/CSS page (`index.html`) to display the sensor data.
Use JavaScript (AJAX) to fetch the sensor data from the Python script and update the webpage
dynamically.

5. Running the Script:


Run the Python script (`sensor_data.py`) on Raspberry Pi:
```bash
python3 sensor_data.py
```

6. Accessing the Web Interface:


Open a web browser on any device connected to the same network as Raspberry Pi.
Enter the IP address of Raspberry Pi in the browser's address bar to access the web interface
and view the sensor data.

Result:

We have successfully used the sensors to measure temperature, humidity, light and distance

Note: By following these steps, we can set up a system to acquire data from temperature,
humidity, light, and distance sensors using Raspberry Pi and display the data on a web server,
facilitating industrial IoT applications such as environmental monitoring or facility management.
Experiment 6

Web-Based Hardware Control

Aim: To create a web-based interface for controlling hardware connected to Raspberry Pi.

Materials Required:
Raspberry Pi board
Components to be controlled (e.g., LEDs, motors)
Internet connection (Ethernet or Wi-Fi)
Computer with SSH client (e.g., PuTTY) installed

Software Required:
Python (pre-installed on Raspberry Pi)
Flask web framework (install using `sudo apt install python3-flask`)
GPIO library for Python (pre-installed on Raspberry Pi)
Text editor (e.g., nano, vim)

Procedure:

1. Prepare Raspberry Pi:


Ensure Raspberry Pi is set up and connected to the internet as per Experiment 1.

2. Install Flask:
Open a terminal on Raspberry Pi or connect to Raspberry Pi via SSH from your computer.
Install Flask using the following command:
sudo apt install python3-flask

3. Create Flask Web Application:


Create a new directory for your Flask application:
mkdir web_control
cd web_control
Create a new Python file for your Flask application (e.g., `app.py`) and open it in a text editor:
nano app.py

Write the following code to create a simple Flask web application:

from flask import Flask, render_template


import RPi.GPIO as GPIO
app = Flask(__name__)
# Set up GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)

@app.route('/')
def index():
return render_template('index.html')

@app.route('/on')
def turn_on():
GPIO.output(18, GPIO.HIGH)
return 'LED turned on'

@app.route('/off')
def turn_off():
GPIO.output(18, GPIO.LOW)
return 'LED turned off'

if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')

4. Create HTML Template:


Create a new directory named `templates` inside the `web_control` directory:
mkdir templates

Create a new HTML file named `index.html` inside the `templates` directory and open it in a
text editor:
nano templates/index.html

Write the following HTML code to create a simple web page with buttons to control the
hardware:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hardware Control</title>
</head>
<body>
<h1>Hardware Control</h1>
<form action="/on">
<button type="submit">Turn On</button>
</form>
<form action="/off">
<button type="submit">Turn Off</button>
</form>
</body>
</html>

5. Run Flask Application:


Save the changes to `app.py` and `index.html`.
Run the Flask application using the following command:
python3 app.py

6. Access Web Interface:


Open a web browser on your computer or mobile device.
Enter the IP address of your Raspberry Pi followed by port 5000 (e.g.,
`http://<RaspberryPi_IP>:5000`) in the address bar.
You should see the web page with buttons to control the hardware.

7. Test Hardware Control:


Click the "Turn On" button to turn on the hardware connected to GPIO pin 18.
Click the "Turn Off" button to turn off the hardware.

Result:

We have successfully created a web-based interface for controlling hardware connected to


Raspberry Pi. We can expand this project by adding more functionality and controlling additional
components.
Note: Ensure proper wiring and safety precautions are followed when connecting hardware to
Raspberry Pi GPIO pins.
Experiment 7

Connect IIoT Devices Through Cloud Using MQTT Protocol

Aim: To implement MQTT communication protocol for connecting IIoT devices to the cloud.

Materials Required:
Raspberry Pi (or any other suitable hardware platform)
Sensors or actuators compatible with Raspberry Pi
Internet connection
Cloud MQTT broker (e.g., HiveMQ, Mosquitto, AWS IoT Core)
MQTT client libraries (e.g., paho-mqtt for Python)
Computer with internet access for cloud setup

Procedure:

1. Setup Cloud MQTT Broker:


Choose a cloud-based MQTT broker service (e.g., HiveMQ, Mosquitto, AWS IoT Core).
Sign up for an account and create a new MQTT broker instance.
Note down the broker URL, port number, and authentication credentials (if required).

2. Install MQTT Client Library on Raspberry Pi:


Open a terminal on Raspberry Pi.
Install the MQTT client library (paho-mqtt) for Python using the following command:
pip install paho-mqtt

3. Write Python Code for MQTT Publisher:


Create a new Python script (e.g., `mqtt_publisher.py`) using a text editor on Raspberry Pi.
Write the code to publish sensor data to the MQTT broker. Replace `<broker_address>`,
`<port>`, `<username>`, `<password>`, `<topic>`, and `<sensor_data>` with appropriate values.
import paho.mqtt.publish as publish

broker_address = "<broker_address>"
port = <port>
username = "<username>"
password = "<password>"
topic = "<topic>"
sensor_data = "<sensor_data>"

publish.single(topic, sensor_data, hostname=broker_address, port=port,


auth={'username': username, 'password': password})
4. Write Python Code for MQTT Subscriber (Optional):
If you want to subscribe to MQTT topics and receive messages on Raspberry Pi, create a new
Python script (e.g., `mqtt_subscriber.py`) and write the code for subscribing.
Replace `<broker_address>`, `<port>`, `<username>`, `<password>`, and `<topic>` with
appropriate values.
import paho.mqtt.client as mqtt

def on_message(client, userdata, message):


print("Received message:", str(message.payload.decode("utf-8")))

broker_address = "<broker_address>"
port = <port>
username = "<username>"
password = "<password>"
topic = "<topic>"

client = mqtt.Client()
client.username_pw_set(username, password)
client.on_message = on_message
client.connect(broker_address, port)
client.subscribe(topic)
client.loop_forever()

5. Run MQTT Publisher Script:


Open a terminal on Raspberry Pi.
Navigate to the directory containing the `mqtt_publisher.py` script.
Run the script using the following command:
python mqtt_publisher.py

6. Monitor MQTT Messages (Optional):


If you have created a MQTT subscriber script, open a separate terminal on Raspberry Pi.
Navigate to the directory containing the `mqtt_subscriber.py` script.
Run the script using the following command:
python mqtt_subscriber.py

7. Verify Cloud Connection:


Check the cloud MQTT broker dashboard to verify if sensor data is being published
successfully.
If using a subscriber script, verify if messages are being received on Raspberry Pi.

Result:

We have successfully connected IIoT devices to the cloud using the MQTT protocol. We can
now extend this setup for more complex IIoT applications and experiments.

Note: Ensure that your Raspberry Pi and cloud MQTT broker have internet connectivity
throughout the experiment. Replace placeholder values (e.g., `<broker_address>`, `<port>`,
`<username>`, `<password>`, `<topic>`) with actual values obtained from your cloud MQTT
broker setup.
Experiment 8

Controlling IoT Devices Using Arduino

Aim: To develop a real-time monitoring and control system using Arduino to control IoT
devices.

Materials Required:
Arduino board (e.g., Arduino Uno)
LED(s)
Resistors (if required)
Breadboard
Jumper wires
USB cable (for Arduino programming)
Computer with Arduino IDE installed

Procedure:

1. Setup Arduino:
Connect the Arduino board to your computer using the USB cable.
Open the Arduino IDE on your computer.

2. Connect LED(s):
Connect the LED(s) to the Arduino board using the breadboard and jumper wires. Connect the
anode (longer leg) of the LED to a digital pin on the Arduino (e.g., Pin 13) and the cathode
(shorter leg) to the ground (GND) pin. Use resistors to limit current if necessary.

3. Write Arduino Sketch:


In the Arduino IDE, write the following Arduino sketch to control the LED(s):
// Define the pin connected to the LED
const int ledPin = 13;

// Setup function runs once when Arduino starts


void setup() {
// Initialize the digital pin as an output
pinMode(ledPin, OUTPUT);
}

// Loop function runs repeatedly


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

// Turn off the LED


digitalWrite(ledPin, LOW);
delay(1000); // Wait for 1 second
}

4. Upload Sketch to Arduino:


Verify the sketch for any errors by clicking the verify button (checkmark icon) in the Arduino
IDE.
Once verified, upload the sketch to the Arduino board by clicking the upload button (right
arrow icon). Ensure the correct board and port are selected in the Arduino IDE.

5. Monitor LED Control:


After uploading the sketch, the LED should start blinking on and off with a 1-second interval.

6. Testing:
Test the system by remotely controlling the LED using the IoT platform (if implemented) or
by manually interacting with the Arduino board.
Ensure the LED responds correctly to control commands and the system operates as expected.
Result:

Thus, We have successfully controlled the IoT devices with Arduino board

Note:
Modify the Arduino sketch as needed to control other IoT devices connected to the Arduino
board. Ensure to handle electronic components carefully and follow safety precautions when
working with hardware. Make sure to disconnect the Arduino from the power source when
making any changes to the circuitry.
Experiment 9

Create Wireless Network of Sensors Using Zigbee

Aim: To create a wireless network of sensors using Zigbee communication protocol.

Materials Required:
Raspberry Pi board (any model)
Zigbee modules (e.g., XBee Series 2)
Zigbee Explorer/Adapter (if needed for configuration)
Sensors (e.g., temperature, humidity, motion)
Jumper wires
Breadboard (if needed)
USB power supply
Computer with XCTU software installed (for Zigbee module configuration)

Procedure:

1. Prepare Zigbee Modules:


If Zigbee modules are not pre-configured, connect them to your computer using the Zigbee
Explorer/Adapter and use XCTU software to configure them. Set one module as the coordinator
and others as end devices or routers.

2. Prepare Raspberry Pi:


Set up Raspberry Pi according to Experiment 1 in the lab manual to ensure it is properly
configured and connected to the internet.

3. Connect Zigbee Modules to Raspberry Pi:


Connect Zigbee modules to Raspberry Pi using UART communication. Make sure to connect
the TX pin of the Zigbee module to the RX pin of Raspberry Pi, and vice versa, using jumper
wires.

4. Write Python Script for Zigbee Communication:


Write Python scripts to communicate with Zigbee modules using the serial port. You can use
libraries like PySerial for serial communication.
Sample Python code snippets for sending and receiving data with Zigbee modules:
import serial
import time
ser = serial.Serial('/dev/ttyS0', 9600) # Open serial port (change ttyS0 to appropriate
port)
ser.flushInput()

def send_data(data):
ser.write(data.encode())

def receive_data():
if ser.in_waiting > 0:
return ser.readline().decode().rstrip()

# Example usage
send_data("Hello from Raspberry Pi!")
time.sleep(1)
received_data = receive_data()
print("Received:", received_data)

5. Connect Sensors to Zigbee Modules:


Connect sensors (e.g., temperature, humidity, motion) to the Zigbee modules as per the sensor
specifications and module capabilities. Ensure proper voltage levels and signal compatibility.

6. Collect and Transmit Sensor Data:


Write Python scripts to read sensor data and transmit it wirelessly using Zigbee modules.
Include error handling and data formatting as necessary.
Sample code snippet for collecting sensor data and transmitting it:
# Read sensor data (example)
temperature = 25.5 # Example temperature reading
humidity = 60.0 # Example humidity reading

# Format data for transmission


data_to_send = f"Temperature: {temperature}°C, Humidity: {humidity}%"

# Send data wirelessly using Zigbee module


send_data(data_to_send)

7. Receive and Process Sensor Data:


Write Python scripts to receive sensor data from Zigbee modules on the Raspberry Pi, process
it, and store or display as required.
Sample code snippet for receiving and processing sensor data:
# Receive and process data
received_data = receive_data()
if received_data:
print("Received:", received_data)
# Process received data (parse, analyze, store, etc.)

8. Test the Wireless Sensor Network:


Deploy the sensors and Zigbee modules in the desired locations.
Run the Python scripts on Raspberry Pi and observe the transmission and reception of sensor
data.
Verify that the sensor data is correctly received and processed by Raspberry Pi.

Result:

Thus, We have successfully created a wireless network of sensors using Zigbee communication
protocol. Experiment with different sensors, data processing techniques, and applications to
further explore the capabilities of your IIoT system.

Note: Ensure to handle the hardware components carefully and double-check connections and
configurations to avoid damage or malfunction.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy