0% found this document useful (0 votes)
40 views85 pages

MECHATRONICS AND IoT LABORATORY MANUAL

The document is a laboratory record for students at Tamilnadu College of Engineering, detailing the Mechatronics and IoT laboratory course objectives, experiments, and outcomes for the academic year 2024-2025. It includes a list of experiments related to mechatronics and IoT, along with procedures and calculations for measuring various physical quantities using transducers. The document also provides a framework for recording experiment details and results, ensuring students demonstrate their understanding of the subject matter.
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)
40 views85 pages

MECHATRONICS AND IoT LABORATORY MANUAL

The document is a laboratory record for students at Tamilnadu College of Engineering, detailing the Mechatronics and IoT laboratory course objectives, experiments, and outcomes for the academic year 2024-2025. It includes a list of experiments related to mechatronics and IoT, along with procedures and calculations for measuring various physical quantities using transducers. The document also provides a framework for recording experiment details and results, ensuring students demonstrate their understanding of the subject matter.
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/ 85

TAMILNADU COLLEGE OF ENGINEERING

KARUMATHAMPATTI, COIMBATORE – 641 659

LABORATORY RECORD

NAME : ______________________________________________________

CLASS : ______________________________________________________

BRANCH : ______________________________________________________

SUBJECT:______________________________________________________

REGISTER NO: ROLL No:

CERTIFIED THAT THIS IS BONAFIDE RECORD OF WORK DONE BY

THE ABOVE STUDENT LABORATORY DURING THE YEAR 2024-2025.

SIGNATURE OF LAB IN CHARGE SIGNATURE OF HEAD OF DEPT.

SUBMITTED FOR THE PRACTICAL EXAMINATION HELD ON ________________

External Examiner Internal Examiner

1
2
ME3781-MECHATRONICS AND IoT LABORATORY
LTPC
0042
COURSE OBJECTIVES

1. To study the concept of mechatronics to design, modelling and analysis of basic electrical
hydraulic systems.
2. To provide the hands on-training in the control of linear and rotary actuators.
3. To study the concepts and fundamentals of IoT, sensors, actuators and IoT boards

MECHATRONICS - LIST OF EXPERIMENTS: 30

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 classification.

INTERNET OF THINGS - LIST OF EXPERIMENTS: 30

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 Linear/Rotary
Actuator through IoT when sensor data is detected.
6. To interface Bluetooth/Wifi with microcontroller/SBC and write a program to send sensor data
to smart phone using Bluetooth/wifi.
TOTAL:60 PERIODS

OUTCOMES: At the end of the course the students would be able to

1. Demonstrate the functioning of mechatronics systems with various pneumatic, hydraulic and
electrical systems.
2. Demonstrate the microcontroller and PLC as controllers in automation systems by executing
proper interfacing of I/O devices and programming
3. Demonstrate of IoT based Home automation, CNC router, Robotic arm.

3
4
INDEX
MECHATRONICS LABORATORY

Signature
Page Marks of
S.No Date Name of the Experiment
No. Awarded Staff
in charge

10

5
INTERNET OF THINGS LABORATORY

Signature
Page Marks of
S.No Date Name of the Experiment
No. Awarded Staff
in charge

6
MECHATRONICS LABORATORY

7
DIAGRAM

lua
Copy code
+-------------------------+
| Linear Displacement |
| Sensor |
| |
| (e.g., Potentiometer) |
+-------------------------+

|
| Output Signal (V)
|
+--------------+
| Digital |
| Voltmeter |
+--------------+

+-------------------------+
| Rotary Encoder |
| (e.g., Optical) |
| |
+-------------------------+

|
| Output Signal (Pulses)
|
+--------------+
| Digital |
| Voltmeter |
+--------------+

8
EX. NO.: 1
DATE:

MEASUREMENT OF LINEAR/ANGULAR OF POSITION, DIRECTION AND SPEED USING


TRANSDUCERS

AIM

To measure the linear and angular position, direction, and speed of a moving object using suitable
transducers and perform the necessary calculations.

APPARATUS REQUIRED

1. Linear Position Measurement:


o Linear displacement sensor (e.g., potentiometer, LVDT, or rotary encoder)
o Digital voltmeter or digital readout
o Mechanical setup (e.g., a sliding carriage on a track)
o Power supply
o Mounting supports
2. Angular Position and Speed Measurement:
o Rotary encoder (or potentiometer)
o Tachometer (for speed measurement)
o Digital voltmeter
o Power supply
o Mechanical setup with rotating disk or wheel
3. Miscellaneous:
o Stopwatch (for time measurements)
o Ruler or measuring tape (for linear displacement measurement)
o Connection cables
o Data acquisition system (optional, for data logging)

PROCEDURE

Linear Position Measurement:

1. Set up the linear displacement sensor along the path of a moving object (e.g., a carriage or slider
along a track).
2. Connect the output of the sensor to a voltmeter or data acquisition system.
3. Measure the initial position (X₁) and final position (X₂) of the object using the sensor.
4. Move the object to a different position along the track, noting the changes in the sensor output as the
object moves.
5. Record the corresponding voltage or output signal values for different positions.
6. Calculate the linear displacement by measuring the change in position.

Angular Position and Speed Measurement:

1. Mount a rotating disk or wheel to a shaft connected to the rotary encoder.


2. Connect the encoder to a digital voltmeter or data acquisition system.
3. Rotate the disk or wheel through a known angle, and record the encoder’s output at regular intervals.
4. Measure the time it takes to rotate the disk through a given angle.
5. Calculate the angular displacement (θ) and angular velocity (ω) from the recorded data.

9
CALCULATIONS

1. Linear Position Calculation:

Let the displacement sensor output (V) be proportional to the position (X). If the sensor's calibration gives a
relationship like:

V=kXV = kXV=kX

where VVV is the output voltage and XXX is the position in meters, then the linear position is:

X=VkX = \frac{V}{k}X=kV

where kkk is the sensor’s calibration constant.

2. Angular Position Calculation:

For a rotary encoder, the angular position θ (in degrees or radians) can be calculated from the encoder’s
output signal, which is usually given in pulses. If the encoder has NNN pulses per revolution (PPR), the
angular position can be calculated as:

θ=NpulsesNpulses per revolution×360∘\theta = \frac{N_{\text{pulses}}}{N_{\text{pulses per


revolution}}} \times 360^\circθ=Npulses per revolutionNpulses×360∘

where:

• NpulsesN_{\text{pulses}}Npulses is the total number of pulses counted during the rotation.


• Npulses per revolutionN_{\text{pulses per revolution}}Npulses per revolution is the number of
pulses the encoder generates per complete revolution.

3. Angular Speed (ω):

The angular velocity is the rate of change of angular displacement. If the time taken to rotate by an angle
θ\thetaθ is ttt, the angular speed (ω) is:

ω=θt\omega = \frac{\theta}{t}ω=tθ

where:

• θ\thetaθ is the angular displacement (in radians or degrees).


• ttt is the time taken (in seconds).

4. Linear Speed (v):

If you are measuring linear motion, the linear speed is given by:

v=ΔXΔtv = \frac{\Delta X}{\Delta t}v=ΔtΔX

where:

• ΔX\Delta XΔX is the change in linear position.


• Δt\Delta tΔt is the time taken for the change in position.

10
SAMPLE CALCULATIONS

1. Linear Position:

• Assume the sensor has a calibration constant k=2 V/mk = 2 \, \text{V/m}k=2V/m.


• If the output voltage V=4 VV = 4 \, \text{V}V=4V, the position XXX is:

X=Vk=4 V2 V/m=2 mX = \frac{V}{k} = \frac{4 \, \text{V}}{2 \, \text{V/m}} = 2 \, \text{m}X=kV


=2V/m4V=2m

2. Angular Position:

• Assume the encoder has 1000 pulses per revolution.


• If the total number of pulses counted is 250, the angular position θ\thetaθ is:

θ=2501000×360∘=90∘\theta = \frac{250}{1000} \times 360^\circ = 90^\circθ=1000250×360∘=90∘

3. Angular Speed:

• If the time taken to rotate the disk through 90° is 2 seconds, the angular speed ω\omegaω is:

ω=θt=90∘2 s=45∘/s\omega = \frac{\theta}{t} = \frac{90^\circ}{2 \, \text{s}} = 45^\circ/\text{s}ω=tθ=2s90∘


=45∘/s

4. Linear Speed:

• Assume the object moves 5 meters in 10 seconds. The linear speed vvv is:

v=ΔXΔt=5 m10 s=0.5 m/sv = \frac{\Delta X}{\Delta t} = \frac{5 \, \text{m}}{10 \, \text{s}} = 0.5 \,
\text{m/s}v=ΔtΔX=10s5m=0.5m/s

RESULT

• The linear displacement XXX was found to be 2 meters for a voltage of 4V.
• The angular position θ\thetaθ was calculated to be 90° for 250 pulses.
• The angular speed ω\omegaω was calculated to be 45°/s.
• The linear speed vvv was calculated to be 0.5 m/s.

11
DIAGRAM:

• Block diagram for Pressure Measurement:

css
Copy code
[Pressure Source] --> [Pressure Transducer] --> [Data Acquisition] -->
[Display/Readout]

• Block diagram for Temperature Measurement:

css
Copy code
[Temperature Source] --> [Temperature Transducer] --> [Data Acquisition] -->
[Display/Readout]

• Block diagram for Force Measurement:

css
Copy code
[Applied Load] --> [Force Transducer] --> [Data Acquisition] -->
[Display/Readout]

12
EX. NO.: 2
DATE:

MEASUREMENT OF PRESSURE, TEMPERATURE AND FORCE USING TRANSDUCERS

AIM

To measure the pressure, temperature, and force using respective transducers and perform related
calculations.

APPARATUS REQUIRED

1. Pressure Transducer (e.g., strain gauge or piezoelectric transducer)


2. Temperature Transducer (e.g., thermistor or RTD)
3. Force Transducer (e.g., load cell or strain gauge)
4. Digital Pressure Gauge
5. Digital Thermometer
6. Force Measuring Device (such as a load cell)
7. Power Supply (for the transducers)
8. Multimeter (for measuring voltage, current, or resistance, as needed)
9. Calibration Equipment (weights for force calibration, pressure pump, and temperature source)
10. Data Acquisition System (optional, for automated data logging)

PROCEDURE

1. Pressure Measurement:
o Connect the pressure transducer to a known pressure source (e.g., a pressure pump).
o Power the transducer and connect it to a data acquisition system or a voltmeter to measure the
output.
o Gradually increase the pressure and note the corresponding output voltage from the
transducer.
o Record the pressure and corresponding output for several pressure levels.
2. Temperature Measurement:
o Connect the temperature transducer (e.g., thermistor or RTD) to a suitable power source and
voltmeter.
o Use a controlled heat source (e.g., water bath or an oven) to vary the temperature.
o Measure the output voltage or resistance of the transducer at different temperature points and
record the values.
3. Force Measurement:
o Connect the force transducer (load cell) to the applied load.
o Power the transducer and connect it to the data acquisition system or voltmeter.
o Apply known forces (e.g., different weights) to the force transducer.
o Measure and record the corresponding output from the transducer.
4. Calibrate the Transducers:
o If necessary, perform calibration using known reference values for pressure, temperature, and
force to ensure accurate measurements.

13
CALCULATIONS

1. Pressure Calculation:

The output voltage from the pressure transducer is related to the pressure by the following equation:

P=(Vout−Vzero)SP = \frac{(V_{\text{out}} - V_{\text{zero}})}{S}P=S(Vout−Vzero)

where:

oPPP = Pressure in Pascals (Pa)


oVoutV_{\text{out}}Vout = Output voltage from the transducer (V)
oVzeroV_{\text{zero}}Vzero = Zero voltage output at 0 pressure (V)
oSSS = Sensitivity of the transducer (V/Pa)
2. Temperature Calculation:

The output voltage (or resistance) from the temperature transducer can be used to calculate the
temperature:

T=(Rmeasured−Rref)B+TrefT = \frac{(R_{\text{measured}} - R_{\text{ref}})}{B} +


T_{\text{ref}}T=B(Rmeasured−Rref)+Tref

where:

o TTT = Temperature in °C
o RmeasuredR_{\text{measured}}Rmeasured = Measured resistance (or output voltage) from
the temperature transducer (Ω or V)
o RrefR_{\text{ref}}Rref = Reference resistance (or voltage) at a known temperature (Ω or V)
o BBB = Temperature coefficient (from the transducer's datasheet)
o TrefT_{\text{ref}}Tref = Reference temperature (in °C)
3. Force Calculation:

The force measured by the load cell can be calculated using the following formula:

F=(Vout−Vzero)CF = \frac{(V_{\text{out}} - V_{\text{zero}})}{C}F=C(Vout−Vzero)

where:

o FFF = Force in Newtons (N)


o VoutV_{\text{out}}Vout = Output voltage from the load cell (V)
o VzeroV_{\text{zero}}Vzero = Zero voltage output (V) when no load is applied
o CCC = Sensitivity of the load cell (V/N)

14
SAMPLE CALCULATION

1. Pressure Calculation: Assume the pressure transducer has a sensitivity of 0.005 V/Pa and a zero
output of 0.2 V. If the measured output voltage is 2.0 V for a given pressure, the pressure can be
calculated as:

P=(2.0−0.2)0.005=360 PaP = \frac{(2.0 - 0.2)}{0.005} = 360 \, \text{Pa}P=0.005(2.0−0.2)=360Pa

2. Temperature Calculation: If a thermistor with a reference resistance RrefR_{\text{ref}}Rref of


1000 Ω at 25°C and a temperature coefficient BBB of 3950 is used, and the measured resistance is
1100 Ω, the temperature can be calculated as:

T=(1100−1000)3950+25=25.025 °CT = \frac{(1100 - 1000)}{3950} + 25 = 25.025 \,


\text{°C}T=3950(1100−1000)+25=25.025°C

3. Force Calculation: For a load cell with sensitivity CCC of 0.02 V/N and a zero output of 0.5 V, if
the measured output voltage is 2.0 V under load, the force is calculated as:

F=(2.0−0.5)0.02=75 NF = \frac{(2.0 - 0.5)}{0.02} = 75 \, \text{N}F=0.02(2.0−0.5)=75N

RESULT

• Pressure Measurement:
o The measured pressures at different voltages are as follows:
▪ At V=2.0 VV = 2.0 \, \text{V}V=2.0V, Pressure = 360 Pa
▪ At V=3.0 VV = 3.0 \, \text{V}V=3.0V, Pressure = 540 Pa
• Temperature Measurement:
o The measured temperatures at different resistance values are as follows:
▪ At R=1100 ΩR = 1100 \, \OmegaR=1100Ω, Temperature = 25.025°C
▪ At R=1200 ΩR = 1200 \, \OmegaR=1200Ω, Temperature = 30.05°C
• Force Measurement:
o The measured forces at different voltages are as follows:
▪ At V=2.0 VV = 2.0 \, \text{V}V=2.0V, Force = 75 N
▪ At V=2.5 VV = 2.5 \, \text{V}V=2.5V, Force = 100 N

15
DIAGRAMS

1. DC Servomotor Control:
o Block Diagram for Speed Control:

css
Copy code
[Power Supply] --> [H-Bridge] --> [DC Servomotor] --> [Tachometer]
^ |
|----------------------|

2. AC Servomotor Control:
o Block Diagram for Speed Control:

css
Copy code
[AC Power Supply] --> [Frequency Controller] --> [AC Servomotor] -->
[Tachometer]

3. Induction Motor Control:


o Block Diagram for Speed and Direction Control:

css
Copy code
[VFD] --> [Induction Motor] --> [Tachometer]
^ |
|-------------------------|

16
EX. NO.: 3
DATE:

SPEED AND DIRECTION CONTROL OF DC SERVOMOTOR, AC SERVOMOTOR AND


INDUCTION MOTORS

AIM

To control the speed and direction of DC servomotor, AC servomotor, and induction motors using various
techniques.

APPARATUS REQUIRED

1. DC Servomotor (with armature and field windings)


2. AC Servomotor (typically an induction or synchronous servomotor)
3. Induction Motor (single-phase or three-phase)
4. Power Supply Unit (for DC and AC motors)
5. H-Bridge or Motor Driver Circuit (for direction control of DC motor)
6. Rheostat or Potentiometer (for speed control of DC motor)
7. Pulse Width Modulation (PWM) Controller (for controlling speed of DC motor)
8. AC Motor Controller (for controlling speed and direction of AC motors)
9. Phase Control Circuit (for speed and direction control of Induction motors)
10. Frequency Controller (for controlling the frequency of AC motors)
11. Voltmeter, Ammeter (for measuring motor parameters)
12. Tachometer (for measuring speed)
13. Digital Multimeter
14. Stopwatch
15. Breadboard and Connecting Wires

PROCEDURE

1. Speed and Direction Control of DC Servomotor:


o Connect the DC servomotor to the power supply and H-Bridge circuit for direction control.
o Use a potentiometer or rheostat to adjust the armature voltage and observe the speed changes.
o To change the direction, reverse the polarity of the DC supply or use an H-Bridge.
o Measure the motor speed using a tachometer.
o Record the motor speed at different voltage levels.
2. Speed and Direction Control of AC Servomotor:
o Connect the AC servomotor to the AC supply and the AC motor controller.
o Adjust the frequency and observe the motor speed change using the frequency controller.
o Use the controller to change the direction of the motor by reversing the phase sequence.
o Measure the motor speed at different frequencies using a tachometer.
3. Speed and Direction Control of Induction Motor:
o Connect the induction motor to a VFD (Variable Frequency Drive) for speed control.
o Adjust the frequency on the VFD and observe the change in motor speed.
o For direction control, reverse the phase sequence of the AC supply using the VFD.
o Measure the motor speed using a tachometer and record it for different frequencies.
o Note the motor performance at different voltage levels.

17
CALCULATIONS

1. DC Servomotor Speed Calculation: The speed of a DC motor is proportional to the applied


voltage:

N=k×VarmatureN = k \times V_{\text{armature}}N=k×Varmature

where:

o NNN = Speed of the motor (RPM)


o kkk = Motor constant (depends on motor type)
o VarmatureV_{\text{armature}}Varmature = Applied armature voltage
2. AC Servomotor Speed Calculation: The synchronous speed of an AC servomotor is calculated by:

Ns=120×fPN_s = \frac{120 \times f}{P}Ns=P120×f

where:

o NsN_sNs = Synchronous speed (RPM)


o fff = Supply frequency (Hz)
o PPP = Number of poles in the motor
3. Induction Motor Speed Calculation: The actual speed of an induction motor is given by:

N=Ns×(1−s)N = N_s \times (1 - s)N=Ns×(1−s)

where:

o NNN = Actual speed (RPM)


o NsN_sNs = Synchronous speed (RPM)
o sss = Slip, defined as: s=Ns−NNss = \frac{N_s - N}{N_s}s=NsNs−N
o Slip varies with load, and typically ranges from 0 to 6% under normal operating conditions.

SAMPLE CALCULATION

1. DC Servomotor: If the armature voltage is 10V, and the motor constant kkk is 100 RPM/V, the
speed of the motor will be:

N=100×10=1000 RPMN = 100 \times 10 = 1000 \, \text{RPM}N=100×10=1000RPM

2. AC Servomotor: For an AC motor with a supply frequency f=50 Hzf = 50 \, \text{Hz}f=50Hz and
P=4P = 4P=4 poles:

Ns=120×504=1500 RPMN_s = \frac{120 \times 50}{4} = 1500 \, \text{RPM}Ns=4120×50


=1500RPM

3. Induction Motor: If the synchronous speed is 1500 RPM, and the slip sss is 0.02 (2%), the actual
speed will be:

N=1500×(1−0.02)=1500×0.98=1470 RPMN = 1500 \times (1 - 0.02) = 1500 \times 0.98 = 1470 \,


\text{RPM}N=1500×(1−0.02)=1500×0.98=1470RPM

18
RESULT

1. DC Servomotor:
o The speed of the DC servomotor was observed to increase with an increase in armature
voltage.
o Direction of rotation was reversed by changing the polarity.
2. AC Servomotor:
o The motor speed increased with the increase in supply frequency.
o The direction of the AC motor changed with phase reversal.
3. Induction Motor:
o The motor speed increased with the increase in supply frequency.
o The direction of the motor reversed when the phase sequence was altered.

19
20
EX. NO.: 4
DATE:

ADDITION, SUBTRACTION AND MULTIPLICATION PROGRAMMING IN 8051

AIM
To write an assembly language program to add, subtract and multiply the given
data stored at two consecutive locations using 8051microcontroller.

ADDITION OF TWO 8 BIT NUMBERS


ALGORITHM

1. Set DPTR as pointer for data.


2. Move first data from external memory to accumulator and save it in R1 register.
3. Increment DPTR.
4. Move second data from external memory to accumulator
5. Clear R0 register to account for carry.
6. Add the content of R1 register to accumulator.
7. Check for carry. If carry is not set go to step 8. Otherwise go to next step.
8. Increment R0 register.
9. Increment DPTR and save the sum in external memory.
10. Increment DPTR, move carry to accumulator and save it in external memory.
11. Stop

SUBTRACTION OF TWO 8 BIT NUMBERS


ALGORITHM

1. Set DPTR as pointer for data.


2. Move the minuend from external memory to accumulator and save it in R1 register.
3. Increment DPTR.
4. Move subtrahend from external memory to accumulator
5. Exchange the contents of R1 and A such that minuend is in A and subtrahend is in R1
6. Clear R0 register to account for sign.
7. Clear carry flag.
8. Subtract the content of R1 register from accumulator.
9. Check for carry. If carry is not set go to step 12. Otherwise go to next step.
10. Complement the content of A–reg and increment by 1 to get 2’s complement of result in A–reg
11. Increment R0 register.
12. Increment DPTR and save the result in external memory.
13. Increment DPTR, moveR0 (sign bit) to accumulator and then save it in external memory.
14. Stop

21
22
MULTIPLICATION OF TWO 8 BIT NUMBERS

ALGORITHM

1. Load address of data in DPTR


2. Move the first data from external memory to A and save in B.
3. Increment DPTR and move second data from external memory to B.
4. Perform multiplication to get the product in A and B.
5. Increment DPTR and save A (lower byte of product) in memory
6. Increment DPTR, move B (lower byte of product) to A and save it in memory
7. Stop

ADDITION OF TWO 8 BIT NUMBERS

23
ADDITION OF TWO 8 BIT NUMBERS

OBSERVATION

Input:
4500: [Addend]
4501: [Augend]
Output:
4502: [Sum]
4503: [Carry]

SUBTRACTION OF TWO 8 BIT NUMBERS


OBSERVATION

INPUT:
4500: [MINUEND]
4501: [SUBTRAHEND]
OUTPUT:
4502: [DIFFERENCE]
4503: [SIGN BIT]

MULTIPLICATION OF TWO 8 BIT NUMBERS


OBSERVATION

Input:
4500:[1stdata]
4501: [2nddata]
Output:
4502: [Lower byte of product]
4503: [Higher byte of product]

24
SUBTRACTION OF TWO 8 BIT NUMBERS

25
26
MULTIPLICATION OF TWO 8 BITNUMBERS

RESULT
Thus the addition, subtraction and multiplication of two numbers were
performed using the 8051 microcontroller.

27
DIAGRAM:

DC Motor Control (8051 + L298)

lua
Copy code
+5V -----> 8051 Microcontroller
|
P1 ----> L298 Motor Driver
|
----> DC Motor <----
|
Ground

Stepper Motor Control (8051 + ULN2003)

lua
Copy code
+5V -----> 8051 Microcontroller
|
P1 ----> ULN2003 Driver
|
----> Stepper Motor <----
|
Ground

28
EX. NO.: 5
DATE:

PROGRAMMING AND INTERFACING OF STEPPER MOTOR AND DC MOTOR USING


8051/PLC

AIM

• To interface and control a DC motor and a stepper motor using the 8051 microcontroller or a
PLC (Programmable Logic Controller).
• To develop the appropriate control programs for both motors and observe their operation.

APPARATUS REQUIRED

For 8051 Microcontroller:

1. 8051 Microcontroller Board


2. DC Motor
3. Stepper Motor
4. Motor Driver IC (e.g., L298 for DC motor control)
5. ULN2003 Driver IC (for stepper motor control)
6. Power Supply (5V for 8051, 12V for motors)
7. Crystal Oscillator (for 8051)
8. Push Buttons (for user input control)
9. Connecting Wires
10. LEDs (for indication)
11. Resistors and Capacitors (for stabilization)

For PLC:

1. PLC System (e.g., Siemens, Allen-Bradley, etc.)


2. DC Motor
3. Stepper Motor
4. Motor Driver Units
5. PLC Programming Software (e.g., Ladder Logic)
6. Sensors (optional)

PROGRAM FOR 8051 MICROCONTROLLER:

DC Motor Control Program:

asm
Copy code
; DC Motor Control Program using 8051 Microcontroller
ORG 0H

; Initialize Ports
MOV P1, #00H ; Set Port 1 as output (Motor Driver)
MOV P2, #00H ; Set Port 2 as input (Control switch)

START:
MOV A, P2 ; Read input from control switch
JB ACC.0, FORWARD ; If switch bit 0 is 1, rotate motor forward
JB ACC.1, REVERSE ; If switch bit 1 is 1, rotate motor reverse
SJMP START ; Repeat until a switch is pressed
29
30
FORWARD:
MOV P1, #01H ; Send signal to motor driver for forward motion
SJMP START

REVERSE:
MOV P1, #02H ; Send signal to motor driver for reverse motion
SJMP START

END

Stepper Motor Control Program:

asm
Copy code
; Stepper Motor Control Program using 8051 Microcontroller
ORG 0H

; Initialize Ports
MOV P1, #00H ; Set Port 1 as output (Stepper Motor driver)

START:
MOV A, P2 ; Read input for control sequence
JB ACC.0, STEP1 ; If switch bit 0 is 1, rotate motor in steps
SJMP START

STEP1:
MOV P1, #01H ; Activate coil 1 of stepper motor
CALL DELAY
MOV P1, #02H ; Activate coil 2 of stepper motor
CALL DELAY
MOV P1, #04H ; Activate coil 3 of stepper motor
CALL DELAY
MOV P1, #08H ; Activate coil 4 of stepper motor
CALL DELAY
SJMP START

DELAY:
MOV R0, #255
DELAY_LOOP:
MOV R1, #255
DELAY_LOOP2:
NOP
NOP
NOP
NOP
DJNZ R1, DELAY_LOOP2
DJNZ R0, DELAY_LOOP
RET

END

PROCEDURE

1. Hardware Setup for 8051 Microcontroller:


o Connect the 8051 microcontroller to a suitable power supply (5V).
o Connect the DC motor to the L298 motor driver.
▪ Input pins of L298 will be connected to Port 1 of the 8051 microcontroller.
▪ Enable pins of L298 will be tied to high (Vcc).
▪ Output pins of L298 will be connected to the DC motor.
o
31
32
o For the stepper motor, use the ULN2003 stepper motor driver connected to Port 1 of the
8051.
▪ The stepper motor should be wired to the ULN2003 driver.
o Provide external power supply (12V) to the motors.
2. Programming the Microcontroller:
o Write the assembly code for controlling the DC motor and stepper motor.
o Load the program into the microcontroller using an appropriate programmer (e.g., ISP
programmer).
3. Testing DC Motor:
o Press the appropriate switches to control the motor direction (forward or reverse).
o Observe the DC motor’s response to the inputs.
4. Testing Stepper Motor:
o Press the switch to rotate the stepper motor in discrete steps.
o Observe the stepper motor rotating one step at a time as it responds to the control pulses.

RESULT

• DC Motor Control: The DC motor responds to the input from the switches, rotating either forward
or backward based on the control signal sent by the microcontroller.
• Stepper Motor Control: The stepper motor rotates one step at a time when control pulses are sent
from the 8051. The program successfully sends the correct sequence of signals to drive the motor in
a specific direction.

33
CIRCUIT DIAGRAM

In this circuit:

• Connect Red LED to Port 2.0 (P2.0) with a 220Ω resistor.


• Connect Yellow LED to Port 2.1 (P2.1) with a 220Ω resistor.
• Connect Green LED to Port 2.2 (P2.2) with a 220Ω resistor.
• Connect all LED grounds to the common ground of the 8051 microcontroller.

34
EX. NO.: 6
DATE:

PROGRAMMING AND INTERFACING OF TRAFFIC LIGHT INTERFACE USING 8051

AIM

To program and interface a Traffic Light Control System using 8051 microcontroller with Assembly
language to manage traffic flow using Red, Yellow, and Green LEDs.

APPARATUS REQUIRED

• 8051 Microcontroller Development Board


• LEDs (Red, Yellow, Green)
• 220Ω Resistors (3 pieces)
• Breadboard
• Connecting wires
• Power supply (5V)
• USB to Serial Cable (for programming)
• Assembler and Compiler software (e.g., Keil uVision for Assembly programming)
• Flash Magic software (for loading hex files into the microcontroller)

PROCEDURE

1. Set up the Hardware:


o Assemble the circuit as described above, using the 8051 microcontroller development board.
o Connect each LED to the respective port pins on the microcontroller.
2. Program the Microcontroller:
o Open Keil uVision and create a new project.
o Select the 8051 microcontroller model (e.g., AT89C51).
o Write the Assembly language code for the traffic light control system.
o Compile the program to generate a .hex file.
3. Load the Program:
o Connect the 8051 microcontroller board to your computer.
o Open Flash Magic and select the appropriate COM port and microcontroller type.
o Load the .hex file and program the microcontroller.
4. Run the Program:
o Power up the microcontroller board.
o Observe the LED sequence as per the programmed traffic light control logic.

Assembly Language Program


assembly
Copy code
ORG 0000H ; Origin, starting address for the program

MAIN:
SETB P2.0 ; Turn ON Red LED (P2.0)
CLR P2.1 ; Turn OFF Yellow LED
CLR P2.2 ; Turn OFF Green LED
ACALL DELAY ; Call delay subroutine (Red ON for a while)

CLR P2.0 ; Turn OFF Red LED


SETB P2.1 ; Turn ON Yellow LED (P2.1)
35
36
CLR P2.2 ; Turn OFF Green LED
ACALL DELAY ; Call delay subroutine (Yellow ON for a while)

CLR P2.0 ; Turn OFF Red LED


CLR P2.1 ; Turn OFF Yellow LED
SETB P2.2 ; Turn ON Green LED (P2.2)
ACALL DELAY ; Call delay subroutine (Green ON for a while)

SJMP MAIN ; Repeat the cycle

; Delay subroutine to create a wait time between light changes


DELAY:
MOV R2, #250 ; Load R2 with 250 for delay count
DELAY_LOOP1:
MOV R1, #250 ; Load R1 with 250 for delay count
DELAY_LOOP2:
DJNZ R1, DELAY_LOOP2 ; Inner loop
DJNZ R2, DELAY_LOOP1 ; Outer loop
RET ; Return from delay

END ; End of program

8. Result

The traffic light control system was successfully programmed and interfaced with the 8051
microcontroller. The LEDs (Red, Yellow, and Green) responded in the expected sequence to simulate a
traffic control system.

37
DIAGRAM

38
EX. NO.: 7
DATE:

SEQUENCING OF HYDRAULIC AND PNEUMATIC CIRCUITS

AIM

To study and implement the sequencing of hydraulic and pneumatic circuits using appropriate control
valves and actuators, demonstrating how sequential operations can be achieved in fluid power systems.

APPARATUS REQUIRED

• Hydraulic Circuit Components:


o Hydraulic power pack (pump, reservoir, pressure relief valve)
o Double-acting hydraulic cylinders
o Directional control valves (DCV)
o Flow control valves
o Pressure gauge
o Hydraulic hoses and fittings
• Pneumatic Circuit Components:
o Pneumatic compressor (air supply)
o Double-acting pneumatic cylinders
o Directional control valves (5/2 or 4/2 DCV)
o Flow control valves
o Air filter, regulator, and lubricator (FRL unit)
o Pneumatic hoses and connectors
• General Tools:
o Control panel (if using an automated setup)
o Timer or sequence controller (if using automation)
o Connecting pipes, tubes, and fittings
o Safety goggles and gloves

PROCEDURE

A. Hydraulic Circuit Sequencing

1. Set Up the Hydraulic Circuit:


o Connect the hydraulic power pack to the main circuit using hoses.
o Attach double-acting cylinders to the circuit and connect them to directional control valves
(DCVs).
o Ensure flow control valves are in place to regulate the speed of cylinder extension and
retraction.
2. Check for Leaks:
o Before starting the experiment, ensure all connections are tight and secure.
o Turn on the hydraulic power pack and check for any leaks in the system.
3. Sequential Operation:
o Adjust the pressure relief valve to the desired operating pressure.
o Use the DCVs to control the sequence of cylinder movements.
▪ For example, Cylinder A extends first, followed by Cylinder B.
▪ Adjust flow control valves to achieve the desired speed for each operation.
4. Observe the Sequence:
o Monitor the sequential extension and retraction of the cylinders.
39
40
o Use the control panel to operate the DCVs manually or automatically.
o Adjust the sequence by changing the valve positions and flow rates.

B. Pneumatic Circuit Sequencing

1. Set Up the Pneumatic Circuit:


o Connect the air compressor to the pneumatic circuit.
o Attach double-acting pneumatic cylinders to the circuit and connect them to 5/2 or 4/2
directional control valves.
o Install an FRL unit (Filter, Regulator, Lubricator) at the air inlet to ensure clean and regulated
air supply.
2. Check Air Supply:
o Ensure all hoses and fittings are securely connected.
o Turn on the air compressor and set the regulator to the desired pressure.
o Check for any air leaks.
3. Sequential Operation:
o Use the directional control valves to control the sequence of cylinder movements.
▪ For instance, Cylinder A extends first, followed by Cylinder B after a short delay.
o Adjust the flow control valves to set the speed of cylinder operations.
4. Observe the Sequence:
o Observe the operation of the pneumatic cylinders in sequence.
o Use manual or automated controls to vary the sequence and timing.
o Adjust the system to achieve the desired sequence of operations.

RESULT

• Hydraulic Circuit:
o The sequence of cylinder operations was successfully achieved using directional control
valves.
o Adjusting the flow control valves influenced the speed of extension and retraction.
o The system demonstrated a stable and smooth sequential operation.
• Pneumatic Circuit:
o The pneumatic cylinders operated in a predefined sequence as controlled by the DCVs.
o The system allowed for easy adjustments in sequence timing using flow control valves.
o The operation was smooth with no significant air leakage observed.

41
DIAGRAM

42
EX. NO.: 8
DATE:

SEQUENCING OF HYDRAULIC, PNEUMATIC AND ELECTRO-PNEUMATIC CIRCUITS


USING SOFTWARE

AIM

To simulate and analyse the sequencing of Hydraulic, Pneumatic, and Electro-pneumatic circuits using
simulation software.

APPARATUS REQUIRED

• Computer with Simulation Software (e.g., Automation Studio, FluidSIM, FESTO)


• Software License or Educational Version (if applicable)
• Pre-installed libraries for Hydraulic, Pneumatic, and Electro-pneumatic components
• User manual or software guide for reference

PROCEDURE

A. Setting Up the Software Environment

1. Launch the Simulation Software:


o Open the chosen simulation software (e.g., Automation Studio, FluidSIM, or FESTO).
o Create a new project and select the type of circuit (Hydraulic, Pneumatic, or Electro-
pneumatic).
2. Familiarize with the Interface:
o Explore the workspace, component libraries, and toolbars.
o Load the libraries for hydraulic, pneumatic, and electro-pneumatic components.

B. Sequencing of Hydraulic Circuits

1. Design the Hydraulic Circuit:


o Drag and drop components such as a hydraulic pump, double-acting cylinders, directional
control valves (DCVs), flow control valves, and pressure relief valves.
o Connect the components using hydraulic hoses in the software.
2. Define the Sequence:
o Use limit switches or position sensors to control the movement of hydraulic cylinders.
o Program the sequence such that Cylinder A extends first, followed by Cylinder B.
o Adjust the flow control valves to set the speed of the cylinders.
3. Simulate the Circuit:
o Run the simulation and observe the sequence of cylinder movements.
o Make adjustments to the circuit if necessary and rerun the simulation.

C. Sequencing of Pneumatic Circuits

1. Design the Pneumatic Circuit:


o Drag and drop components like the air compressor, FRL unit (Filter, Regulator, Lubricator),
pneumatic cylinders, and 5/2 or 4/2 directional control valves.
o Connect the components using pneumatic tubes in the software.

43
44
2. Implement Sequential Control:
o Use manual or automated control elements (like sensors or timers) to create a sequence.
o For example, Cylinder A extends, followed by Cylinder B after a delay.
3. Run the Simulation:
o Start the simulation to observe the sequence.
o Adjust flow control valves and timers to achieve the desired timing.

D. Sequencing of Electro-pneumatic Circuits

1. Design the Electro-pneumatic Circuit:


o Use electro-pneumatic components such as solenoid-operated directional control valves,
relays, and sensors.
o Include electrical wiring to connect solenoids to a power supply and control switches.
2. Programming the Sequence:
o Implement logic using relays, limit switches, and timers to control the sequence of
operations.
o Set up a sequence where solenoids activate in a specific order, causing cylinders to extend
and retract accordingly.
3. Simulate and Test:
o Run the simulation to test the electro-pneumatic sequence.
o Modify the electrical control logic as needed to achieve smooth operation.

RESULT

• Hydraulic Circuit Simulation:


o The sequence of cylinder movements was successfully controlled using limit switches.
o The software allowed for fine-tuning of flow rates and pressures.
• Pneumatic Circuit Simulation:
o The pneumatic cylinders operated in the programmed sequence with adjustable delays.
o The system demonstrated efficient air usage with no pressure drops observed.
• Electro-pneumatic Circuit Simulation:
o The electro-pneumatic circuit responded accurately to electrical control signals.
o Relays and timers ensured precise sequencing of cylinder movements.

45
DIAGRAM

46
EX. NO.: 9
DATE:

ELECTRO-PNEUMATIC/HYDRAULIC CONTROL USING PLC

AIM

To design, implement, and control an Electro-pneumatic/Hydraulic system using a Programmable Logic


Controller (PLC). The experiment aims to understand how PLCs can be used to automate the operation of
pneumatic or hydraulic actuators with precise control and sequencing.

APPARATUS REQUIRED

• PLC (Programmable Logic Controller) with appropriate I/O modules (e.g., Siemens, Allen
Bradley, Delta)
• Electro-pneumatic Components:
o Double-acting pneumatic cylinders
o Solenoid-operated directional control valves (5/2 or 4/2 DCV)
o Air compressor with FRL unit (Filter, Regulator, Lubricator)
o Pneumatic hoses and connectors
• Electro-hydraulic Components:
o Hydraulic power pack (pump, reservoir, pressure relief valve)
o Double-acting hydraulic cylinders
o Solenoid-operated directional control valves
o Hydraulic hoses and fittings
• Electrical Components:
o Power supply (24V DC)
o Limit switches and proximity sensors
o Push buttons and indicator lamps
o Relay board (if needed for interfacing)
o Connecting wires and cables
• Software:
o PLC Programming Software (e.g., TIA Portal, RSLogix 5000, WPLSoft)
o Ladder Logic, Function Block Diagram (FBD), or Structured Text (ST) programming

PROCEDURE

A. Setting Up the PLC and Electro-pneumatic/Hydraulic System

1. Hardware Setup:
o Connect the PLC to the power supply (ensure correct voltage levels).
o Wire the solenoid-operated control valves to the digital output ports of the PLC.
o Connect the cylinder limit switches or sensors to the digital input ports of the PLC.
o If using an electro-hydraulic setup, connect the hydraulic power pack to the solenoid valves
and hydraulic cylinders.
2. Pneumatic/Hydraulic Connections:
o For electro-pneumatic:
▪ Connect the air compressor to the FRL unit.
▪ Attach the pneumatic cylinders to the solenoid valves using hoses.
o For electro-hydraulic:
▪ Connect the hydraulic power pack to the cylinders via hydraulic hoses.
▪ Ensure all connections are secure and free of leaks.
47
48

3. PLC Programming:
o Open the PLC programming software on your computer.
o Create a new project and configure the PLC hardware settings.
o Develop a Ladder Logic (or any preferred) program to control the sequence of operations.
▪ Define inputs (limit switches, sensors, push buttons) and outputs (solenoids).
▪ Implement control logic to achieve a specific sequence (e.g., Cylinder A extends, then
Cylinder B extends, followed by retraction).

B. Example PLC Ladder Logic Program

1. Step 1: Define Inputs and Outputs


o Inputs:
▪ I0.0: Start Push Button
▪ I0.1: Limit Switch for Cylinder A (Extended)
▪ I0.2: Limit Switch for Cylinder B (Extended)
o Outputs:
▪ Q0.0: Solenoid Valve for Cylinder A
▪ Q0.1: Solenoid Valve for Cylinder B
2. Step 2: Write Ladder Logic

plaintext
Copy code
| Start PB (I0.0) |---[ ]----------------(Set Q0.0 - Cylinder A Forward)
| Cylinder A Ext. LS |---[ ]---------------(Set Q0.1 - Cylinder B Forward)
| Cylinder B Ext. LS |---[ ]---------------(Reset Q0.0, Reset Q0.1 - Retract)

• Explanation:
o When the Start button is pressed, Cylinder A extends (activating solenoid Q0.0).
o When Cylinder A reaches full extension, Cylinder B extends (activating solenoid Q0.1).
o When Cylinder B reaches full extension, both cylinders retract.

3. Step 3: Upload and Test Program


o Connect the PLC to the computer using a USB or Ethernet cable.
o Upload the ladder logic program to the PLC.
o Run the program and monitor the system using the software’s online mode.
4. Step 4: Adjustments and Troubleshooting
o Observe the sequence of cylinder movements.
o Adjust timers or delays if needed for precise control.
o Check for any error codes in the PLC and troubleshoot as required.

RESULT

• The system successfully demonstrated the use of a PLC to control electro-pneumatic/hydraulic


cylinders.
• The sequence of operations (extend/retract) was controlled accurately by the PLC as per the
programmed logic.
• Adjusting the PLC program allowed for fine-tuning the sequence and timing of cylinder movements.
• The experiment provided a clear understanding of how PLCs can automate industrial processes using
fluid power systems.

49
50
EX. NO.: 10
DATE:

VISION BASED IMAGE ACQUISITION AND PROCESSING TECHNIQUE FOR INSPECTION


AND CLASSIFICATION

AIM

To design and implement a vision-based system for acquiring and processing images to perform automated
inspection and classification. The goal is to understand how computer vision techniques can be used for
quality control, object recognition, and sorting in industrial applications.

APPARATUS REQUIRED

• Hardware Components:
o Digital Camera or USB Webcam
o Lighting setup (LED lights or ring light) for consistent illumination
o Mounting stand or tripod for the camera
o Computer with sufficient processing power (preferably with a GPU)
o Calibration chart or object (e.g., checkerboard pattern) for camera calibration
• Software Tools:
o Image acquisition software (e.g., OpenCV, MATLAB, or NI Vision)
o Image processing software (e.g., Python with OpenCV library, MATLAB Image Processing
Toolbox)
o Integrated Development Environment (IDE) like PyCharm, Jupyter Notebook, or MATLAB
o Python libraries: opencv-python, numpy, scikit-learn, tensorflow (if using deep
learning models)
• Test Objects:
o A set of objects or items for inspection (e.g., manufactured parts, fruits, packages)
o Defective and non-defective samples for classification

Procedure

A. Image Acquisition

1. Set Up the Camera:


o Mount the camera on a stable stand facing the inspection area.
o Adjust the focus and positioning to cover the field of view.
o Ensure adequate and uniform lighting to minimize shadows and reflections.
2. Calibrate the Camera:
o Use a calibration chart (e.g., a checkerboard pattern) to correct for lens distortion.
o Capture multiple images of the calibration chart from different angles.
o Use software tools (like OpenCV) to compute the camera matrix and distortion coefficients.
3. Capture Test Images:
o Capture images of the objects to be inspected under consistent lighting conditions.
o Save the images in a suitable format (e.g., JPEG, PNG) for processing.

B. Image Processing

1. Load the Images:


o Use Python with OpenCV or MATLAB to load the captured images.

51
52
python
Copy code
import cv2
image = cv2.imread('test_image.jpg')
cv2.imshow('Captured Image', image)
cv2.waitKey(0)
cv2.destroyAllWindows()

2. Pre-process the Images:


o Convert the images to grayscale for simpler analysis.
o Apply filters (e.g., Gaussian blur) to reduce noise.
o Use edge detection techniques (e.g., Canny edge detector) to highlight object boundaries.

python
Copy code
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
edges = cv2.Canny(blurred, 50, 150)
cv2.imshow('Edges', edges)

3. Object Detection and Feature Extraction:


o Use contour detection to find objects in the image.
o Extract features like shape, size, color, or texture for classification.

python
Copy code
contours, _ = cv2.findContours(edges, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
for cnt in contours:
cv2.drawContours(image, [cnt], 0, (0, 255, 0), 2)
cv2.imshow('Contours', image)

4. Classification:
o Implement classification using Machine Learning or Deep Learning algorithms.
o Split the dataset into training and testing sets.
o Use algorithms like Support Vector Machine (SVM), K-Nearest Neighbors (KNN), or a
Convolutional Neural Network (CNN) for classification.

python
Copy code
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
X_train, X_test, y_train, y_test = train_test_split(features, labels,
test_size=0.2)
model = SVC()
model.fit(X_train, y_train)
accuracy = model.score(X_test, y_test)
print(f'Classification Accuracy: {accuracy * 100:.2f}%')

5. Real-time Inspection (Optional):


o For real-time applications, integrate a live camera feed with processing and classification.

python
Copy code
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
if not ret:
break
# Apply processing steps here
cv2.imshow('Live Feed', frame)

53
54
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()

C. Analysis and Results

1. Evaluate the Accuracy:


o Test the system with various objects to determine the accuracy of inspection and
classification.
o Generate a confusion matrix to analyze the classification performance.
2. Optimize the System:
o Adjust camera settings, lighting, and algorithm parameters to improve accuracy.
o Experiment with different feature extraction techniques and classifiers for better results.

RESULT

• The vision-based system was able to successfully capture and process images for automated
inspection.
• The classification algorithm achieved an accuracy of X% (depending on the dataset and model
used).
• The system demonstrated robust performance in detecting defects or sorting objects based on
predefined criteria.
• Adjustments to lighting and camera calibration significantly improved the system’s accuracy.

55
56
INTERNET OF THINGS LABORATORY

57
DIAGRAM

plaintext
Copy code
+-------------------+
| DHT Sensor |
| (DHT11/DHT22) |
| |
+--------+----------+
|
| +---------------+
+----| ESP32/Arduino |
| |
| Wi-Fi |
+---------------+
|
| (Sends Data)
|
+---------------+
| Cloud |
| Platform |
+---------------+

58
EX. NO.: 1
DATE:

FAMILIARIZATION WITH CONCEPT OF IOT AND ITS OPEN SOURCE


MICROCONTROLLER/SBC

AIM

To create a simple IoT-based temperature monitoring system that sends temperature data to the cloud
for remote monitoring.

APPARATUS REQUIRED

1. Microcontroller: ESP32 or Arduino with ESP8266


2. Temperature Sensor: DHT11 or DHT22
3. Wi-Fi Module: (if using Arduino, ESP8266)
4. Cloud Platform: Thingspeak or Adafruit IO
5. Breadboard and Jumper Wires

PROCEDURE

1. Circuit Setup:

➢ Connect the DHT sensor to the microcontroller:


VCC to 3.3V/5V

GND to Ground

Data pin to a digital pin (e.g., GPIO 4)
2. Programming:

➢ Use the Arduino IDE to upload a program that reads data from the DHT sensor and sends it
to the cloud.
➢ Example Code Snippet (for ESP32):

cpp
Copy code
#include <DHT.h>
#include <WiFi.h>
#include <HTTPClient.h>

#define DHTPIN 4 // Pin where the sensor is connected


#define DHTTYPE DHT11 // DHT 11

DHT dht(DHTPIN, DHTTYPE);

const char* ssid = "your_SSID";


const char* password = "your_PASSWORD";
const char* server =
"http://api.thingspeak.com/update?api_key=YOUR_API_KEY";

void setup() {
Serial.begin(115200);
dht.begin();
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
}
59
60
}

void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();

if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}

HTTPClient http;
http.begin(server);
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
String httpRequestData = "field1=" + String(t);
http.POST(httpRequestData);
http.end();

delay(60000); // Send data every minute


}

3. Cloud Configuration:
o Sign up for a cloud service like Thingspeak.
o Create a new channel to receive temperature data.
o Obtain the API key and update it in the code.
4. Testing:
o Upload the code to the microcontroller.
o Monitor the serial output for connection status and data transmission.
o Check the cloud platform for incoming data.

OUTPUT

1. Running the Code:

• Upload the code to the ESP32 using the Arduino IDE.


• Open the Serial Monitor to see the IP address assigned to the ESP32 after connecting to Wi-Fi.

2. Accessing the Web Page:

• Open a web browser on your computer or smartphone.


• Enter the ESP32 IP address (e.g., http://192.168.1.100) into the address bar.

3. Expected Results:

• The web page will display the current temperature and humidity readings from the DHT11 sensor.
For example:

makefile
Copy code
Sensor Data
Temperature: 25.0 °C
Humidity: 60.0 %

RESULT

Thus a simple IoT-based temperature monitoring system was created and it sends temperature data
to the cloud for remote monitoring.
61
DIAGRAM

plaintext
Copy code
+---------------------+
| Motor |
+----------+----------+
|
| +----------------+
+---| Relay Module |
+----------------+
| |
+-----+ +-----+
| |
+----+-----+ +-----+----+
| Microcontroller | | Power |
| (ESP32/RPi) | | Supply |
+------------------+ +----------+
|
|
+---------------------+
| Internet |
+---------------------+
|
+-----+-----+
| Cloud/ |
| Mobile App|
+------------+

62
EX. NO.: 2
DATE:

WRITE A PROGRAM TO TURN ON/OFF MOTOR USING MICROCONTROLLER/SBC


THROUGH INTERNET

AIM

To create a system that allows you to turn a motor ON or OFF using a microcontroller (like an ESP32 or
Raspberry Pi) through an internet connection.

APPARATUS REQUIRED

1. Microcontroller/SBC: ESP32 or Raspberry Pi


2. Motor: DC motor
3. Relay Module: To control the motor
4. Power Supply: For the motor
5. Breadboard and Jumper Wires
6. Wi-Fi Connection
7. Cloud Platform: Blynk or any other IoT service for control

PROGRAM

Using ESP32 with Blynk

1. Set Up Blynk:
o Create a Blynk account and set up a new project.
o Add a Button widget to control the motor.
o Get the Auth Token for your project.
2. Wiring:
o Connect the relay module to an output pin on the ESP32 (e.g., GPIO 23).
o Connect the motor to the relay according to the relay module's instructions.
3. Arduino Code:

cpp
Copy code
#define BLYNK_PRINT Serial
#include <BlynkSimpleEsp32.h>

// Define Blynk authorization token


char auth[] = "Your_Blynk_Auth_Token";

// Define the pin for the relay


const int relayPin = 23;

void setup() {
Serial.begin(115200);
Blynk.begin(auth, "your_SSID", "your_PASSWORD");
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, LOW); // Initially turn OFF
}

BLYNK_WRITE(V0) { // Button on V0
int motorState = param.asInt(); // Get value from the button
if (motorState == 1) {
digitalWrite(relayPin, HIGH); // Turn ON the motor
Serial.println("Motor ON");
63
CALCULATION

• Motor Power Calculation:


o If the motor operates at 12V and draws 1A, the power can be calculated as:
P=V×I=12V×1A=12WP = V \times I = 12V \times 1A = 12WP=V×I=12V×1A=12W
• Relay Specifications:
o Ensure the relay can handle the voltage and current of the motor.
o For a 12V, 1A motor, choose a relay rated for at least 10A and 250V AC or appropriate DC
specifications.

64
} else {
digitalWrite(relayPin, LOW); // Turn OFF the motor
Serial.println("Motor OFF");
}
}

void loop() {
Blynk.run(); // Keep Blynk running
}

OUTPUT

1. Running the Code:

• Upload the code to the ESP32 using the Arduino IDE.


• Open the Serial Monitor to view the IP address assigned to the ESP32 after it connects to Wi-Fi.

2. Accessing the Web Interface:

• Open a web browser on your computer or smartphone.


• Enter the ESP32 IP address (e.g., http://192.168.1.100) into the address bar.

3. Expected Results:

• The web interface will display two buttons: "Turn ON" and "Turn OFF".
• When you click "Turn ON", the relay activates, and the motor will start running.
• When you click "Turn OFF", the relay deactivates, and the motor will stop.

Example Output in Web Browser:


plaintext
Copy code
Motor Control
[Turn ON] [Turn OFF]

RESULT

Thus the result of a system that allows you to turn a motor ON or OFF using a microcontroller
(like an ESP32 or Raspberry Pi) through an internet connection.

65
DIAGRAM

plaintext
Copy code
+-------------------+
| DHT Sensor |
| (DHT11/DHT22) |
+---------+---------+
|
|
+-----+------+
| Microcontroller |
| (ESP32) |
+-----+------+
|
|
+-------------------+
| Internet |
+-------------------+
|
+-------------------+
| Cloud Platform |
| (ThingSpeak/IO) |
+-------------------+

66
EX. NO.: 3
DATE:

WRITE A PROGRAM TO INTERFACE SENSORS TO DISPLAY THE DATA ON THE SCREEN


THROUGH INTERNET

AIM

To interface a temperature and humidity sensor (DHT11/DHT22) with a microcontroller (like ESP32 or
Raspberry Pi) and display the sensor data on a web-based dashboard.

APPARATUS REQUIRED

1. Microcontroller/SBC: ESP32 or Raspberry Pi


2. Temperature and Humidity Sensor: DHT11 or DHT22
3. Wi-Fi Connection
4. Cloud Platform: ThingSpeak or Adafruit IO for data visualization
5. Breadboard and Jumper Wires

PROGRAM

Using ESP32 with DHT Sensor and ThingSpeak

1. Wiring:
o Connect the DHT sensor:
▪ VCC to 3.3V
▪ GND to Ground
▪ Data pin to a digital pin (e.g., GPIO 4)
2. Setup ThingSpeak:
o Create an account on ThingSpeak.
o Create a new channel to store temperature and humidity data.
o Note down the Write API Key for your channel.
3. Arduino Code:

cpp
Copy code
#include <DHT.h>
#include <WiFi.h>
#include <HTTPClient.h>

#define DHTPIN 4 // Pin where the sensor is connected


#define DHTTYPE DHT11 // DHT 11

DHT dht(DHTPIN, DHTTYPE);

const char* ssid = "your_SSID";


const char* password = "your_PASSWORD";
const char* server = "http://api.thingspeak.com/update?api_key=YOUR_API_KEY";

void setup() {
Serial.begin(115200);
dht.begin();
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
67
CALCULATION

• Data Transmission Frequency:


o The data is sent every 60 seconds. Adjust this value based on the application requirement.
• API Data Format:
o The API request format for ThingSpeak is:

arduino
Copy code
http://api.thingspeak.com/update?api_key=YOUR_API_KEY&field1=temperature&fi
eld2=humidity

68
Serial.println("Connected to WiFi");
}

void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();

if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}

// Display data on Serial Monitor


Serial.print("Humidity: ");
Serial.print(h);
Serial.print("% Temperature: ");
Serial.print(t);
Serial.println("°C");

// Send data to ThingSpeak


HTTPClient http;
http.begin(server);
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
String httpRequestData = "field1=" + String(t) + "&field2=" + String(h);
int httpResponseCode = http.POST(httpRequestData);
http.end();

// Wait for 60 seconds before next reading


delay(60000);
}

OUTPUT

1. Running the Code:


o Upload the code to the ESP32 using the Arduino IDE.
o Open the Serial Monitor to view the IP address assigned to the ESP32 after it connects to Wi-
Fi.
2. Accessing the Web Page:
o Open a web browser on your computer or smartphone.
o Enter the ESP32 IP address (e.g., http://192.168.1.100) into the address bar.
3. Expected Results:
o The web page will display the current temperature and humidity readings.
o Example output:

makefile
Copy code
Sensor Data
Temperature: 25.0 °C
Humidity: 60.0 %

RESULT

Thus the result of a temperature and humidity sensor (DHT11/DHT22) with a microcontroller (like
ESP32 or Raspberry Pi) was interfaced, and the sensor data on a web-based dashboard were displayed.

69
DIAGRAM

plaintext
Copy code
+---------------------+
| Soil Moisture |
| Sensor |
+----------+----------+
|
|
+------+------+
| ESP32 |
| (Microcontroller) |
+------+------+
|
+---------------------+
| Relay Module |
+----------+----------+
|
|
+-----+-----+
| Solenoid |
| Valve |
+-----------+
|
+-------------+
| Power Supply |
+-------------+

70
EX. NO.: 4
DATE:

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 a sensor (like a moisture sensor) with a microcontroller (ESP32) to control a solenoid valve
over the internet based on the sensor data.

APPARATUS REQUIRED

1. Microcontroller: ESP32
2. Sensor: Soil Moisture Sensor
3. Solenoid Valve: Typically 12V
4. Relay Module: To control the solenoid valve
5. Power Supply: For the solenoid valve
6. Breadboard and Jumper Wires
7. Wi-Fi Connection
8. Cloud Platform: Blynk or ThingSpeak for remote control

PROGRAM

Using ESP32 with a Soil Moisture Sensor and Blynk

1. Wiring:
o Connect the soil moisture sensor:
▪ VCC to 3.3V
▪ GND to Ground
▪ Signal pin to an analog pin (e.g., GPIO 34)
o Connect the relay module:
▪ IN pin to a digital pin on ESP32 (e.g., GPIO 23)
▪ Connect the solenoid valve according to the relay specifications.
2. Setup Blynk:
o Create a Blynk account and set up a new project.
o Add a Button widget to control the solenoid valve.
o Get the Auth Token for your project.
3. Arduino Code:

cpp
Copy code
#define BLYNK_PRINT Serial
#include <BlynkSimpleEsp32.h>

// Define Blynk authorization token


char auth[] = "Your_Blynk_Auth_Token";

// Define pins
const int moisturePin = 34; // Analog pin for soil moisture sensor
const int relayPin = 23; // Pin for relay control

void setup() {
Serial.begin(115200);
71
CALCULATION

• Moisture Sensor Threshold:


o The threshold value for the soil moisture can be calibrated based on experiments. For
instance:
▪ A value below 300 might indicate dry soil, while above 700 indicates wet soil (these
values can vary based on the sensor and soil type).
• Relay Specifications:
o Ensure the relay can handle the solenoid valve's voltage and current. For example, if the
solenoid operates at 12V and draws 1A, use a relay rated for at least 10A and suitable for the
voltage.

72
Blynk.begin(auth, "your_SSID", "your_PASSWORD");
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, LOW); // Initially turn OFF solenoid
}

BLYNK_WRITE(V0) { // Button on V0
int motorState = param.asInt(); // Get value from the button
if (motorState == 1) {
digitalWrite(relayPin, HIGH); // Turn ON solenoid valve
Serial.println("Solenoid ON");
} else {
digitalWrite(relayPin, LOW); // Turn OFF solenoid valve
Serial.println("Solenoid OFF");
}
}

void loop() {
Blynk.run(); // Keep Blynk running

int moistureValue = analogRead(moisturePin); // Read soil moisture


Serial.print("Moisture Level: ");
Serial.println(moistureValue);

// Control solenoid based on moisture level


if (moistureValue < 300) { // Threshold for dry soil
digitalWrite(relayPin, HIGH); // Turn ON solenoid valve
Serial.println("Solenoid ON - Soil is dry");
} else {
digitalWrite(relayPin, LOW); // Turn OFF solenoid valve
Serial.println("Solenoid OFF - Soil is wet");
}

delay(5000); // Read every 5 seconds


}

OUTPUT

1. Running the Code:


o Upload the code to the ESP32 using the Arduino IDE.
o Open the Serial Monitor to see the IP address assigned to the ESP32 after connecting to Wi-
Fi.
2. Accessing the Web Page:
o Open a web browser on your computer or smartphone.
o Enter the ESP32 IP address (e.g., http://192.168.1.100) into the address bar.
3. Expected Results:
o The web page will display the soil moisture value.
o The solenoid valve will automatically turn ON or OFF based on the soil moisture readings.
o Example output:

yaml
Copy code
Soil Moisture Data
Soil Moisture Value: 450
Solenoid Valve: ON

RESULT

Thus a sensor (like a moisture sensor) was interfaced with a microcontroller (ESP32) to control a
solenoid valve over the internet based on the sensor data.

73
DIAGRAM

plaintext
Copy code
+-------------------+
| Temperature |
| Sensor |
| (DHT11/DHT22) |
+---------+---------+
|
|
+-----+------+
| ESP32 |
| (Microcontroller) |
+-----+------+
|
+---------------------+
| Relay Module |
+----------+----------+
|
|
+-----+-----+
| Linear/ |
| Rotary Actuator |
+-----------+
|
+-------------+
| Power Supply |
+-------------+

74
EX. NO.: 5
DATE:

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 (e.g., a temperature sensor) with a microcontroller (ESP32) to control a linear or
rotary actuator over the internet based on the sensor data.

APPARATUS REQUIRED

1. Microcontroller: ESP32
2. Sensor: Temperature Sensor (e.g., DHT11 or DHT22)
3. Actuator: Linear or Rotary Actuator
4. Relay Module: To control the actuator
5. Power Supply: For the actuator
6. Breadboard and Jumper Wires
7. Wi-Fi Connection
8. Cloud Platform: Blynk or ThingSpeak for remote control

PROGRAM

Using ESP32 with a Temperature Sensor and Blynk

1. Wiring:
o Connect the DHT sensor:
▪ VCC to 3.3V
▪ GND to Ground
▪ Data pin to an analog pin (e.g., GPIO 4)
o Connect the relay module to control the actuator:
▪ IN pin to a digital pin on ESP32 (e.g., GPIO 23)
2. Setup Blynk:
o Create a Blynk account and set up a new project.
o Add a Button widget to control the actuator.
o Get the Auth Token for your project.
3. Arduino Code:

cpp
Copy code
#define BLYNK_PRINT Serial
#include <DHT.h>
#include <BlynkSimpleEsp32.h>

// Define Blynk authorization token


char auth[] = "Your_Blynk_Auth_Token";

// Define pins
const int sensorPin = 4; // Pin for DHT sensor
const int relayPin = 23; // Pin for relay control

DHT dht(sensorPin, DHT11); // Initialize DHT sensor

75
CALCULATION

• Temperature Threshold:
o In the above program, the actuator turns ON when the temperature exceeds 30°C. This value
can be adjusted based on the specific application requirements.
• Relay Specifications:
o Ensure the relay is rated for the voltage and current required by the actuator. For example, if
the actuator requires 12V and draws 1A, use a relay rated for at least 10A and suitable for the
voltage.

76
void setup() {
Serial.begin(115200);
Blynk.begin(auth, "your_SSID", "your_PASSWORD");
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, LOW); // Initially turn OFF actuator
dht.begin();
}

BLYNK_WRITE(V0) { // Button on V0
int actuatorState = param.asInt(); // Get value from the button
if (actuatorState == 1) {
digitalWrite(relayPin, HIGH); // Turn ON actuator
Serial.println("Actuator ON");
} else {
digitalWrite(relayPin, LOW); // Turn OFF actuator
Serial.println("Actuator OFF");
}
}

void loop() {
Blynk.run(); // Keep Blynk running

// Read temperature
float t = dht.readTemperature();
Serial.print("Temperature: ");
Serial.println(t);

// Control actuator based on temperature threshold


if (t > 30.0) { // Threshold for high temperature
digitalWrite(relayPin, HIGH); // Turn ON actuator
Serial.println("Actuator ON - High Temperature");
} else {
digitalWrite(relayPin, LOW); // Turn OFF actuator
Serial.println("Actuator OFF - Temperature Normal");
}

delay(5000); // Read every 5 seconds


}

OUTPUT

1. Running the Code:


o Upload the code to the ESP32 using the Arduino IDE.
o Open the Serial Monitor to see the IP address assigned to the ESP32 after connecting to Wi-
Fi.
2. Accessing the Web Page:
o Open a web browser on your computer or smartphone.
o Enter the ESP32 IP address (e.g., http://192.168.1.100) into the address bar.
3. Expected Results:
o The web page will display the distance measured by the ultrasonic sensor.
o The actuator will turn ON or OFF based on the distance readings.
o Example output:

vbnet
Copy code
Distance Measurement
Distance: 5.0 cm
Actuator: ON

77
78
RESULT

Thus a sensor (e.g., a temperature sensor) was interfaced with a microcontroller (ESP32) to control a
linear or rotary actuator over the internet based on the sensor data.

79
DIAGRAM

plaintext
Copy code
+-------------------+
| Temperature |
| Sensor |
| (DHT11/DHT22) |
+---------+---------+
|
|
+-----+------+
| ESP32 |
| (Microcontroller) |
+-----+------+
|
+------+------+
| Bluetooth / |
| Wi-Fi |
+------+------+
|
+-----------------+
| Smartphone |
| (App for Data) |
+-----------------+

80
EX. NO.: 6
DATE:

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 temperature and humidity sensor (e.g., DHT11) with a microcontroller (ESP32) and send
the sensor data to a smartphone using Bluetooth or Wi-Fi.

APPARATUS REQUIRED

1. Microcontroller: ESP32 (with built-in Wi-Fi and Bluetooth)


2. Temperature and Humidity Sensor: DHT11 or DHT22
3. Smartphone: With appropriate app for receiving data
4. Breadboard and Jumper Wires
5. Wi-Fi Connection (if using Wi-Fi)

PROGRAM

Using ESP32 with DHT Sensor and Bluetooth

1. Wiring:
o Connect the DHT sensor:
▪ VCC to 3.3V
▪ GND to Ground
▪ Data pin to a digital pin (e.g., GPIO 4)
2. Arduino Code (for Bluetooth):

cpp
Copy code
#include <DHT.h>
#include <BluetoothSerial.h>

// Define DHT sensor


#define DHTPIN 4 // Pin where the sensor is connected
#define DHTTYPE DHT11 // DHT 11

DHT dht(DHTPIN, DHTTYPE);


BluetoothSerial SerialBT;

void setup() {
Serial.begin(115200);
SerialBT.begin("ESP32_Sensor"); // Bluetooth device name
dht.begin();
Serial.println("Bluetooth Device is Ready to Pair");
}

void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();

if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}

81
CALCULATION

• Data Transmission Frequency:


o In both programs, the sensor data is sent every 5 seconds. This interval can be adjusted based
on requirements.
• API Data Format (for Wi-Fi):
o The data is sent to ThingSpeak using the following format:

arduino
Copy code
http://api.thingspeak.com/update?api_key=YOUR_API_KEY&field1=temperature&fi
eld2=humidity

82
// Send data over Bluetooth
String data = "Temperature: " + String(t) + " °C, Humidity: " + String(h) + "
%";
SerialBT.println(data);
Serial.println(data);

delay(5000); // Send data every 5 seconds


}

Using ESP32 with DHT Sensor and Wi-Fi (ThingSpeak):

1. Arduino Code (for Wi-Fi):

cpp
Copy code
#include <DHT.h>
#include <WiFi.h>
#include <HTTPClient.h>

// Define DHT sensor


#define DHTPIN 4 // Pin where the sensor is connected
#define DHTTYPE DHT11 // DHT 11

DHT dht(DHTPIN, DHTTYPE);

const char* ssid = "your_SSID";


const char* password = "your_PASSWORD";
const char* server = "http://api.thingspeak.com/update?api_key=YOUR_API_KEY";

void setup() {
Serial.begin(115200);
dht.begin();
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {


delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
}

void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();

if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}

// Send data to ThingSpeak


HTTPClient http;
http.begin(server);
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
String httpRequestData = "field1=" + String(t) + "&field2=" + String(h);
int httpResponseCode = http.POST(httpRequestData);
http.end();

Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" °C, Humidity: ");
Serial.print(h);
Serial.println(" %");

83
84
delay(5000); // Send data every 5 seconds
}

OUTPUT

1. Running the Code:

• Upload the appropriate code (Wi-Fi or Bluetooth) to the ESP32 using the Arduino IDE.
• Open the Serial Monitor to view any debug messages.

2. Receiving Data on Smartphone:

• For Wi-Fi:
o Download the Blynk app and create a new project.
o Add two Value Display widgets to show temperature and humidity.
o Input the virtual pins (V0 for temperature and V1 for humidity).
o The app will display the sensor data in real-time.
• For Bluetooth:
o Use any Bluetooth terminal app on your smartphone (e.g., Bluetooth Terminal).
o Pair with "ESP32_Sensor".
o Open the connection to see the temperature and humidity data sent from the ESP32.

3. Expected Results:

• Wi-Fi (Blynk App):


o The Blynk app will show real-time updates of temperature and humidity.
• Bluetooth:
o The Bluetooth terminal will display data like:

yaml
Copy code
Temperature: 25.0 °C, Humidity: 60.0 %

RESULT

Thus a temperature and humidity sensor (e.g., DHT11) was interfaced with a microcontroller (ESP32)
and send the sensor data to a smartphone using Bluetooth or Wi-Fi.

85

You might also like