Industrial IoT Lab Manual
Industrial IoT Lab Manual
(Autonomous)
Ongole
Lab Manual
on
Industrial IoT
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
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.
3. Familiarization with GPIO pins and control hardware through GPIO pins.
7. Connect IOT devices through cloud using IoT protocol such as MQTT.
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.
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
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:
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
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:
2. Gather Components:
Gather the breadboard, LED, resistor, and jumper wires.
import time
try:
while True:
# Turn LED on
GPIO.output(led_pin, GPIO.HIGH)
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
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.
# 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()
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
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:
# Main function
if __name__ == "__main__":
try:
while True:
temperature, humidity = read_dht_sensor()
light_intensity = read_light_sensor()
distance = read_distance_sensor()
time.sleep(1)
except KeyboardInterrupt:
GPIO.cleanup()
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
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:
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
@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')
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>
Result:
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:
broker_address = "<broker_address>"
port = <port>
username = "<username>"
password = "<password>"
topic = "<topic>"
sensor_data = "<sensor_data>"
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()
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
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.
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
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:
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)
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.