0% found this document useful (0 votes)
171 views34 pages

SBC Lab Manual

This laboratory report describes experiments conducted with an Arduino Uno to interface various sensors and devices. The experiments include blinking an LED, controlling an LED with pulse-width modulation, interfacing a 16x2 LCD display, and interfacing sensors such as a light sensor, temperature/humidity sensor, and motion sensor. Code examples and circuit diagrams are provided for each experiment along with brief explanations of the concepts and components involved.
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)
171 views34 pages

SBC Lab Manual

This laboratory report describes experiments conducted with an Arduino Uno to interface various sensors and devices. The experiments include blinking an LED, controlling an LED with pulse-width modulation, interfacing a 16x2 LCD display, and interfacing sensors such as a light sensor, temperature/humidity sensor, and motion sensor. Code examples and circuit diagrams are provided for each experiment along with brief explanations of the concepts and components involved.
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/ 34

SBC Based System Design & IoT

LABORATORY REPORT

SBC BASED SYSTEM DESIGN & IOT


 Course Code: CUTM1257

ELECTRICAL ENGINEERING

SCHOOL OF VOCATIONAL EDUCATION AND TRAINING, BBSR

CENTURION UNIVERSITY OF TECHNOLOGY & MANAGEMENT

RAMACHANDRAPUR, JATNI, KHURDA, BHUBANESWAR- 752050

Section: Diploma

Branch: Electrical ENGINEERING

Semester: 4TH

1
SBC Based System Design & IoT

COURSE NAME:

SBC BASED SYSTEM DESIGN & IOT LABORATORIES

List of Experiments:

1. Write a program to Blink LED using Arduino UNO. 


2. Write a program to Control LED with PWM.
3. Write a program to interface LCD (16x2) with Arduino.
4. Write a program to Interface of Light Sensor (LDR) with Arduino UNO.
5. Write a program to Interface MQ sensors With Arduino.
6. Write a program to Interface Temperature and Humidity sensor (DHT11) With Arduino.
7. Write a program to Interface Relay Module with Arduino UNO.
8. Write a program to Interface IR Module with Arduino UNO.
9. Write a program to Interface PIR Module with Arduino UNO.

INDEX

Exp.
Page
No. Date Name of The Experiments
No.
19.01.2022 Write a program to Blink LED using Arduino UNO. 
4-5
1.

20.01.2022 Write a program to Control LED with PWM


2. 6-8
20.01.2022 Write a program to interface LCD (16x2) with Arduino.
3. 9-11

22.01.2022 Write a program to Interface of Light Sensor (LDR) with


Arduino UNO.
4. 12-14

27.01.2022 Write a program to Interface MQ sensors With Arduino.


5. 15-21

2
SBC Based System Design & IoT
27.01.2022 Write a program to Interface Temperature and Humidity sensor
(DHT11) With Arduino.
6. 21-23

29.01.2022 Write a program to Interface Relay Module with Arduino


UNO.
24-27
7

02.02.2022
8 Write a program to Interface IR Module with Arduino UNO 28-31

03.02.2022 Write a program to Interface PIR Module with Arduino UNO.


9 31-34

3
SBC Based System Design & IoT

Experiment No.1 Date:

AIM OF THE EXPERIMENT:


 Write a program to Blink LED using Arduino UNO. 

APPARTUS REQUIRED:

SL Equipments Specification Quantity


NO
1 Arduino Uno  1
2 LED 1
3 Resistor 220 ohms 1
4 Jumper wires 4
5 Bread Board 1

BLOCK & CIRCUIT DIAGRAM:

CODE:
4
SBC Based System Design & IoT

int ledPin=8;

void setup()

pinMode(ledPin,OUTPUT);

void loop()

digitalWrite(ledPin,HIGH);

delay(1000);

digitalWrite(ledPin,LOW);

delay(1000);

THEORY: 

In this lesson, we will program the Arduino's GPIO output high level (+5V) and low level (0V), and then make
the LED which is connected to the Arduino’s GPIO flicker with a certain frequency.

The LED is the abbreviation of light emitting diode. It is usually made of gallium arsenide, gallium phosphide
semiconductor materials. The LED has two electrodes: a positive electrode and a negative one. 

 The main function of the resistor is to limit currents. In the circuit, the character ‘R’ represents resistor, and the
unit of resistor is ohm(Ω).

PROCEDURE:

● Connect one end of the resistor to the digital pin 8

● Connect the long leg of the LED (the positive leg, called the anode) to the other end of the resistor.

● Connect the short leg of the LED (the negative leg, called the cathode) to the GND.

5
SBC Based System Design & IoT

CONCLUSION:

After upload done, we have concluded that the on-board LED blink every second.

Experiment No.2

AIM OF THE EXPERIMENT:

Write a program to Control LED with PWM.

APPARTUS REQUIRED:

SL Equipments Specification Quantity


NO
1 Arduino Uno  1
2 LED 1
3 Resistor 220 ohms 1
4 Jumper wires 4
5 Bread Board 1

BLOCK & CIRCUIT DIAGRAM:

6
SBC Based System Design & IoT

CODE:

const int LED = 10;

int i = 0;

int wait = 10;

void setup()

pinMode(LED, OUTPUT);

void loop()

for(i = 0;i < 255;i++) {

analogWrite(LED,i);

delay(wait);

7
SBC Based System Design & IoT
}

for(i = 255;i > 0;i--) {

analogWrite(LED,i);

delay(wait);

THEORY: 

In order to fade your LED off and on, gradually increase your PWM value from 0 (all the way off) to 255
(all the way on), and then back to 0 once again to complete the cycle. In the sketch below, the PWM value is
set using a variable called brightness.

The LED is the abbreviation of light emitting diode. It is usually made of gallium arsenide, gallium phosphide
semiconductor materials. The LED has two electrodes: a positive electrode and a negative one. 

 The main function of the resistor is to limit currents. In the circuit, the character ‘R’ represents resistor, and the
unit of resistor is ohm(Ω).

PROCEDURE:

● Connect one end of the resistor to the digital pin 10

● Connect the long leg of the LED (the positive leg, called the anode) to the other end of the resistor.

● Connect the short leg of the LED (the negative leg, called the cathode) to the GND.

CONCLUSION:

After upload done, we have seen the on-board LED gradually increase the brightness and then gradually
decrease the brightness.

8
SBC Based System Design & IoT

Experiment No.3

AIM OF THE EXPERIMENT:

Write a program to interface LCD (16x2) with Arduino.

APPARTUS REQUIRED:

SL Equipments Specification Quantity


NO
1 Arduino Uno  1

9
SBC Based System Design & IoT
2 LCD Display 16 * 2 1
3 Resistor 220 ohms 1
4 Jumper wires Male-male As per
Female-male requirement
5 Bread Board mini 1

BLOCK & CIRCUIT DIAGRAM:

CODE:

#include<LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()

lcd.begin(16, 2);

void loop()

lcd.setCursor(0,0);

lcd.print(" Hello ");

10
SBC Based System Design & IoT
lcd.setCursor(2,1);

lcd.print(" World ");

THEORY: 

The process of controlling the display involves putting the data that form the image of what you want to display
into the data registers, then putting instructions in the instruction register. The Liquid Crystal Library simplifies
this for you so you don't need to know the low-level instructions.

The Hitachi-compatible LCDs can be controlled in two modes: 4-bit or 8-bit. The 4-bit mode requires seven I/O
pins from the Arduino, while the 8-bit mode requires 11 pins. For displaying text on the screen, you can do most
everything in 4-bit mode, so example shows how to control a 16x2 LCD in 4-bit mode.

 The main function of the resistor is to limit currents. In the circuit, the character ‘R’ represents resistor, and the
unit of resistor is ohm(Ω).

PROCEDURE:

To wire your LCD screen to your board, connect the following pins:

● LCD RS pin to digital pin 12


● LCD Enable pin to digital pin 11
● LCD D4 pin to digital pin 5
● LCD D5 pin to digital pin 4
● LCD D6 pin to digital pin 3
● LCD D7 pin to digital pin 2
● LCD R/W pin to GND
● LCD VSS pin to GND
● LCD VCC pin to 5V
● LCD LED+ to 5V through a 220-ohm resistor
● LCD LED- to GND

CONCLUSION:

After upload done, I will see that the LCD Display is showing ‘Hello World ‘

11
SBC Based System Design & IoT

Experiment No.4

AIM OF THE EXPERIMENT:

Write a program to Interface of Light Sensor (LDR) with Arduino UNO.

APPARTUS REQUIRED:

SL Equipments Specification Quantity


NO
1 Arduino Uno  1
12
SBC Based System Design & IoT
2 LCD 16 * 2 Display 1
3 Resistor 220 ohms 1
4 Jumper wires 6
5 Photoresistor 1
6 4.7 kΩ Resistor 1
7 Bread Board 1

BLOCK & CIRCUIT DIAGRAM:

CODE:

int sensorValue = 0;

void setup()

pinMode(A0, INPUT);

Serial.begin(9600);

pinMode(9, OUTPUT);

void loop()

13
SBC Based System Design & IoT
{

// read the value from the sensor

sensorValue = analogRead(A0);

// print the sensor reading so you know its range

Serial.println(sensorValue);

if(sensorValue>=852){

digitalWrite(9,HIGH);

}else{

digitalWrite(9,LOW);

// map the sensor reading to a range for the LED

// analogWrite(9, map(sensorValue, 0, 1023, 0, 255));

delay(100); // Wait for 100 millisecond(s)

THEORY: 
LDR sensor module is a low-cost digital sensor as well as analog sensor module, which is capable to measure
and detect light intensity. This sensor also is known as the Photoresistor sensor. This sensor has an onboard
LDR (Light Dependent Resistor), that helps it to detect light. This sensor module comes with 4 terminals.
Where the “DO” pin is a digital output pin and the “AO” pin is an analog output pin. The output of the module
goes high in the absence of light and it becomes low in the presence of light. The sensitivity of the sensor can be
adjusted using the onboard potentiometer.
LDR Sensor Module or Photoresistor sensor Pin Diagram

14
SBC Based System Design & IoT
Pin No Pin Name Description

1 VCC +5 v power supply Input Pin

2 GND Ground (-) power supply Input Pin

3 DO Digital Output Pin

4 AO Analog Output Pin

PROCEDURE:

● Connect the Analog pin A0 one of the end of the 4.7 kΩ resistor and to the negative pin of LDR

● Give 5v positive to the LDR

● Connect the long leg of the LED (the positive leg, called the anode) to the Digital pin 9

● Connect the negative of the led to GND with a resistor

CONCLUSION:

After upload done, we have seen that the led is adjusting its brightness according to the surrounding light of
LDR.

Experiment No.5 Date:

Aim of the Exp:

Write a program to Interface MQ sensors With Arduino.

List of equipment / tools:

Sl. No Tools / Equipment Specification Quantity


01 Arduino UNO 01
02 Breadboard Medium 01

15
SBC Based System Design & IoT
03 Smoke detection MQ-2 01
sensor
04 Resistor 221ohm 01
05 LED RED(5mm) 01
Green(5mm) 01
06 Buzzer 01
07 Jumper Wire Single Strand As per requirement

Drawing / Circuit / Program

16
SBC Based System Design & IoT

Theory

MQ-2 Smoke Sensor


The MQ-2 smoke sensor is sensitive to smoke and to the following flammable gases:
● LPG
● Butane
● Propane
● Methane
● Alcohol
● Hydrogen
The resistance of the sensor is different depending on the type of the gas.
The smoke sensor has a built-in potentiometer that allows you to adjust the sensor sensitivity according to how
accurate you want to detect gas.

17
SBC Based System Design & IoT

MQ-2 sensor

Sensor Pin-out details


Working Mechanism of MQ sensor
The voltage that the sensor outputs change accordingly to the smoke/gas level that exists in the atmosphere. The
sensor outputs a voltage that is proportional to the concentration of smoke/gas.
In other words, the relationship between voltage and gas concentration is the following:
● The greater the gas concentration, the greater the output voltage
● The lower the gas concentration, the lower the output voltage

18
SBC Based System Design & IoT

The output can be an analog signal (A0) that can be read with an analog input of the Arduino or a digital output
(D0) that can be read with a digital input of the Arduino.
CODE

int red Led = 12;

int green Led = 11;

int buzzer = 10;

int smokeA0 = A5;

// Your threshold values

int sensorThres = 400;

void setup () {

pin Mode (red Led, OUTPUT);

pin Mode (green Led, OUTPUT);

pin Mode (buzzer, OUTPUT);

pin Mode (smokeA0, INPUT);

Serial. Begin (9600);

void loop () {

int analog Sensor = analog Read(smokeA0);


19
SBC Based System Design & IoT
Serial. Print ("Pin A0: ");

Serial.println(analog Sensor);

// Checks if it has reached the threshold value

if (analog Sensor > sensorThres)

digital Write (red Led, HIGH);

digital Write (green Led, LOW);

tone (buzzer, 1000, 200);

else

digital Write (red Led, LOW);

digital Write (green Led, HIGH);

no Tone(buzzer);

delay (100);

Procedure

The MQ-2 sensor has 4 pins.


Pin Wiring to Arduino Uno
A0-------------------------------------Analog pins
D0-------------------------------------Digital pins
GND-----------------------------------GND
VCC------------------------------------5V
Before jumping into the coding part, we need to check whether we've assembled all the necessary hardware
components.
Conclusion

From the above experiment we have concluded that MQ sensor is working properly with Arduino through
programming.
20
SBC Based System Design & IoT

Experiment No.6 Date:

21
SBC Based System Design & IoT
Aim of the Exp:

Write a program to Interface Temperature and Humidity sensor (DHT11) With Arduino.

List of equipment / tools:

Sl. No Tools / Equipment Specification Quantity


01 Arduino UNO 01
02 Breadboard Medium 01
03 Temperature and DHT-11(3pins & 01
Humidity sensor 4pins)
04 Resistor 221ohm 01
05 Jumper Wire Single Strand As per requirement

Drawing / Circuit / Program

Theory

Humidity is the water vapor around you mixed with air. It is measured in per cents. So, if the humidity is 60 per
cent (which is the average humidity), then 60 per cent of the air around you are water vapor. If it is 100%, then
it means either the sensor is not correct, the sensor is broken/damaged, the Arduino crashed, the Arduino can't
receive any signal, there's an error in the code or you're underwater*. If it's 0%, it means all the reasons above
except the last one, you're in space or you're in the middle of a desert**.
* Correction: it means the air cannot hold any more water.
** The air in a desert does contain some water but it is a very little amount compared to a normal place. The
Sahara Desert has a mean humidity of 25%.

22
SBC Based System Design & IoT
CODE
#include <dht11.h>
#Define DHT11PIN 4

dht11 DHT11;

void setup ()
{
Serial. Begin (9600);

void loop ()
{
Serial.println();

int chk = DHT11.read(DHT11PIN);

Serial. Print ("Humidity (%): ");


Serial.println((float)DHT11.humidity, 2);

Serial. Print ("Temperature (C): ");


Serial.println((float)DHT11.temperature, 2);

delay (2000);

Procedure

You need to follow these instructions to make it work:


1. You need to add the library to the Arduino IDE.
2. Upload the code.
3. When the code is uploaded, open the Serial Monitor and set the baud rate to 9600.
4. You will see the humidity and temperature.

Conclusion

From the above experiment we have concluded that DHT-11 sensor is working properly with Arduino through
programming.

23
SBC Based System Design & IoT
Experiment No.7 Date:

Aim of the Exp:

Write a program to Interface Relay Module with Arduino UNO.

List of equipment / tools:

Sl. No Tools / Equipment Specification Quantity


01 Arduino UNO 01
02 Breadboard Medium 01
03 Relay Single channel 01
04 Resistor 221ohm 01
05 Jumper Wire Single Strand As per requirement

Drawing / Circuit / Program

Theory
A relay is an electromechanical switch used mainly for switching application either high voltage or low voltage
switching, and they can be also used with microcontrollers like the Arduino for controlling high voltage devices

24
SBC Based System Design & IoT

Relay Module
The aim of writing this is to serve as a guide while to interface the relay and the Arduino or the ESP 32
We'll be using the Arduino, Relay Module, Wires, LED (green) and a 220-ohm resistor
Input Side

25
SBC Based System Design & IoT

Output Side
The relay pinout is as follows;
On the Input side
Positive ---- "5v or External 5v Power Supply"
Control/Signal pin ----- "digital Write pins on the Arduino "
Negative ---- "Ground"
On the Output Side
Normally Closed ---- "preferably Empty"
Ground ----- "Ground"
Normally Open ---- "Negative Terminal of the Load "
Things to note when working with your Relay
* The relay is not an ideal switch...meaning don't use your relay for basic switching purpose like turning on/off
LED...it will wear off the mechanical parts faster...this example was just for demonstration
* They are not good for fast switch application
26
SBC Based System Design & IoT
* Relays are more suitable for high voltage application or relatively slow switching like controlling servos.

CODE
/* Relay and Arduino >>>> code by @_carlos_dev */

int relay Pin = 8; //Assign Pin 8 to the relay control/signal pin

void setup () {
// put your setup code here, to run once:
pinMode(relayPin, OUTPUT); //Setting the Relay pin as an Output Pin
}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(relayPin, HIGH); //Turn the relay ON for 1 second
delay(1000);
digitalWrite(relayPin,LOW); //Turn the relay OFF for 1 second
delay(1000);
}

Procedure
● Connect signal pin to the digital pin 8

● Upload the code.

● Connect the long leg of the LED (the positive leg, called the anode) to the other end of the resistor.

● Connect the short leg of the LED (the negative leg, called the cathode) to the GND.

Conclusion

From the above experiment we have concluded that Relay Module is working properly with Arduino through
programming.

27
SBC Based System Design & IoT

Experiment No.8 Date:

Aim of the Exp:

28
SBC Based System Design & IoT
Write a program to Interface IR Module with Arduino UNO.

List of equipment / tools:

Sl. No Tools / Equipment Specification Quantity


01 Arduino UNO 01
02 Breadboard Medium 01
03 IR mudule 3.3-5dc 01
04 led red 01
05 Jumper Wire Single Strand As per requirement

Drawing / Circuit / Program

Theory

IR Infrared Obstacle Avoidance Sensor Module has a pair of infrared transmitting and receiving tubes.
When the transmitted light waves are reflected back, the reflected IR waves will be received by the
receiver tube. The onboard comparator circuitry does the processing and the green indicator LED comes
to life.
 
The module features a 3-wire interface with Vcc, GND and an OUTPUT pin on its tail. It works fine with
3v3 to 5V levels. Upon hindrance/reflectance, the output pin gives out a digital signal (a low-level signal).
The onboard preset helps to fine tune the range of operation, effective distance range is 2cm to 80cm.

29
SBC Based System Design & IoT
Features:

● Onboard detection indication


● Effective distance range of 2cm to 80cm
● A preset knob to fine-tune distance range
● There is an obstacle, the green indicator light on the circuit board
● Detection distance: 2 ~ 12cm
● TTL output is high whenever it senses an obstacle
● Detection angle: 35 °
● Comparator chip: LM393
● 3mm screw holes for easy mounting
● Dimensions: 48 x 14 x 8 mm (LxWxH)
● Weight: 3gm

Package Includes:

● 1 x IR Infrared Obstacle Avoidance Sensor Module

Code

void setup () {

// put your setup code here, to run once:

pin Mode (4, INPUT);

pin Mode (12, OUTPUT) ;//LED

void loop () {

30
SBC Based System Design & IoT
// put your main code here, to run repeatedly:

if (digital Read (4) ==LOW) {

digital Write (12, HIGH);

else {

digital Write(12,LOW);

Procedure

● Connect input to the digital pin 4

● Connect input to the digital pin 12

● Upload the code

● Connect the long leg of the LED (the positive leg, called the anode) to the other end of the resistor.

● Connect the short leg of the LED (the negative leg, called the cathode) to the GND.

Conclusion

From the above experiment we have concluded that IR sensor is working properly with Arduino through
programming.

Experiment No.9 Date:

Aim of the Exp:

Write a program to Interface PIR Module with Arduino UNO.

31
SBC Based System Design & IoT
List of equipment / tools:

Sl. No Tools / Equipment Specification Quantity


01 Arduino UNO 01
02 Breadboard Medium 01
03 PIR mudule 3.3-5dc 01
04 led red 01
05 Jumper Wire Single Strand As per requirement

Drawing / Circuit / Program

Code

intcalibrationTime = 30;
//the time when the sensor outputs a low impulse
longunsigned intlowIn;
//the amount of milliseconds the sensor has to be low
//before we assume all motion has stopped
longunsigned intpause = 5000;
boolean lockLow = true;
32
SBC Based System Design & IoT
boolean takeLowTime;
intpirPin = 12; //the digital pin connected to the PIR sensor's output
intledPin = 13;
////
//SETUP
voidsetup(){
Serial.begin(9600);
pinMode(pirPin, INPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(pirPin, LOW);
//give the sensor some time to calibrate
Serial.print("calibrating sensor ");
for(inti = 0; i < calibrationTime; i++){
Serial.print(".");
delay(1000);
}
Serial.println(" done");
Serial.println("SENSOR ACTIVE");
delay(50);
}
//LOOP
voidloop(){
if(digitalRead(pirPin) == HIGH){
digitalWrite(ledPin, HIGH); //the led visualizes the sensors output pin state
if(lockLow){
lockLow = false;
Serial.println("---");
Serial.print("motion detected at ");
Serial.print(millis()/1000);
Serial.println(" sec");
delay(50);
}
takeLowTime = true;
}
if(digitalRead(pirPin) == LOW){
digitalWrite(ledPin, LOW); //the led visualizes the sensors output pin state
if(takeLowTime){
lowIn = millis(); //save the time of the transition from high to LOW
takeLowTime = false;
}
//if the sensor is low for more than the given pause,
//we assume that no more motion is going to happen
if(!lockLow && millis() - lowIn > pause){
//makes sure this block of code is only executed again after
//a new motion sequence has been detected
lockLow = true;
Serial.print("motion ended at "); //output
Serial.print((millis() - pause)/1000);
33
SBC Based System Design & IoT
Serial.println(" sec");
delay(50);
}
}
}
Theory

Theory:
PIR SENSOR: - A passive infrared sensor (PIR sensor) is an electronic sensor that measures infrared (IR)
light radiating from objects in its field of view. They are most often used in PIR-based motion detectors. PIR
sensors are commonly used in security alarms and automatic lighting applications.

Procedure: -

Most PIR modules have a 3-pin connection at the side or bottom. The pinout may vary between modules so
check the pinout carefully! Power is usually 3-5v DC input.

The circuit connections are made as follows:

Vcc pin of the HC-SR501 is connected to +3v of the NodeMCU.

Output pin of the HC-SR501 is connected to Digital pin D7 of the NodeMCU.

GND pin of the HC-SR501 is connected to Ground pin (GND) of the NodeMCU.

In this example we'll connect Anode pin of the LED to Digital pin D6 and Cathode pin to GND pin of


NodeMCU.

Conclusion

From the above experiment we have concluded that this experiment is working properly with Arduino UNO.

34

You might also like