MECHATRONICS & IoT
LABORATARY MANUAL
INDEX
S.No EXPERIMENT NAME Page No Faculty Sign
Mechatronics Experiments
1. Measurement of Linear/Angular of Position, Direction
and Speed using Transducers.
2. Measurement of Pressure, Temperature and Force using
Transducers.
3. Speed and Direction control of DC Servomotor, AC
Servomotor and Induction motors.
4. Addition, Subtraction and Multiplication Programming
in 8051.
5. Programming and Interfacing of Stepper motor and DC
motor using 8051/PLC.
6. Programming and Interfacing of Traffic Light Interface
using 8051.
7. Sequencing of Hydraulic and Pneumatic circuits.
8. Sequencing of Hydraulic, Pneumatic and Electro-
pneumatic circuits using Software.
9. Electro-pneumatic/hydraulic control using PLC.
10. Vision based image acquisition and processing
technique for inspection and
IoT Experiments
1. Familiarization with concept of IoT and its open-source
microcontroller/SBC.
2. Write a program to turn ON/OFF motor using
microcontroller/SBC through internet.
3. Write a program to interface sensors to display the data
on the screen through internet.
4. Interface the sensors with microcontroller/SBC and
write a program to turn ON/OFF Solenoid valve
through internet when sensor data is detected.
5. To interface sensor with microcontroller/SBC and
write a program to turn ON/OFF
6. To interface Bluetooth/Wi-Fi with microcontroller/SBC
and write a program to send sensor
data to smart phone using Bluetooth/Wi-Fi.
Experiment 1: Measurement of Linear/Angular Position, Direction, and
Speed using Transducers
AIM:
To measure the linear/angular position, direction, and speed using transducers and
analyse their performance.
MATERIALS REQUIRED:
1. Linear transducer (e.g., LVDT)
2. Angular transducer (e.g., potentiometer)
3. Tachometer
4. Data acquisition system (DAQ)
5. Oscilloscope
6. Connecting wires
7. Power supply
DESCRIPTION:
In this experiment, we aim to study the measurement of different mechanical
parameters such as position, direction, and speed using transducers. Transducers convert
physical quantities into electrical signals that can be measured. The linear variable
differential transformer (LVDT) is used to measure linear displacement, while a rotary
potentiometer is used for angular displacement. The speed of the system is measured
using a tachometer, which converts rotational speed into an electrical signal.
PROCEDURE:
1. Setup the LVDT for Linear Measurement:
Connect the LVDT to the data acquisition system.
Move the core of the LVDT and observe the voltage output corresponding
to different displacements.
Plot a graph of voltage vs. displacement to verify linearity.
2. Setup the Potentiometer for Angular Measurement:
Attach the potentiometer to a rotating shaft.
Measure the voltage output as the shaft is rotated.
Record the voltage readings for different angles and plot the results.
3. Speed Measurement using Tachometer:
Connect the tachometer to a rotating motor or wheel.
Measure the voltage output corresponding to different speeds of rotation.
Calculate the speed of rotation using the formula:
Speed = Voltage/Calibration factor of Tachometer
4. Direction Detection:
Use the output of the potentiometer or tachometer to detect the direction of
rotation. The sign of the voltage or changes in signal behaviour can
indicate direction.
5. Analyse the Results:
Compare the measured values with the theoretical values for position,
speed, and direction.
RESULT:
The position, speed, and direction were successfully measured using transducers. The
graphs plotted for voltage vs. displacement and voltage vs. speed demonstrate the
performance of the transducers. The results align with theoretical predictions, validating
the use of LVDT and potentiometers for position measurements and tachometers for
speed measurements.
Experiment 2: Measurement of Pressure, Temperature, and Force
using Transducers
AIM:
To measure pressure, temperature, and force using appropriate transducers.
MATERIALS REQUIRED:
1. Pressure transducer
2. Temperature sensor (Thermocouple or RTD)
3. Force transducer (Load cell)
4. Multi-meter
5. Data acquisition system
6. Power supply
DESCRIPTION:
This experiment aims to study the measurement of physical parameters such as
pressure, temperature, and force using transducers. Pressure transducers convert
pressure into electrical signals, temperature sensors (such as thermocouples) detect
changes in temperature, and load cells measure force applied.
PROCEDURE:
1. Pressure Measurement:
Connect the pressure transducer to a fluid system.
Measure the output voltage at different pressure levels using the DAQ system.
Plot the pressure vs. voltage graph.
2. Temperature Measurement:
Connect the thermocouple to the DAQ and place it in an environment
with varying temperatures.
Record the voltage output corresponding to the temperature changes and
calibrate the sensor to get temperature values.
3. Force Measurement:
Attach the load cell to a mechanical system to measure applied force.
Measure the output signal from the load cell and calculate the force using
the calibration factor.
RESULT:
Pressure, temperature, and force were successfully measured using the respective
transducers. The transducer performance was validated with the calibration charts
obtained.
Experiment 3: Speed and Direction Control of DC Servomotor, AC
Servomotor, and Induction Motors
AIM:
To control the speed and direction of DC servomotors, AC servomotors, and induction
motors.
MATERIALS REQUIRED:
1. DC servomotor
2. AC servomotor
3. Induction motor
4. Motor driver circuits
5. Microcontroller (e.g., Arduino or 8051)
6. Power supply
7. Oscilloscope
DESCRIPTION:
This experiment focuses on controlling the speed and direction of various motors
using external inputs. DC servomotors allow precise control of position and speed. AC
servomotors and induction motors are used in industrial applications for speed and
torque control.
PROCEDURE:
1. DC Servomotor Control:
Connect the servomotor to the motor driver and microcontroller.
Write code to control the speed by varying the PWM signal.
Measure the motor speed at different PWM duty cycles.
2. AC Servomotor Control:
Connect the AC servomotor to the driver circuit.
Control the speed by adjusting the input frequency and voltage.
Measure the motor speed at various input frequencies.
3. Induction Motor Control:
Connect the induction motor to a Variable Frequency Drive (VFD).
Adjust the motor speed by changing the input frequency.
Measure speed using a tachometer.
4. Direction Control:
Reverse the direction of rotation by changing the polarity of the input for the DC
and AC motors.
For induction motors, use the VFD to change direction.
PROGRAM CODING:
Code for controlling a DC motor using PWM:
include <Servo.h>
Servo myservo;
void setup() {
myservo.attach(9);
}
void loop() {
myservo.write(90); // Control speed and direction
}
RESULT:
The speed and direction of the DC servomotor, AC servomotor, and induction motor
were successfully controlled using the programmed methods and VFD.
Experiment 4: Addition, Subtraction, and Multiplication Programming
in 8051
AIM:
To write assembly language programs for performing addition, subtraction, and
multiplication on the 8051 microcontrollers.
MATERIALS REQUIRED:
1. 8051 development board
2. Keil µVision software
3. Power supply
4. Connecting cables
DESCRIPTION:
This experiment involves basic arithmetic operations using assembly language on
the 8051 microcontrollers. Simple programs for addition, subtraction, and multiplication
will be written and tested.
PROCEDURE:
1. Addition Program:
Write a program to add two 8bit numbers.
Load the first number into a register and the second into another.
Use the ADD instruction to add the numbers and store the result.
2. Subtraction Program:
Load the minuend and subtrahend into registers.
Use the SUBB instruction to subtract the numbers and store the result.
3. Multiplication Program:
Load the multiplicand and multiplier into registers.
Use the MUL AB instruction to multiply the numbers.
PROGRAM CODING:
Example of addition in 8051 assembly:
MOV A, #25h; Load first number
ADD A, #15h; Add second
number MOV R0, A; Store result
in R0
RESULT:
The addition, subtraction, and multiplication programs were successfully executed on
the 8051 microcontrollers.
Experiment 5: Programming and Interfacing of Stepper Motor and DC
Motor using 8051/PLC
AIM:
To interface and control a stepper motor and DC motor using 8051/PLC.
MATERIALS REQUIRED:
1. Stepper motor
2. DC motor
3. 8051 microcontroller or PLC
4. Motor driver (ULN2003)
5. Power supply
DESCRIPTION:
This experiment involves interfacing a stepper motor and a DC motor with the
8051 microcontroller or PLC. The microcontroller/PLC will control the speed and
direction of the motors.
PROCEDURE:
1. Stepper Motor Control:
Connect the stepper motor to the driver and 8051.
Write a program to rotate the motor stepwise.
Control the speed by adjusting the delay between steps.
2. DC Motor Control:
Interface the DC motor with the 8051/PLC using a motor driver.
Write code to control the motor speed using PWM.
PROGRAM CODING:
void stepperMotor() {
P1 = 0x01; delay();
P1 = 0x02; delay();
P1 = 0x04; delay();
P1 = 0x08; delay();
}
RESULT:
The stepper and DC motors were successfully controlled using the 8051 microcontroller
and PLC.
Experiment 6: Programming and Interfacing of Traffic Light Interface
using 8051
AIM:
To design and implement a traffic light control system using the 8051 microcontrollers.
MATERIALS REQUIRED:
1. 8051 microcontrollers
2. LEDs (Red, Yellow, Green)
3. Resistors
4. Breadboard
5. Power supply
DESCRIPTION:
This experiment involves the design of a traffic light system using 8051. LEDs will
represent the traffic signals, and the microcontroller will control the timing of the lights.
PROCEDURE:
1. Connection Setup:
Connect the LEDs to the microcontroller ports.
Write a program to control the lights in the traffic signal sequence (Red > Green
> Yellow).
2. Programming:
Set timers for each light phase and transition between them based on delays.
PROGRAM CODING:
void trafficLight() {
P1 = 0x01; // Red light
delay();
P1 = 0x02; // Green light
delay();
P1 = 0x04; // Yellow
light delay();
}
RESULT:
The traffic light system was successfully programmed and implemented using the 8051
microcontrollers.
Experiment 7: Sequencing of Hydraulic and Pneumatic Circuits
AIM:
To design and sequence hydraulic and pneumatic circuits for automated control.
MATERIALS REQUIRED:
1. Hydraulic and pneumatic actuators
2. Valves
3. Flow control circuits
4. Air compressor
5. Hydraulic fluid system
DESCRIPTION:
This experiment aims to develop automated sequences for hydraulic and pneumatic
actuators. The sequence will be designed for a specific task using actuators and valves
controlled by manual or automated inputs.
PROCEDURE:
1. Circuit Setup:
Connect the actuators to the valves and set up the hydraulic/pneumatic system.
Define the sequence of operations for the actuators.
2. Operation:
Control the valves to operate the actuators in the desired sequence.
Adjust the flow rate for each actuator using flow control valves.
RESULT:
The hydraulic and pneumatic circuits were successfully sequenced, and the actuators
performed the desired operations.
Experiment 8: Sequencing of Hydraulic, Pneumatic, and
Electropneumatic Circuits using Software
AIM:
To sequence hydraulic, pneumatic, and electropneumatic circuits using simulation
software.
MATERIALS REQUIRED:
1. Simulation software (e.g., Fluid SIM, Automation Studio)
2. Computer system
DESCRIPTION:
In this experiment, software will be used to design and simulate hydraulic,
pneumatic, and electropneumatic circuits. The software allows for testing various
sequences before actual implementation.
PROCEDURE:
1. Software Setup:
Launch the simulation software and select the components for the circuit.
Design the hydraulic/pneumatic circuit on the software platform.
2. Simulation:
Program the sequence of operations and simulate the circuit's behaviour.
Analyse the output to ensure the correct functioning of the system.
RESULT:
The hydraulic, pneumatic, and electropneumatic circuits were successfully sequenced
using simulation software.
Experiment 9: Electropneumatic/Hydraulic Control using PLC
AIM:
To control an electropneumatic or hydraulic system using a Programmable Logic
Controller (PLC).
MATERIALS REQUIRED:
1. PLC unit
2. Electropneumatic actuators
3. Solenoid valves
4. Sensors
5. Power supply
DESCRIPTION:
This experiment involves controlling an electropneumatic or hydraulic system using a
PLC. The PLC will automate the sequence of operations for the system.
PROCEDURE:
1. PLC Programming:
Connect the actuators and solenoid valves to the PLC.
Write a ladder logic program to control the sequence of operations.
2. Execution:
Run the PLC program and observe the system's behaviour.
Adjust the program as necessary for proper timing and sequencing.
PROGRAM CODING:
Sample Ladder Logic for a pneumatic control system:
|--[ Start ]--( )---[ Actuate Cylinder ]--|
RESULT:
The electropneumatic/hydraulic system was successfully controlled using the PLC.
Experiment 10: Vision Based Image Acquisition and Processing
Technique for Inspection and Classification
AIM:
To implement a vision-based image acquisition system for object inspection and
classification.
MATERIALS REQUIRED:
1. Camera module
2. Image processing software (e.g., MATLAB, OpenCV)
3. Computer system
4. Test objects
DESCRIPTION:
This experiment uses image acquisition and processing techniques to inspect and
classify objects. A camera captures the image, and software algorithms process it to
identify defects or classify objects based on predefined criteria.
PROCEDURE:
1. Image Acquisition:
Set up the camera to capture images of test objects.
Store the images for processing.
2. Image Processing:
Use image processing algorithms to detect features like edges, colors, and shapes.
Apply filters to enhance the image quality.
3. Classification:
Develop algorithms to classify the objects based on features.
Output the classification results.
PROGRAM CODING:
Sample MATLAB code for edge detection:
matlab
img = imread('object.jpg');
edges = edge(rgb2gray(img), 'Canny');
imshow(edges);
RESULT:
The vision-based system successfully acquired and processed images for object
inspection and classification.
Experiment 1: Familiarization with concept of IoT and its open
source microcontroller/SBC.
Aim:
To understand the basic concepts of the Internet of Things (IoT) and familiarize with
opensource microcontrollers and SingleBoard Computers (SBC) like Arduino and Raspberry
Pi, commonly used in IoT systems.
Materials Required:
Arduino UNO / Raspberry Pi (or any other opensource microcontroller or SBC)
USB cable
Laptop/PC with Arduino IDE or Raspberry Pi OS installed
Sensors (e.g., DHT11 for temperature and humidity, or any other available sensor)
Jumper wires
Breadboard
Power supply
Description:
This experiment introduces the fundamentals of IoT, which involves connecting devices over
the internet to exchange data and perform automated tasks. The practical implementation will
include setting up a basic IoT system using an opensource microcontroller or SBC, such as
Arduino or Raspberry Pi. You will learn to program the device, interface sensors, and view
sensor data in real time.
Procedure:
1. Setup the Microcontroller/SBC:
Connect your Arduino or Raspberry Pi to your laptop/PC using a USB cable.
Install the Arduino IDE or boot up Raspberry Pi OS as needed.
2. Connecting the Sensor:
Attach the sensor (e.g., DHT11) to the microcontroller using jumper wires and a breadboard.
For Arduino: Connect the sensor pins (VCC to 5V, GND to GND, Data to a digital pin).
For Raspberry Pi: Connect the sensor to GPIO pins.
3. Write and Upload the
Code: For Arduino:
Open the Arduino IDE and write a simple code to read data from the sensor.
Use the `DHT` library to interface with the DHT11 sensor.
For Raspberry Pi:
Open the terminal and write a Python script to read sensor data using the appropriate GPIO
library.
4. Run the Code:
Upload the code to Arduino or execute the Python script on Raspberry Pi.
Observe the realtime data from the sensor on the serial monitor (for Arduino) or terminal
(for Raspberry Pi).
5. Optional IoT Communication:
Set up an IoT platform (such as ThingSpeak or Blynk) to send the sensor data to the cloud
for remote monitoring.
Coding (for Arduino using DHT sensor):
include "DHT.h"
define DHTPIN 2 // Pin where the DHT sensor is
connected define DHTTYPE DHT11 // Type of sensor
DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
float temperature =
dht.readTemperature(); float humidity =
dht.readHumidity();
if (isnan(temperature) || isnan(humidity)) {
Serial.println("Failed to read from DHT
sensor!");
return;
}
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.print(" °C, Humidity: ");
Serial.print(humidity);
Serial.println(" %");
delay(2000); // Wait 2 seconds between readings
}
Result:
After successfully completing this experiment, you should be able to:
Understand the core concepts of IoT and the role of
microcontrollers/SBCs. Interact with sensors and gather realtime data.
(Optional) Send sensor data to an IoT platform for remote monitoring.
Experiment 2: Write a program to turn ON/OFF motor using
microcontroller/SBC through internet.
Aim:
To write a program that controls a motor (turn ON/OFF) using a microcontroller or Single
Board Computer (SBC) via the internet.
Materials Required:
Microcontroller/SBC (e.g., Arduino, Raspberry Pi)
Motor (DC motor or relaycontrolled motor)
Motor Driver (e.g., L298N, ULN2003)
WiFi Module (e.g., ESP8266 or builtin WiFi on Raspberry Pi)
Power Supply
Jumper Wires
Breadboard
Internet connection
Laptop/PC with necessary software (Arduino IDE, Python for Raspberry Pi, etc.)
Description:
This experiment demonstrates how to control a motor through the internet using a
microcontroller (Arduino) or SBC (Raspberry Pi). By establishing an internet connection, the
system receives control signals (ON/OFF) and then activates or deactivates the motor
accordingly. This simulates a basic IoT application where remote control of hardware devices
is possible via a web interface or a mobile application.
Procedure:
1. Setup the Circuit:
Connect the motor to the motor driver (L298N or ULN2003).
Connect the motor driver to the Arduino pins for motor control (e.g., pin 9 for motor
ON/OFF).
Attach the ESP8266 WiFi module to the Arduino for internet connectivity (TX, RX, VCC,
GND).
Power up the motor driver and Arduino with appropriate power sources.
2. Configure the ESP8266:
Write a program to connect the ESP8266 to your WiFi network using the necessary
credentials (SSID and password).
Set up a simple web server on the ESP8266 module to listen for commands (ON/OFF) sent
via the internet.
3. Write the Program:
Create a webbased interface (or use a thirdparty service like Blynk) to send motor control
commands (ON/OFF) to the Arduino.
In the Arduino code, listen for these commands and toggle the motors state based on the
received input.
4. Upload and Run the Code:
Upload the code to the Arduino using the Arduino IDE.
Power the system and access the web interface to send control signals.
Observe the motor turning ON/OFF based on the commands sent through the internet.
Code:
include <ESP8266WiFi.h>
const char ssid = "your_SSID";
const char password =
"your_PASSWORD"; WiFiServer
server(80);
int motorPin = 9;
void setup() {
pinMode(motorPin, OUTPUT);
digitalWrite(motorPin, LOW);
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{ delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
server.begin();
}
void loop() {
WiFiClient client =
server.available(); if (client) {
String request = client.readStringUntil(\r);
client.flush();
if (request.indexOf("/ON") != 1) {
digitalWrite(motorPin, HIGH);
}
if (request.indexOf("/OFF") != 1) {
digitalWrite(motorPin, LOW);
}
client.println("HTTP/1.1 200 OK");
client.println("ContentType: text/html");
client.println(""); client.println("<!
DOCTYPE HTML>");
client.println("<html>");
client.println("<button onclick=\"location.href=/ON\">Turn ON</button>");
client.println("<button onclick=\"location.href=/OFF\">Turn OFF</button>");
client.println("</html>");
client.stop();
}
}
Result:
Successfully implemented the program to control a motor using a microcontroller/SBC via the
internet. The motor can be remotely turned ON or OFF using a web interface.
Experiment 3: Write a program to interface sensors to display the
data on the screen through internet.
Aim:
To interface sensors with a microcontroller and display the sensor data on a screen through an
internet connection.
Materials Required:
Microcontroller (e.g., Arduino, ESP8266, or Raspberry
Pi) Sensor (e.g., Temperature sensor, Humidity sensor,
etc.) Breadboard
Connecting wires
Resistors (if necessary)
WiFi module (if not using an internetenabled microcontroller like
ESP8266) Power supply (e.g., USB or battery)
Laptop/PC with Arduino IDE (or relevant programming
environment) Internet connection
LCD display (optional) or Web Dashboard for visualizing the data
Description:
This experiment aims to demonstrate the process of interfacing sensors with a microcontroller
and transmitting the data over the internet. Using the Internet of Things (IoT) principles, the
data will be sent to a web server or cloud platform where it can be accessed and visualized
remotely. The microcontroller will read data from the connected sensor and transmit it
through a WiFi network. The transmitted data will then be displayed on a screen (LCD or
web dashboard).
Procedure:
1. Sensor Interfacing:
Connect the sensor to the microcontroller. For example, if you are using a temperature
sensor (DHT11), connect the sensors data pin to a digital pin of the microcontroller (e.g., pin
D2 on Arduino), and connect the power and ground pins appropriately.
If using a microcontroller without native WiFi support, connect a WiFi module (e.g.,
ESP8266) to the microcontroller.
2. Setting up WiFi:
Ensure the microcontroller is connected to a WiFi network. Configure the WiFi credentials
within the code to enable communication with the internet.
3. Write the Program:
Write a program that reads data from the sensor and sends it to an internet server or platform.
You can use platforms like ThingSpeak, Blynk, or any custom web server for this purpose.
4. Data Transmission:
Use an appropriate protocol such as HTTP or MQTT to transmit the sensor data to the
internet.
5. Display the Data:
The received data can be displayed on an LCD screen or through a web dashboard where
you can monitor the sensor readings remotely.
Coding (Sample Code using ESP8266 and DHT11):
include <ESP8266WiFi.h>
include <DHT.h>
define DHTPIN 2 // Pin connected to the DHT sensor
define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
// Replace with your network credentials
const char ssid = "your_SSID";
const char password = "your_PASSWORD";
// Replace with your server
const char server =
"your_server.com"; WiFiClient client;
void setup() {
Serial.begin(115200);
dht.begin();
// Connect to WiFi
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{ delay(1000);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println(WiFi.localIP());
}
void loop() {
// Read temperature and humidity
float h = dht.readHumidity();
float t = dht.readTemperature();
// Check if any reads failed
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT
sensor!"); return;
}
// Print the data to serial monitor
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" C");
// Connect to server and send the data
if (client.connect(server, 80)) {
client.print("GET /update?temp=");
client.print(t);
client.print("&hum=");
client.print(h);
client.println(" HTTP/1.1");
client.println("Host: your_server.com");
client.println("Connection: close");
client.println();
}
delay(2000); // Send data every 2 seconds
}
Result:
After successful execution of the program, the sensor data (e.g., temperature and humidity)
will be transmitted over the internet and displayed on the screen, either as an LCD output or a
webbased dashboard. The data can be monitored remotely from any location with internet
access.
Experiment 4: Interface the sensors with microcontroller/SBC
and write a program to turn ON/OFF Solenoid valve through
internet when sensor data is detected.
Aim:
To interface sensors with a microcontroller or Single Board Computer (SBC) and write a
program to turn ON/OFF a solenoid valve over the internet based on sensor data detection.
Materials Required:
Microcontroller (e.g., Arduino) or SBC (e.g., Raspberry Pi)
Solenoid Valve
Sensor (e.g., temperature sensor, proximity sensor, etc.)
WiFi module (e.g., ESP8266, ESP32)
Relay Module (to control solenoid valve)
Jumper wires
Breadboard
Power supply
Internet connection
Computer with Arduino IDE (or any required software for SBC)
Description:
In this experiment, we will use a sensor to detect specific environmental data and send this
information to a microcontroller/SBC. When the sensor detects a specific threshold value, the
microcontroller/SBC will send a signal to a solenoid valve to turn it ON or OFF. This will be
achieved over the internet, allowing remote control and monitoring.
Procedure:
1. Circuit Setup:
Connect the sensor to the input pins of the microcontroller/SBC.
Connect the solenoid valve to the relay module and interface the relay with the output pin
of the microcontroller/SBC.
Connect the WiFi module to enable internet connectivity for remote control.
2. Microcontroller/SBC Setup:
Install necessary libraries for the sensor and WiFi communication.
Configure the microcontroller/SBC to communicate with the solenoid valve through the
relay.
3. Programming:
Write the code to read sensor data.
Set a threshold value for the sensor data that will trigger the solenoid valve.
Implement internet communication to control the solenoid valve remotely.
4. Testing:
Upload the code to the microcontroller/SBC.
Open the serial monitor to observe sensor data.
Test by manually adjusting sensor conditions (e.g., heating a temperature sensor) to observe
whether the solenoid valve turns ON/OFF.
Code:
include <ESP8266WiFi.h>
include <BlynkSimpleEsp8266.h>
char auth[] = "YourAuthToken"; // Blynk authentication token
char ssid[] = "YourNetworkName"; // WiFi network name
char pass[] = "YourPassword"; // WiFi password
int sensorPin = A0; // Sensor connected to analog pin
int relayPin = D1; // Relay module connected to digital pin
int sensorValue; // Variable to store sensor value
void setup() {
pinMode(sensorPin, INPUT);
pinMode(relayPin, OUTPUT);
Blynk.begin(auth, ssid, pass); // Connect to Blynk IoT
platform Serial.begin(9600);// Begin serial communication
}
void loop() {
Blynk.run(); // Run Blynk to check for commands
sensorValue = analogRead(sensorPin); // Read sensor value
Serial.println(sensorValue); // Print sensor value for monitoring
if (sensorValue > 500) { // Threshold value
digitalWrite(relayPin, HIGH); // Turn ON solenoid valve
} else {
digitalWrite(relayPin, LOW); // Turn OFF solenoid valve
}
}
Result:
The sensor data is successfully read and monitored by the microcontroller/SBC.
Based on the sensor data threshold, the solenoid valve is controlled remotely through the
internet.
The solenoid valve turns ON/OFF based on the detection of the sensors threshold value.
Experiment 5: To interface sensor with microcontroller/SBC and
write a program to turn ON/OFF Linear/Rotary Actuator
through IoT when sensor data is detected.
Aim:
To interface a sensor with a microcontroller (e.g., Arduino, Raspberry Pi) or a
singleboard computer (SBC) and write a program to turn ON/OFF a linear or rotary actuator
through IoT when sensor data is detected.
Materials Required:
Microcontroller/SBC: Arduino, Raspberry Pi, or similar
Sensor: (e.g., Temperature sensor, Ultrasonic sensor, IR sensor)
Actuator: Linear actuator or Rotary actuator (DC motor, servo motor)
IoT Module: ESP8266/ESP32 or WiFi module
Resistors, jumper wires, and breadboard
Power supply: 5V or as per the hardware specification
Computer with Arduino IDE/Python IDE for programming
Cloud platform for IoT: (e.g., Blynk, Thingspeak, Adafruit IO, or a custom IoT cloud)
Internet connection
Description:
In this experiment, we will interface a sensor with a microcontroller or SBC and capture
realtime data. When the sensor detects a certain condition (e.g., a threshold value is crossed),
an actuator (linear or rotary) will be turned ON or OFF via the IoT system. The actuator will
be controlled remotely using an IoT platform, allowing for realtime monitoring and
interaction through the cloud.
Procedure:
1. Setup of the Microcontroller/SBC:
Connect the sensor to the microcontroller/SBC using appropriate pins (e.g., analog or digital
pins).
Connect the actuator (linear/rotary) to a motor driver or directly to the
microcontroller/SBC if supported.
Attach the IoT module (ESP8266/ESP32) to establish wireless communication with the
cloud platform.
2. Sensor and Actuator Wiring:
Ensure the sensor output pin is connected to an input pin on the microcontroller.
The actuators power and control pins should be connected through a motor driver or directly
controlled by the SBC.
3. Programming the Microcontroller/SBC:
Write a program to read data from the sensor continuously.
When the sensor detects a particular value (e.g., temperature > 30°C or object within 10 cm),
trigger the actuator to turn ON.
The program should also send sensor data to an IoT platform, enabling realtime monitoring.
4. IoT Cloud Configuration:
Create an account on the chosen IoT platform (e.g., Blynk, Adafruit IO).
Set up a project to receive data from the microcontroller/SBC and display it on a dashboard.
Program the IoT cloud to send a control signal to the microcontroller when a command is
given (e.g., turn the actuator OFF remotely).
5. Run the System:
Upload the code to the microcontroller/SBC.
Ensure the system is connected to the internet and the IoT platform is receiving sensor data.
Test the system by manually triggering the sensor and observing the actuators response
through both local control and IoT cloud control.
Coding (Arduino Example):
include <ESP8266WiFi.h> // Include the ESP8266 library for
WiFi include <BlynkSimpleEsp8266.h> // Include Blynk library
for IoT
// Define sensor and actuator pins
const int sensorPin = A0;
const int actuatorPin = D1;
// Blynk authentication token
char auth[] = "YourBlynkAuthToken";
char ssid[] = "YourSSID";
char pass[] =
"YourPassword"; void setup()
{
pinMode(sensorPin, INPUT); // Sensor as input
pinMode(actuatorPin, OUTPUT); // Actuator as output
Blynk.begin(auth, ssid, pass); // Initialize Blynk
}
void loop() {
Blynk.run(); // Run Blynk
int sensorValue = analogRead(sensorPin); // Read sensor data
if (sensorValue > thresholdValue) { // Check if sensor exceeds threshold
digitalWrite(actuatorPin, HIGH); // Turn ON actuator
Blynk.virtualWrite(V1, sensorValue); // Send sensor data to Blynk
} else {
digitalWrite(actuatorPin, LOW); // Turn OFF actuator
}
}
Result:
Upon successful execution of the experiment:
The sensor data will be read by the microcontroller and displayed on the IoT platform in
realtime.
When the sensor detects a specific condition (e.g., crossing a threshold), the actuator will turn
ON or OFF.
Remote control of the actuator will be achieved via the IoT cloud platform, and the actuators
status can be observed and controlled from anywhere.
Experiment 6: To interface Bluetooth/Wifi with
microcontroller/SBC and write a program to send sensor data to
smart phone using Bluetooth/wifi.
Aim:
To interface a Bluetooth/WiFi module with a microcontroller or Single Board Computer
(SBC) and write a program to send sensor data to a smartphone.
Materials Required:
1. Microcontroller or SBC (e.g., Arduino, ESP32, Raspberry Pi)
2. Bluetooth module (e.g., HC05) or WiFi module (e.g., ESP8266/ESP32)
3. Sensor (e.g., DHT11 for temperature and humidity, or any other sensor)
4. Smartphone with a Bluetooth/WiFi terminal app (e.g., Serial Bluetooth Terminal, IoT
MQTT Dashboard)
5. Jumper wires
6. Breadboard
7. USB Cable for programming
8. Power supply (if required)
Description:
In this experiment, we will interface a Bluetooth or WiFi module with a microcontroller/SBC
to communicate sensor data to a smartphone. The sensor will collect data (like temperature,
humidity, or any other measurable quantity), which will then be sent wirelessly to the
smartphone via Bluetooth or WiFi.
For Bluetooth, we'll use the HC05 module, and for WiFi communication, an ESP8266 or
ESP32 module will be utilized. Data will be sent using either Bluetooth serial communication
or over WiFi using protocols like HTTP or MQTT.
Procedure:
Step 1: Setting Up the Circuit
1. Connect the Sensor:
Connect the sensor (e.g., DHT11) to the microcontroller/SBC. Typically, you'll connect the
VCC, GND, and signal/data pins to the appropriate pins on the microcontroller.
2. Connect Bluetooth/WiFi
Module: For Bluetooth (HC05):
Connect the VCC and GND of the Bluetooth module to the 5V and GND pins of the
microcontroller.
Connect the TX of the Bluetooth module to the RX of the microcontroller, and the
RX to the TX pin.
For WiFi (ESP8266/ESP32):
Connect the ESP8266/ESP32 to the microcontroller or use the onboard capabilities of
ESP32.
For ESP8266: VCC → 3.3V, GND → GND, TX → RX, RX → TX.
3. Power On: Power up the setup using a USB cable or external power supply.
Step 2: Coding and Uploading the Program
For Bluetooth Communication:
Write a program that reads data from the sensor and sends it over the serial connection to the
Bluetooth module.
For example, if you're using an Arduino, use the `Serial.begin()` function to set up serial
communication and use the `Serial.print()` function to send data.
For WiFi Communication:
Set up the WiFi connection using the SSID and password.
Send the sensor data over the internet using HTTP requests or an MQTT broker.
Step 3: Testing the Communication
1. For Bluetooth:
Pair your smartphone with the Bluetooth module.
Use a Bluetooth terminal app to receive data sent by the microcontroller.
2. For WiFi:
Connect the smartphone to the same network as the microcontroller/SBC.
Use an IoT monitoring app (like IoT MQTT Dashboard) or a custom app to receive the data
from the microcontroller.
Sample Code:
Bluetooth Example (Arduino):
include <SoftwareSerial.h>
include <DHT.h>
define DHTPIN 2 // Pin where the sensor is connected
define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
SoftwareSerial BTSerial(10, 11); // RX, TX pins for HC05
module void setup() {
Serial.begin(9600);
BTSerial.begin(9600);
dht.begin();
}
void loop() {
float temperature =
dht.readTemperature(); float humidity =
dht.readHumidity();
if (isnan(temperature) || isnan(humidity)) {
Serial.println("Failed to read from DHT
sensor!"); return;
}
// Send data to Bluetooth
BTSerial.print("Temp: ");
BTSerial.print(temperature);
BTSerial.print("C Humidity: ");
BTSerial.print(humidity);
BTSerial.println("%");
delay(2000); // Wait 2 seconds between readings
}
WiFi Example (ESP32/ESP8266 with Arduino IDE):
include <WiFi.h>
include <DHT.h>
const char ssid = "your_SSID";
const char password = "your_PASSWORD";
define DHTPIN 2 // Pin where the sensor is connected
define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
WiFiServer server(80);
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{ delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
dht.begin();
server.begin();
}
void loop() {
WiFiClient client = server.available(); // Listen for incoming clients
if (client) { // If a new client connects,
Serial.println("New Client.");
String currentLine = ""; // make a String to hold incoming data
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte
Serial.write(c); // print it out the serial monitor
if (c == '\n') { // if the byte is a newline character
// Send data to client
float temperature =
dht.readTemperature(); float humidity =
dht.readHumidity();
client.print("HTTP/1.1 200 OK\r\nContentType: text/html\r\n\r\
n"); client.print("Temperature: ");
client.print(temperature);
client.print("C Humidity: ");
client.print(humidity);
client.println("%");
break;
}
}
}
client.stop();
Serial.println("Client Disconnected.");
}
}
Result:
Upon successfully completing the experiment, you should be able to transmit realtime sensor
data to your smartphone via Bluetooth or WiFi, where it can be displayed using a terminal or
dashboard application.