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

Final IOT Manual

iot manual for se
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)
33 views

Final IOT Manual

iot manual for se
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/ 58

Matoshri Education Society’s

Matoshri College of Engineering & Research Centre, Eklahare, Nashik-422105

Department of Artificial Intelligence and Data Science Engineering

LABORATORY MANUAL
2022-2023

Internet of Things Laboratory(217531)


SE AI &DS
Semester - II

Subject Code : Companion Course 217529

TEACHING SCHEME EXAMINATION SCHEME


Lectures : 3Hrs / Week Practical : 25 Marks
Practical : 4Hrs / Week Term Work :50 Marks

-: Name of Faculty :-
Mrs. Sonali Deore
Matoshri College of Engineering & Research Centre,
Eklahare, Nashik-422105
Prerequisites:

1. Basic Programming Logic


2. Processor Architecture and Interfacing
3. Computer Network Technology
1.
Course Objectives:

1. To study IoT platforms such as Raspberry-Pi/Beagle board/ Arduino.


2. To study operating systems for platforms such as Raspberry-Pi/Beagle board/ Arduino.
3. To get knowledge for communicating with objects.
4. To explore cloud environment for IoT.
5. To provide knowledge for IoT related protocols such as MQTT / CoAP etc.
6. To design the web interface for IoT.

Laboratory Outcomes:

By the end of the course, students should be able to


1. To understand IoT platforms such as Raspberry-Pi/Beagle board/Arduino.
2. To understand operating systems for platforms such as Raspberry-Pi/Beagle
board/Arduino.
3. To communicate with objects using IoT platforms such as Raspberry-Pi/Beagle
board/Arduino.
4. To interface cloud environment for IoT application.
5. To implement IoT related protocols such as MQTT / CoAP etc.
6. To implement the web interface for IoT
INDEX

GROUP A

Sr.
Title Page No.
No.
Study of Raspberry-Pi/ Beagle board/ Arduino and other
1 microcontroller ( History & Elevation)
Study of different operating systems for Raspberry-Pi/Beagle
2 board/Arduino. Understanding the process of OS installation.

3 Study of different GATES (AND, OR, XOR), Sensors and basic binary
operations.

Study of Connectivity and configuration of Raspberry-Pi /Beagle


board/Arduino circuit with basic peripherals like LEDS.
4 Understanding GPIO and its use in the program

GROUP B

Sr.
Title Page No.
No.
Write a program using Arduino to control LED (One or more ON/OFF). Or
5 Blinking

Create a program that illuminates the green LED if the counter is less than
6 100, illuminates the yellow LED if the counter is between 101 and 200 and
illuminates the red LED if the counter is greater than 200

Create a program so that when the user enters "b" the green light blinks, "g" the
7 green light is illuminated "Y" the yellow light is illuminated and "r" the red
light is Illuminated

Write a program that asks the user for a number and outputs the number
8 squared that is entered
Write a program to control the color of the LED by turning 3 different
9 potentiometers. One will be read for the value of Red, one for the value of
Green, and one for the value of Blue
Write a program read the temperature sensor and send the values
10 to the serialmonitor on the computer

Write a program so it displays the temperature in Fahrenheit as


11 well as the maximum and minimum temperatures it has seen

Write a program to show the temperature and shows a graph of the recent
measurements
12
EXPERIMENT NO. 1 (Group A)

1. Aim: Study of Raspberry-Pi/ Beaglebone/ Arduino and other microcontroller (History & Elevation)

2. Outcome: At end of this experiment, student will be able to study of different microcontrollers like
Raspberry-Pi/ Beaglebone/ Arduino

3. Hardware Requirement: Arduino

4. Software Requirement: Arduino IDE

⮚ Theory:
Internet of Things: - IoT is short for Internet of Things. The Internet of Things refers to the ever-growing
network of physical objects that feature an IP address for internet connectivity, and the communication that
occurs between these objects and other Internet-enabled devices and systems. The Internet of Things (IoT)
refers to the use of intelligently connected devices and systems to leverage data gathered by embedded sensors
and actuators in machines and other physical objects. In other words, the IoT (Internet of Things) can be called to
any of the physical objects connected with network.
Examples of IoT: -

1) Apple Watch and Home Kit.


2) Smart Refrigerator.
3) Smart Refrigerator.
4) Smart cars.
5) Google Glass.
6) Smart thermostats.
A) Raspberry-Pi:-
The Raspberry Pi is a series of small single-board computers developed in the United Kingdom by the Raspberry
Pi Foundation to promote teaching of basic computer science in schools and in developing countries. It does not
include peripherals (such as keyboards and mice). The Raspberry Pi is a low cost, credit-card sized computer
that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. It is a capable little device
that enables people of all ages to explore computing, and to learn how to program in languages like Scratch and
Python. The Raspberry Pi is a credit-card-sized computer that costs between $5 and $35. It's available anywhere
in the world, and can function as a proper desktop computer or be used to build smart devices. A Raspberry Pi is
a general-purpose computer, usually with a Linux operating system, and the ability to run multiple programs.
Raspberry Pi is like the brain. Its primary advantage comes in processing higher level processing capability. It’s a
single board computer.
Here are the various components on the Raspberry Pi board:
1. ARM CPU/GPU -- This is a Broadcom BCM2835 System on a Chip (SoC) that's made up of an ARM central
processing unit (CPU) and a Video core 4 graphics processing unit (GPU). The CPU handles all the
computations that make a computer work (taking input, doing calculations and producing output), and
the GPU handles graphics output.
2. GPIO -- These are exposed general-purpose input/output connection points that will allow the real
hardware hobbyists the opportunity to tinker.
3. RCA -- An RCA jack allows connection of analog TVs and other similar output devices. ∙ Audio out -- This
is a standard 3.55-millimeter jack for connection of audio output devices such as headphones or
speakers. There is no audio in.
4. LEDs -- Light-emitting diodes, for your entire indicator light needs.
5. USB -- This is a common connection port for peripheral devices of all types (including your mouse and
keyboard). Model A has one, and Model B has two. You can use a USB hub to expand the number of ports
or plug your mouse into your keyboard if it has its own USB port.
6. HDMI -- This connector allows you to hook up a high-definition television or other compatible device
using an HDMI cable.
7. Power -- This is a 5v Micro USB power connector into which you can plug your compatible power supply.
8. SD card slot -- This is a full-sized SD card slot. An SD card with an operating system (OS) installed is
required for booting the device. They are available for purchase from the manufacturers, but you can also
download an OS and save it to the card yourself if you have a Linux machine and the wherewithal.
9. Ethernet -- This connector allows for wired network access and is only available on the Model B.

B) Beagle board: - The Beagle Board is a low-power open-source single-board computer produced by Texas
Instruments in association with Digi-Key and Newark element14. The Beagle Board was also designed with open
source software development in mind, and as a way of demonstrating the Texas Instrument's OMAP3530
system-on-a-chip. ] The board was developed by a small team of engineers as an educational board that could be
used in colleges around the world to teach open source hardware and software capabilities. It is also sold to the
public under the Creative Commons share-alike license. The board was designed using Cadence OrCAD for
schematics and Cadence Allegro for PCB manufacturing; no simulation software was used. Beagle Bone Black is a
low-cost, open source, community-supported development platform for ARM® Cortex™-A8 processor
developers and hobbyists. Boot Linux in under 10-seconds and get started on Sitara™ AM335x ARM Cortex-A8
processor development in less than 5 minutes with just a single USB cable.
Here are the various components on the Beagle board:
Processor: AM335x 1GHz ARM® Cortex-A8
∙ 512MB DDR3 RAM
∙ 4GB 8-bit eMMC on-board flash storage
∙ 3D graphics accelerator
∙ NEON floating-point accelerator
∙ 2x PRU 32-bit microcontrollers
Connectivity
∙ USB client for power & communications
∙ USB host
∙ Ethernet
∙ HDMI
∙ 2x 46 pin headers
Software Compatibility
∙ Debian
∙ Android
∙ Ubuntu
∙ Cloud9 IDE on Node.js w/ BoneScript library
∙ plus, much more
C) Arduino: - Arduino is an open-source hardware and software company, project and user community that
designs and manufactures single-board microcontrollers and microcontroller kits for building digital devices and
interactive objects that can sense and control objects in the physical and digital world. Arduino board designs use
a variety of microprocessors and controllers. The boards are equipped with sets of digital and analog
input/output (I/O) pins that may be interfaced to various expansion boards or breadboards (shields) and other
circuits. The boards feature serial communications interfaces, including Universal Serial Bus (USB) on some
models, which are also used for loading programs from personal computers. The microcontrollers are typically
programmed using a dialect of features from the programming languages C and C++. In addition to using
traditional compiler tool chains, the Arduino project provides an integrated development environment (IDE)
based on the Processing language project. Arduino is open-source hardware. The hardware reference designs are
distributed under a Creative Commons Attribution Share-Alike 2.5 license and are available on the Arduino
website. Layout and production files for some versions of the hardware are also available.

Here are the various components on the Arduino board:


Microcontrollers
1. ATmega328P (used on most recent boards)
2. ATmega168 (used on most Arduino Diecimila and early Duemilanove)
3. ATmega8 (used on some older board)

Digital Pins
In addition to the specific functions listed below, the digital pins on an Arduino board can be used for general
purpose input and output via the pinMode(), digitalRead(), and digitalWrite() commands. Each pin has an
internal pull-up resistor which can be turned on and off using digitalWrite() (w/ a value of HIGH or LOW,
respectively) when the pin is configured as an input. The maximum current per pin is 40 mA.
Analog Pins
In addition to the specific functions listed below, the analog input pins support 10-bit analog-to-digital
conversion (ADC) using the analogRead() function. Most of the analog inputs can also be used as digital pins:
analog input 0 as digital pin 14 through analog input 5 as digital pin 19. Analog inputs 6 and 7 (present on the
Mini and BT) cannot be used as digital pins.
Power Pins
∙ VIN (sometimes labelled "9V"). The input voltage to the Arduino board when it's using an external power source
(as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage
through this pin, or, if supplying voltage via the power jack, access it through this pin. Note that different boards
accept different input voltages ranges, please see the documentation for your board. Also note that the LilyPad
has no VIN pin and accepts only a regulated input.
Other Pins
1. AREF. Reference voltage for the analog inputs. Used with analog Reference().
2. Reset. (Diecimila-only) Bring this line LOW to reset the microcontroller. Typically used to add a reset
button to shields which block the one on the board. ∙ Analog Reference pin (orange) ∙ Digital Ground
(light green)
3. Digital Pins 2-13 (green)
4. Digital Pins 0-1/Serial In/Out - TX/RX (dark green) - These pins cannot be used for digital i/o
(digitalRead and digitalWrite) if you are also using serial communication (e.g. Serial.begin).
5. Reset Button - S1 (dark blue)
6. In-circuit Serial Programmer (blue-green)
7. Analog In Pins 0-5 (light blue)
8. Power and Ground Pins (power: orange, grounds: light orange)
9. External Power Supply In (9-12VDC) - X1 (pink)
10. Toggles External Power and USB Power (place jumper on two pins closest to desired supply) - SV1
(purple)
11. USB (used for uploading sketches to the board and for serial communication between the board and the
computer; can be used to power the board) (yellow)

Conclusion: -
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
________________________________________________________________________________________________________________________________
_________________________________
-------------------------------------------------------------------------------------------------------------------------

Questions:

Q1. Enlist and Explain different types of Arduino board ?

Q2. What’s the difference between digitalWrite() and analogWrite() in Arduino?

Q3. Can you give me some examples of real-world applications of Arduino?

Q4. What is the purpose of PWM in Arduino?

Q5. What are the different components of a Raspberry pi board?

Q6. How is Raspberry Pi different from Arduino?

Q7. What are the generations of Raspberry Pi available?

Q8. What is the maximum screen resolution output of Raspberry Pi?

EXPERIMENT NO. 02

Title: Study of different operating systems for Raspberry-Pi/Beagle board/Arduino. Understanding the
process of OS installation.

Aim: To Study different operating systems for Raspberry-Pi/Beagle board/Arduino. And to understand the
process of OS installation for each.
Outcome: To study operating systems for platforms such as Raspberry-Pi/Beagle board/Arduino.
Hardware Requirement: Raspberry-Pi
Software Requirement: Raspbian OS

Theory:

1) Raspberry-Pi: - The Pi can run the official Raspbian OS, Ubuntu Mate, Snappy Ubuntu Core,
the Kodi- based media centers OSMC and LibreElec, the non-Linux based Risc OS (one for fans of
1990s Acorn computers). It can also run Windows
10 IoT Core, which is very different to the desktop version of Windows, as mentioned below.
OS which install on Raspberry-Pi: Raspbian, Ubuntu MATE, Snappy Ubuntu, Pidora,
Linutop, SARPi, Arch Linux ARM, Gentoo Linux, etc.
How to install Raspbian on Raspberry-Pi:
Step 1: Download Raspbian
Step 2: Unzip the file. The Raspbian disc image is compressed, so you’ll need to unzip it. The

file uses the ZIP64 format, so depending on how current your built-in utilities are, you need to use

certain programs to unzip it.

Step 3: Write the disc image to your microSD card.


Next, pop your microSD card into your computer and write the disc image to it. The process of
actually writing the image will be slightly different across these programs, but it’s pretty self-
explanatory no matter what you’re using. Each of these programs will have you select the
destination (make sure you’ve picked your microSD card!) and the disc image (the unzipped Raspbian
file). Choose, double-check, and then hit the button to write.
Step 4: Put the microSD card in your Pi and boot up. Once the disc image has been written to the
microSD card, you’re ready to go! Put that sucker into your Raspberry Pi, plug in the
peripherals and power source, and enjoy. The current edition to Raspbian will boot directly to the
desktop. Your default credentials are username pi and password raspberry.

2) Beagle Bone Black: - The BeagleBone Black includes a 2GB or 4GB on-board eMMC
flash memory chip. It comes with the Debian distribution factory pre-installed. You can flash new
operating systems including Angstrom, Ubuntu, Android, and others.
1. Os which install on BeagleBone Black: Angstrom, Android, Debian, Fedora, Buildroot, Gentoo,
Nerves Erlang/OTP, Sabayon, Ubuntu, Yocto, MINIX 3

How to install Debian on BeagleBone Black:


 Step 1: Download Debian img.xz file.

 Step 2: Unzip the file.

 Step 3: Insert your MicroSD (uSD) card into the proper slot. Most uSD cards come with a full-sized
SD card that is really just an adapter. If this is what you have then insert the uSD into the adapter,
then into your card reader.

 Step 4: Now open Win32 Disk imager, click the blue folder icon, navigate to the debian img location,
and double click the file. Now click Write and let the process complete. Depending on your
processor and available RAM it should be done in around 5 minutes.
 Step 6: Now, this next part is pretty straight forward. Plug the USB cable in and wait some more. If
everything is going right you will notice that the four (4) leds just above the USB cable are doing the
KIT impression. This could take up to 4

 Step 5: Alright, once that's done, you'll get a notification pop-up. Now we're ready to get going.
Remove the SD adapter from the card slot, remove the uSD card from the adapter. With the USB
cable disconnected insert the uSD into the BBB. minutes; I just did it again in around 5 minutes.
Your mileage will vary. Go back and surf reddit some more.
 Step 7: If you are not seeing the leds swing back and forth you will need to unplug the USB cable,
press and hold down the user button above the uSD card slot (next to the 2 little 10 pin ICs) then
plug in the USB cable. Release the button and wait. You should see the LEDs swinging back and
forth after a few seconds. Once this happens it's waiting time. When all 4 LEDs next to the USB
slot stay lit at the same time the flash process has been completed.

 Step 8: Remove the uSD card and reboot your BBB. You can reboot the BBB by removing and
reconnecting the USB cable, or hitting the reset button above the USB cable near the edge of the
board.

 Step 9: Now using putty, or your SSH flavor of choice, connect to the BBB using the IP address
192.168.7.2. You'll be prompted for a username. Type root and press Enter. By default,
there is no root password. I recommend changing this ASAP if you plan on putting your BBB
on the network. To do this type password, hit enter, then enter your desired password. You
will be prompted to enter it again to verify.

3) Arduino: - The Arduino itself has no real operating system. You develop code for the Arduino
using the Arduino IDE which you can download from Arduino - Home. Versions are available for
Windows, Mac and Linux. The Arduino is a constrained microcontroller. Arduino consists of both
a physical programmable circuit board (often referred to as a microcontroller) and a piece of
software, or IDE (Integrated Development Environment) that runs on your computer, used to write
and upload computer code to the physical board. You are literally writing the "firmware"
when you write the code and upload it. It's both good and its bad

Conclusion: - Thus, we have studied of how to install operating systems for platforms such as
Raspberry-Pi/Beagle board/Arduino.

EXPERIMENT NO. 3 (Group A)

Aim: Study of different GATES (AND, OR, XOR), Sensors and basic binary operations.

Outcome: To study different GATES (AND, OR, XOR), Sensors

Hardware Requirement: Logical Gates,Sensors etc.

Software Requirement: Raspbian OS

Theory:
A logic gate is a device that acts as a building block for digital circuits. They perform basic logical
functions that are fundamental to digital circuits. Most electronic devices we use today will have
some form of logic gates in them. For example, logic gates can be used in technologies such as
smartphones, tablets or within memory devices. In a circuit, logic gates will make decisions based on a
combination of digital signals coming from its inputs. Most logic gates have two inputs and one output.
Logic gates are based on Boolean algebra. At any given moment, every terminal is in one of the two
binary conditions, false or true. False represents 0, and true represents 1. Depending on the type of logic
gate being used and the combination of inputs, the binary output will differ. A logic gate can be thought
of like a light switch, wherein one position the output is off -- 0, and in another, it is on -- 1. Logic gates
are commonly used in integrated circuits (IC).

Basic logic gates


There are seven basic logic gates: AND, OR, XOR, NOT, NAND, NOR, and XNOR.

AND Gate
The AND gate is so named because, if 0 is called "false" and 1 is called "true," the gate acts in the same way
as the logical "and" operator. The following illustration and table show the circuit symbol and logic
combinations for an AND gate. (In the symbol, the input terminals are at left and the output terminal is at
right.) The output is "true" when both inputs are "true." Otherwise, the output is "false." In other words, the
output is 1 only when both inputs one AND two are 1

Truth Table

2.OR Gate
The OR gate gets its name from the fact that it behaves after the fashion of the logical inclusive "or." The
output is "true" if either or both of the inputs are "true." If both inputs are "false," then the output is "false." In
other words, for the output to be 1, at least input one OR two must be 1.
Logic Diagram

Truth Table
3.XOR Gate
The XOR ( exclusive-OR ) gate acts in the same way as the logical "either/or." The output is "true" if either,
but not both, of the inputs are "true." The output is "false" if both inputs are "false" or if both inputs are "true."
Another way of looking at this circuit is to observe that the output is 1 if the inputs are different, but 0 if the
inputs are the same.

Logic Diagram

Truth Table

NOT Gate
A logical inverter, sometimes called a NOT gate to differentiate it from other types of electronic inverter
devices, has only one input. It reverses the logic state. If the input is 1, then the output is 0. If the input is
0, then the output is 1.

Logic Diagram

Truth Table
NAND Gate

The NAND gate operates as an AND gate followed by a NOT gate. It acts in the manner of the logical
operation "and" followed by negation. The output is "false" if both inputs are "true." Otherwise, the
output is "true."

Logic Diagram

Truth Table

XOR Gate
The XNOR (exclusive-NOR) gate is a combination XOR gate followed by an inverter. Its output is "true" if the
inputs are the same, and "false" if the inputs are different

Logic Diagram

Truth Table
Complex operations can be performed using combinations of these logic gates. In theory, there is no limit to
the number of gates that can be arrayed together in a single device. But in practice, there is a limit to the
number of gates that can be packed into a given physical space. Arrays of logic gates are found in digital
ICs. As IC technology advances, the required physical volume for each individual logic gate decreases
and digital devices of the same or smaller size become capable of performing ever-more-complicated
operations at ever- increasing speeds.
Composition of logic gates
High or low binary conditions are represented by different voltage levels. The logic state of a terminal can,
and generally does, often change as the circuit processes data. In most logic gates, the low state is
approximately zero volts (0 V), while the high state is approximately five volts positive (+5 V).
Logic gates can be made of resistors and transistors or diodes. A resistor can commonly be used as a pull-up
or pull-down resistor. Pull-up and pull-down resistors are used when there are any unused logic gate inputs to
connect to a logic level 1 or 0. This prevents any false switching of the gate. Pull-up resistors are connected to
Vcc (+5V), and pull-down resistors are connected to ground (0 V).
Sensors
There are many different types of sensors.
Sensors can be found in the home, the office, in our cars, buses, trains, trams, computers, medical facilities,
labs, power plants, restaurants, food processing factories, production lines etc
A Sensor is used to take a measurement, the measurement will be processed and the result of the process, an
output will be given. The output will then cause something to change or move. A simple example is the
temperature sensor in a thermostat. The temperature sensor is constantly monitoring the temperature, once
the measurement taken reaches the desired temperature, the measurement is processed and the output causes
the boiler to switch off.
Types of Sensors
There are many different types of sensors, the main categories are

 Position Sensors
 Pressure Sensors
 Temperature Sensors
 Force Sensors
 Vibration Sensors
 Piezo Sensors
 Fluid Property Sensors
 Humidity Sensors
 Strain gauges
 Photo Optic Sensors
 Flow and Level Switches
These categories can all be split further into subcategories for example, within position sensors there are the
following types;
 Contacting
 Non-contacting
 Rotary
 Linear

And these types of sensors can be split even further, within non-contacting you have the
following types of sensors;

 Hall effect
 Capacitive
 Eddy Current
 Ultrasonic
 Laser
 Proximity

Types of Sensors – Position Sensors

As discussed above there are many varieties of position sensor; linear, rotary, contacting, non- contacting
and use a variety of different technologies. Position sensors are used to measure and monitor the position or
displacement of an object.

We have been supplying position sensors for over 40 years and have developed our own range of position
sensors which have been added to the comprehensive range from our suppliers and partners. Our own range
includes;

Linear position Sensors

 VLP
 VXP
 ELPM
 VLPSC

Rotary Position Sensors

 Euro-X Hall Effect


 Euro-XP Puck – 2 part puck and magnet design
 Euro – XPD – D shaft
 CMRS
 CMRT
 CMRK

Types of Sensors – Pressure Sensors

Pressure sensors are often split into the following two categories; Pressure transducers and pressure
switches. The main difference is that pressure transducers give accurate feedback on real-time pressure
and pressure switches have a set limit which causes them to switch. Both pressure switches and pressure
transducers have mechanisms which use the formula – Pressure = force divided by area to detect pressure.

Pressure sensors can measure the pressure in gases, liquids or solids and are used in a variety of industries.
Underwater pressure transducers are referred to as level meters as the pressure they measure is directly
related to the level of the water.
Pressure can be gauge, differential, absolute or vacuum and can be measured in Bar or PSI.
Types of Sensors – Load Cells and Force Sensors

Load Cells are available in a wide variety of shapes and sizes. They are used to measure various types of
force, the main one being weight. Load cells are used in all types of scales; from bathroom scales to
counting scales, industrial scales, truck scales, hopper scales and everything in between.
Temperature Sensors

Temperature sensors are used to measure and monitor temperature, whether this is the main variable
requiring measuring or a secondary variable which requires monitoring as a safety precaution within
another application.
Different types of temperature sensors will require different approvals. Medical approvals will be required
for temperatures used for patient monitoring or within medical devices. Other certifications will be
required for temperature sensors in food and beverage applications.

Basic Binary Operations

The basic operations of mathematics- addition, subtraction, division and multiplication are performed on
two operands. Even when we try to add three numbers, we add two of them and then add the third number
to the result of the two numbers. Thus, the basic mathematical operations are performed on two numbers
and are known as binary operations
Types of Binary Operation
There are four main types of binary operations which are:

 Binary Addition
 Binary Subtraction
 Binary Multiplication
 Binary Division
Binary Addition
The result obtained after adding two binary numbers is the binary number itself. Binary addition is the
simplest method to add any of the binary numbers. It can be calculated easily if we know the following
rules.
Rules
 0+0=0
 0+1=1
 1+0=1
 1 + 1 =10
Let us take any two binary numbers and add them.
Add : 10001 + 11101 = 101110

Binary Subtraction
The result obtained after subtracting two binary numbers is the binary number itself. Binary subtraction is
also the simplest method to subtract any of the binary numbers. It can be calculated easily if we know the
following rules.
Rules
 0–0=0
 0 – 1 = 1 (with a borrow of 1)
 1–0=1
 1–1=0
Let us take any two binary numbers and subtract them.
Binary Multiplication
The binary multiplications are calculated similarly as the other arithmetics numerals are calculated. Let us
take any two binary numbers and multiply them.It can be calculated easily if we know the following rules.
Rules
 0×0=0
 0×1=0
 1×0=0
 1×1=1
Example: 1101 * 1010 = 10000010

Binary Division
The method of binary division is similar to the 10 decimal system other than the base 2 system. It can be
calculated easily if we know the following rules.
 1 ÷ 1=1
 1 ÷ 0 =0
 0 ÷ 1 = Meaningless
 0 ÷ 0= Meaningless
Conclusion: - Thus, we have studied different GATES (AND, OR, XOR), Sensors and basic binary
operations.
EXPERIMENT NO. 4 (Group A)

● Aim: Study of Connectivity and configuration of Raspberry-Pi /Beagle board/Arduino circuit


with basic peripherals like LEDS. Understanding GPIO and its use in the program.

● Outcome: Connectivity and configuration of Raspberry-Pi /Beagle board/Arduino circuit with


basic peripherals like LEDS

Hardware Requirement: Raspberry-Pi /Beagle board/Arduino, LED etc.

Theory:
Connecting Hardware Peripherals to Raspberry-Pi board. Raspberry-Pi setup through SSH
(Headless Configuration of Raspberry-Pi-3 (VNC, Putti))
How to Connect a Raspberry-Pi to the Laptop or PC Display
Required devices:
Raspberry Pi
Ethernet
Cable Laptop/
PC
SD Card with
Raspbian Micro USB
Cable
How does it Work?
To connect a Raspberry Pi to a laptop or PC display, you can simply use an Ethernet cable.
The Raspberry Pi’s desktop GUI can be viewed through the laptop or PC display using a
100mbps Ethernet connection between the two.
We used VNC server software to connect the Raspberry-Pi to our laptop or PC.
Installing the VNC server on your Raspberry-Pi allows you to see the Raspberry Pi’s desktop remotely.

Setting up your Raspberry Pi


Install Raspbian OS on blank SD card.
Insert this SD card into Raspberry-Pi
board.
Connect micro USB cable to power the Raspberry-Pi.
Sharing Internet Over Ethernet in Window OS
This step explains how you can share your laptop or PC with the Raspberry Pi via Ethernet cable.
To share internet with multiple users over Ethernet, go to Network and Sharing
Center. Then click on the WiFi network
Double click on Wireless area connection
Click on Properties (shown below)

Go to “Sharing” tab and click on “Allow other network users to connect”.

After this, make sure that the networking connection is changed to “Local Area Connection”
Now, to check the IP assigned to the network established, click on the new local area connection
link created:

Now open command prompt.


Ping the broadcast address of your IP. (Type) E.g. : ping 192.168.137.1Stop
the ping after 5 seconds.
To get the IP address of Raspberry Pi in the established network, use the Software “AdvanceIP
Scanner”. It is free software.

Setting up the VNC Server to Connect Your Raspberry Pi to the Laptop or PC


Display First install VNC server and Putty on your laptop/ PC
Open Putty Software, and enter login ID: pi and Password: raspberry.
After that, enter commands into Putty i.e,
$ sudo apt-get update
$ sudo apt-get install tightvncserver
$ vncserver :1
You will be prompted to enter and confirm a password.
This will be asked only once, during first time setup.
Enter an 8 digit password.
Note that this is the password you will need to use to connect to your Raspberry Pi remotely.
Setting Up the Client Side (Laptop or PC)
Download VNC client and install it.
When you first run VNC viewer, you will see following screen
Enter the IP address of your Raspberry Pi given dynamically by your laptop and append with : 1
(denoting port number) and press connect.
You will get a warning message, press ‘Continue’:

Enter the 8 digit password which was entered in the VNC server installation on your Raspberry Pi:
Finally, the Raspberry Pi desktop should appear as a VNC window.
You will be able to access the GUI and do everything as if you are using the Pi’s keyboard, mouse, and
monitor directly.

Raspberry-Pi setup using mouse, keyboard and monitor


To work with Raspberry-Pi, we have to connect some peripherals to it. They are as follows

A monitor with power cable and data cable


A micro USB power supply
A wired keyboard and mouse, or a wireless keyboard and
mouse A micro SD card
Monitors - HDMI
There are several different types of monitor that you can use with the Raspberry Pi:

Most modern television sets and monitors have an HDMI port, and are the easiest to get working
with the Raspberry Pi.
You can use an HDMI cable to connect the Raspberry Pi directly to the television or monitor.
VGA
Some old monitors have a VGA port.
These can be trickier to use as you'll need an HDMI-to-VGA converter, which can change digital video
to analogue video.
A simple port adapter won't work.
Power supplies
For Raspberry Pi 3, it's recommended to use a 5V, 2.5A power
supply. Mobile device charger
Many mobile devices are powered using a 5V micro USB charger.
These can often be used to power the Raspberry Pi, although it's worth checking that they provide

sufficient voltage and current (5V / 1.2 - 2.5A).


Keyboard and mouse
Wired keyboard and
mouse
Any standard USB keyboard and mouse can be used with the Raspberry Pi. These plug and
play devices will work without any additional driver. Simply plug them into the Raspberry Pi
and they should be recognized when it starts up.
Bluetooth keyboard and mouse
Bluetooth keyboards and mice can work with the Raspberry Pi, but your success rates will
vary depending on the model and manufacturer. It's best to consult the manufacturer's
documentation to see whether or not a device is compatible with the Raspberry Pi.
SD cards
The latest version of Raspbian, the default operating system recommended for the Raspberry Pi,
requires an 8GB (or larger) micro SD card. Not all SD cards are made equal, and some have higher
failure rates than others. Any 8GB SD card will work, although you'll need to follow the software
setup guide to learn how to load an operating system onto the card.
Understanding GPIO pins on Raspberry Pi board and its use in program
Aim/Objectives:
To understand the GPIO pins of Raspberry-Pi 3
To program the GPIO pins of Raspberry-Pi 3 using Python
Introduction:
Raspberry Pi 3 Model B is the latest version of raspberry pi
board. It is released on 29 February.
The above figure shows the Raspberry Pi 3 Model B and It’s GPIO pins
General-purpose input/output (GPIO) is a generic pin on an integrated circuit or computer board whose
behavior—including whether it is an input or output pin—is controllable by the user at run time.

There are 40 pins available on board of Raspberry pi 3 model B.


The Pins are arranged in a 2×20 fashion as shown in the figure above
Out of these, 26 pins are GPIO pins
As you can observe, the numbers to the pins are given in zigzag manner.
The first (bottom) row starts with number ‘1’. So the pins in this row have odd numbers i.e. from
1 to 39.
The 2nd (Top) row starts with number ‘2’. So the pins in this row have even numbers i.e. from 2 to
40. Out of 40 pins, 26 pins are GPIO pins,8 pins are Ground (GND) pins,2 pins are 5V power
supply pins 2 pins are 3.3V power supply pins, 2 pins are not used
Now if you’re coming to the Raspberry Pi as an Arduino user, you’re probably used to referencing
pins with a single, unique number.
In Raspberry Pi there are two different numbering schemes for referencing Pi pin numbers:
Broadcom chip-specific pin numbers (BCM)
Physical pin numbers (BOARD)
You’re free to use either number-system.
The programs require that you declare which scheme you’re using at the very beginning of your
program.
In a program, at a time, you can use only one number scheme.
Broadcom chip-specific pin numbers (BCM)
BCM - Broadcom pin number, commonly called "GPIO", these are the ones you probably want to
use with RPi.GPIO
The parameter used for this system is (GPIO.BCM).
This is a lower level way of working - it refers to the channel numbers on the Broadcom SOC.
To use this system, you have to always work with a diagram describing which channel number
goes to which pin on the RPi board.
Your script could break between revisions of Raspberry Pi boards.
In this system 26 GPIO pins are named as GPIO 01 to GPIO 26
Physical Numbering System (BOARD)
This system uses physical - Numbers corresponding to the pin's physical location on the
header The numbers printed on the board are physical numbering system.
The parameter used for this system is (GPIO.BOARD).
The advantage of using this numbering system is that your hardware will always work,
regardless of the board revision of the RPi.
You will not need to rewire your connector or change your
code. In this system
26 GPIO pins are named between 0 to 40

The below table summarizes the pinout of Raspberry-Pi in both the number systems.

Sr Pins BOARD Pin No BCM Pin No


No.
1 3.3V 1, 17 1, 17

2 5V 2, 4 2, 4
3 Ground 6,9,14,20,25,30,34,39 6,9,14,20,25,30,34,39
UART TXD 8 GPIO 14
4
RXD 10 GPIO 15
I2C1 SDA1 3 GPIO 2
SCL1 5 GPIO 3
5
I2C0 SDA0 27 ID_SD
SCL0 28 ID_SC
MOSI 0 19 GPIO 10

SPI0 MISO 0 21 GPIO 9


SCLK 0 23 GPIO 11
6 CE 0 24 GPIO 8
MOSI 1 38 GPIO 20
SPI1
MISO 1 35 GPIO 19
SCLK 1 40 GPIO 21
CE 1 26 GPIO 7

The Python IDLE shell and command line


To use the Python IDLE IDE for programming in Raspberry-Pi use the

following Open Python 3 from the main menu:


Or open terminal window and type the command sudo idle 3.5 and press
enter Install all libraries required for Buzzer as given above.
Write the program as per algorithm given below
Save with Ctrl + S and run with F5.
See output on Python Shell or Terminal Window.
Raspberry Pi GPIO programming using Python
The Raspberry Pi is often used in conjunction with other hardware to create interesting
electronic projects.
The Pi 3 comes with 40 GPIO pins that you can use to interface with various hardware
devices— for both receiving data from them or for writing data to them.
To do this, we have to program the GPIO pins. To do this, special libraries in Python are used.
To include these libraries in the program, the command used is ‘import’
This way, we can write applications to both read and also to control devices, i.e., turn them
on and off, etc.
The default operating system used in Raspberry-Pi is Raspbian.
The Python package used for Raspberry Pi GPIO programming is RPi.GPIO. It is already
installed in Raspbian.
If you are using any other operating system, the package can be installed by using the following
command:
$ sudo pip install RPi.GPIO
There are important 8 steps in the programming of Raspberry-Pi using Python as follows Import
the RPi.GPIO library using the following command import RPi.GPIO as GPIO Import the
Time library using the following command
import time
Set numbering scheme to be used. The method used for this is GPIO.setmode(). We will use
physical number scheme. So the method is written as
GPIO.setmode(GPIO.BOAD)
Set the pin mode as INPUT or OUTPUT using the commands GPIO.setup(channel, GPIO.IN)
GPIO.setup(channel, GPIO.OUT)
Read input using following command
GPIO.input(pin no)
Write output using following comman
GPIO.output(pin no, state)
Give delay using command using following command time.sleep(1) # delay for 1
second Clean up GPIO and exit using following commands GPIO.cleanup()
print(“Exiting...”)
You must clean up the pin set-ups before your program exits otherwise those pin settings will
persist, and that might cause trouble when you use the same pins in another program.
The Pi ‘expresses its displeasure’ with a warning.
To clean up the entire set of pins, invoke GPIO.cleanup().
If you want only a few pins to be cleaned up, then the pin numbers should be provided as
GPIO.cleanup (channel_list).
Anyway, you can suppress the warning messages by calling GPIO.setwarnings
(False). Save the program with proper name. The file is saved with extension ‘.py’.
The IDE named ‘IDLE’ used for programming is an interpreter and not a compiler. So to run
the python program, we need to give the super user permission as follows.

Studying Connectivity and Configuration of Raspberry Pi board with basic peripherals (LEDs)
Aim/Objectives:
To understand the concept of Led bar
To understand the common anode & common cathode configuration.
To interface LED bar with Raspberry Pi.
Generate various patterns on LED bar.
Software: Raspbian OS , IDLE editor
Hardware Modules: Raspberry Pi Board, LED bar, Monitor
Introduction to “LED”

LED is a Light Emitting Diode. Light emitting diode is a two lead semiconductor light source. It is a
p-n junction diode, which emits light when it is activated. When a suitable voltage is applied to the
leads, electrons are able to recombine with electron holes within the device, and the color of light
(corresponding to the energy of photon) is determined by the energy band gap of the semiconductor.
It has two terminals named as ‘anode (+ve)’ and ‘cathode (-ve)’. Battery is connected to these two
terminals. When LED is forward biased, it emits light. In LED bar number of LEDs are connected in
series (in our case 8 LEDs are connected) LED bar has two configurations as Common Anode: In this,
anode terminal of all the LEDs are made common and connected to the VCC (+5v). By controlling
cathode terminal we can make LED ON or OFF (current sourcing). Common Cathode: In this,
cathode terminal of all the LEDs are made common and connected to the Ground (0v). By controlling
anode terminal we can make LED ON or OFF (current sinking).

Safety precautions:
Raspberry-Pi provides 3.3V and 5V VCC
pins Raspberry-Pi operates on 3.3V.
Various sensors and actuators operate on different voltages.
Read datasheet of a given sensor or an actuator and then use appropriate VCC pin to connect a
sensor or an actuator.
Ensure that signal voltage coming to the Raspberry-Pi from any sensor or actuator does not
exceed 3.3V.
If signal/data coming to Raspberry-Pi is greater than 3.3V then use voltage level shifter
module to decrease the incoming voltage.
The Raspberry-Pi is a costly device, hence you should show the circuit connections to your
instructor before starting your experiment.
Interface diagram:

Steps for assembling circuit:


Connect led bar module pins from D0- D3 to Raspberry Pi GPIO pins 7, 11, 13, 15
respectively. Connect led bar module pin COM to the GND pin of Raspberry-Pi module.
Procedure:

Write the program as per the algorithm given below.


Save program.
Run code using Run
module. Algorithm:
Import GPIO and Time
library Set mode i.e.
GPIO.BOARD
Set GPIO 8 pins as a Output
pin Print message “ON”
After 1 second time delay, Make all the leds ON one by
one Print message “OFF”
After 1 second time delay, Make all the leds OFF one by one

Conclusion:

Questions:
1) Explain GPIO pins connectivity in details.
2) Explain programming of Raspberry-
EXPERIMENT NO. 5 (Group B)

Aim: Write a program using Arduino to control LED (One or more ON/OFF). Or Blinking

Outcome: Connectivity and configuration of Raspberry-Pi /Beagle board/Arduino circuit with


basic peripherals like LEDS

Hardware Requirement: Arduino, LED, 220 ohm resistor etc.

Software Requirement: Arduino IDE

Theory:
This example shows the simplest thing you can do with an Arduino to see physical output: it blinks the
on-board LED
This example uses the built-in LED that most Arduino boards have. This LED is connected to a
digital pin and its number may vary from board type to board type. To make your life easier, we
have a constant that is specified in every board descriptor file. This constant is LED_BUILTIN
and allows you to control the built-in LED easily. Here is the correspondence between the
constant and the digital pin.
● D13 - 101
● D13 - Due
● D1 - Gemma
● D13 - Intel Edison
● D13 - Intel Galileo Gen2
● D13 - Leonardo and Micro
● D13 - LilyPad
● D13 - LilyPad USB
● D13 - MEGA2560
● D13 - Mini
● D6 - MKR1000
● D13 - Nano
● D13 - Pro
● D13 - Pro Mini
● D13 - UNO
● D13 – Yún
● D13 – Zero

If you want to lit an external LED with this sketch, you need to build this circuit, where you
connect one end of the resistor to the digital pin correspondent to the LED_BUILTIN constant.
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. In
the diagram below we show an UNO board that has D13 as the LED_BUILTIN value.
The value of the resistor in series with the LED may be of a different value than 220 ohm; the
LED will lit up also with values up to 1K ohm.
Schematic

Code
After you build the circuit plug your Arduino board into your computer, start the Arduino
Software (IDE) and enter the code below. You may also load it from the menu
File/Examples/01.Basics/Blink . The first thing you do is to initialize LED_BUILTIN pin as an
output pin with the line
pinMode(LED_BUILTIN, OUTPUT);
In the main loop, you turn the LED on with the line:
digitalWrite(LED_BUILTIN, HIGH);
This supplies 5 volts to the LED anode. That creates a voltage difference across the pins of the
LED, and lights it up. Then you turn it off with the line:

digitalWrite(LED_BUILTIN, LOW);
That takes the LED_BUILTIN pin back to 0 volts, and turns the LED off. In between the on and
the off, you want enough time for a person to see the change, so the delay() commands tell the
board to do nothing for 1000 milliseconds, or one second. When you use the delay() command,
nothing else happens for that amount of time. Once you've understood the basic examples,
check out the BlinkWithoutDelay example to learn how to create a delay while doing other
things.
Once you've understood this example, check out the DigitalReadSerial example to learn how
read a switch connected to the board.

Conclusion: -
EXPERIMENT NO. 6 (Group B)

Aim: Create a program that illuminates the green LED if the counter is less than
100, illuminates the yellow LED if the counter is between 101 and 200 and
illuminates the red LED if the counter is greater than 200

Outcome: Connectivity, configuration and control of LED using Arduino circuit under
different conditions.

Hardware Requirement: Arduino, LED, 220 ohm resistor etc.


Software Requirement: Arduino IDE

Theory:
The problem statement is like Arduino traffic light, a fun little project that you can build
in under an hour. Here's how to build your own using an Arduino, and how to change
the circuit for an advanced variation.
What You Need to Build an Arduino Traffic Light Controller
Apart from the basic Arduino, you'll need:
● 1 x 10k-ohm resistor
● 1 x pushbutton switch
● 6 x 220-ohm resistors
● A breadboard
● Connecting wires
● Red, yellow and green

int counter = 0;
void setup()
{
Serial.begin(9600);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
}
void loop() {
if(counter == 31)
{
counter=0;
}
if(counter < 31)
{
Serial.println(counter);
}
counter = counter + 1;
delay(100);
if(counter > 0 && counter < 11 )
{
digitalWrite(7,HIGH);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
}
if(counter > 10 && counter < 21 )
{
digitalWrite(7,LOW);
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
}
if(counter > 20 && counter < 31 )
{
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,HIGH);
}

Conclusion: -
Experiment No. 7 (Group B)

Title: Create a program so that when the user enters "b" the green light blinks, "g" the
green light is illuminated "Y" the yellow light is illuminated and "r" the red light is
illuminated

Outcome: Connectivity, configuration and control of LED using Arduino circuit under
different conditions.
● Hardware Requirement: Arduino, LED, 220 ohm resistor etc.
● Software Requirement: Arduino IDE
● Theory:
The problem statement is like Arduino traffic light, a fun little project that you can build
in under an hour. Here's how to build your own using an Arduino, and how to change
the circuit for an advanced variation. For this Problem Statement we need to know about the ASCII code
as to covert user entered data.
ASCII stands for American Standard Code for Information Interchange. ASCII was originally designed
for use with teletypes, and so the descriptions are somewhat obscure and their use is frequently not as
intended.

Java actually uses Unicode, which includes ASCII and other characters from languages around the
world.

Apart from the basic Arduino, you'll need:


● 1 x 10k-ohm resistor
● 1 x pushbutton switch
● 6 x 220-ohm resistors
● A breadboard
● Connecting wires
● Red, yellow and green

CODE
int mychar = 0; // for incoming serial data
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
mychar = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(mychar);
}
if(mychar == 114 )
{
digitalWrite(7,HIGH);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
}
if(mychar == 103 )
{
digitalWrite(7,LOW);
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
}
if(mychar == 98 )
{
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,HIGH);
}

Conclusion:
EXPERIMENT NO. 8 (Group B)
● Aim: Write a program that asks the user for a number and outputs the number
squared that is entered
● Outcome: Connectivity, configuration and serial communication with Arduino.
● Hardware Requirement: Arduino, USB cable etc.
● Software Requirement: Arduino IDE
● Theory:
● Arduino Serial Monitor for Beginners
Arduino serial monitor for beginners in electronics. Send and receive data between the serial
monitor window on a computer and an Arduino. The serial monitor is a utility that is part of the
Arduino IDE. Send text from an Arduino board to the serial monitor window on a computer. In
addition, send text from the serial monitor window to an Arduino board. Communications between
the serial monitor and Arduino board takes place over the USB connection between the computer
and Arduino.
● Demonstration of the Arduino Serial Monitor for Beginners
Part 2 of this Arduino tutorial for beginners shows how to install the Arduino IDE. In addition, it
shows how to load an example sketch to an Arduino. It is necessary to know how to load a sketch to
an Arduino board in this part of the tutorial. Therefore, first finish the previous parts of this tutorial
before continuing with this part. A sketch loaded to an Arduino board demonstrates how the serial
monitor works in the sub-sections that follow.
● Load an Example Sketch that uses the Serial Monitor to an Arduino Board
Start the Arduino IDE application. Select File → Examples → 04.Communication → ASCIITable from
the top Arduino IDE menu bar. As a result, the ASCIITable example sketch opens in a new Arduino
IDE window. Upload the ASCIITable example sketch to the Arduino Uno or MEGA 2560 board.
After the ASCIITable sketch is uploaded, nothing is seen to happen. This is because this example
sketch sends text out of the USB port of the Arduino board. Because there is nothing running on the
computer to receive this text, nothing is seen.
● How to Open the Arduino Serial Monitor Window for Beginners
The following image shows the location of the serial monitor window icon on the Arduino IDE
toolbar. A red dot near the top right of the image shows the serial monitor toolbar icon location.
Click the Serial Monitor icon near the top right of the Arduino IDE to open the serial monitor window.
The above image shows the serial monitor window opened, and on top of the Arduino IDE window.
Because the ASCIITable example is loaded on the Arduino board, when the serial monitor window
opens, the Arduino sends text to the serial monitor window. This is also because opening the serial
monitor window resets the Arduino board, causing the ASCIITable sketch to run from the beginning
again.
The ASCIITable sketch sends text out of the USB port of the Arduino. Because the serial monitor is
connected to the USB port, it receives the text and displays it in the big receive area of the window. As
a result, text scrolls on the serial monitor window for a while. The text then stops because the
Arduino has finished sending text. Use the right scrollbar in the serial monitor window to scroll up.
Scrolling up reveals all of the text that the Arduino sent.
● What to do When Junk Characters are Displayed
When junk, or garbage characters, or even nothing is displayed in the serial monitor, it is usually
because of an incorrect baud rate setting. Look at the bottom of the serial monitor in the above
image. Notice the value 9600 baud in a box. This is the baud setting of communications between the
Arduino and serial monitor. The ASCIITable, and most other built-in example sketches, set the
Arduino to communicate at 9600 baud. If your serial monitor window shows a different baud rate,
change it to 9600 baud. Do this by clicking the baud drop-down list. Select 9600 baud on the list that
drops down.
● Reset the Arduino Board with the RESET Button
Press and release the RESET button on the Arduino board and the ASCIITable sketch runs from the
beginning again. As a result of the reset, the same text scrolls down the serial monitor window and
then stops again. The RESET button is the only push button on the Arduino Uno or MEGA 2560.
Pushing the RESET button in holds the board in reset. This means that the sketch currently loaded on
the board stops running. Releasing the RESET button takes the board out of reset. As a result, the
sketch currently loaded on the Arduino starts running from the beginning again.
 Clear the Serial Monitor Window Receive Area
The red dot in the image below shows the location of the Clear output button at the bottom of the
serial monitor window. Click the Clear output button and text is cleared from the receive area of the
serial monitor window. Reset the Arduino, and the receive area fills with text from the ASCIITable
sketch again.
● What the ASCIITable Sketch Does
ASCII stands for American Standard Code for Information Interchange. ASCII is a standard way that
uses numbers to represent various characters. For example, the decimal number 65 represents the
letter A. Another example is the decimal number 125 represents a closing brace: }. This allows
computers to send and receive text by sending and receiving numbers. For example when a computer
receives the number 65, it knows to display the letter A.
The ASCIITable sketch sends the numbers 33 through to 126 out of the USB port. This results in the
printable text characters from the ASCII table displayed in the serial monitor window. In addition to
the ASCII characters, the number that represents each character is displayed. Each number is shown
in four different numbering systems. These are the decimal, hexadecimal, octal and binary number
systems. In the serial monitor window, these number systems are abbreviated to dec, hex, oct and
bin.

CODE :
int out;
void setup()
{
Serial.begin(9600); // opens serial port, sets data rate to 9600
bps
}
void loop()
{
// send data only when you receive data:
if (Serial.available() > 0)
{
// read the incoming byte:
int num=Serial.readString().toInt();
// say what you got:
Serial.print("I received: ");
Serial.println(num);
out = num*num;
Serial.print("Sq of no.: ");
Serial.println(out);
}
}
Conclusion: -
____________________________________________________________________________________
____________________
EXPERIMENT NO. 9 (Group B)

● Aim: Write a program to control the color of the LED by turning 3 different potentiometers.
One will be read for the value of Red, one for the value of Green, and one for the value of Blue

● Outcome: Connectivity, configuration and control of LED using Arduino circuit under
different conditions.

● Hardware Requirement: Arduino, LED, 220 ohm resistor etc.

● Software Requirement: Arduino IDE

● Theory:
Control the color of an RGB LED
In this part you will create a color RGB led whose color can be changed through three potiontiometers

Steps to build the circuit:

As a best practice we’ll start with the ground (GND). It’s very important to make a common ground for
all components. To do this we will first plug a black wire (black is convention for GND) between a GND
pin of the Arduino and the “minus” line on the breadboard. From this “minus” line, then we will be able
to connect all other grounds, which will make things easier to manage.
Add the LED:

Connect the shorter leg of the LED to the ground. You can directly plug this leg into the “minus” line of
the breadboard, or add a small black wire.
Plug the other (longer) leg of the LED to an independent line on the breadboard.
From this leg, add a 220 Ohm resistor to yet another line.
Add a wire between the other side of the resistor and a PWM-compatible digital pin (so we can control
the brightness). Here on Arduino Uno you can choose between pins 3, 5, 6, 9, 10, and 11 – you can
recognize PWM compatibility with the “~” next to the pin number.

Add the Potentiometer:

Plug the 3 legs of the potentiometer to 3 different lines on the breadboard.


Connect the extreme left (or right) leg to GND.
Connect the other extreme leg to 5V on the Arduino.
Add a wire between the middle pin and an analog pin.
Arduino code to control LED brightness with the potentiometer

Code :
void setup()
{
pinMode(A0, INPUT);
pinMode(3, OUTPUT);
pinMode(A1, INPUT);
pinMode(5, OUTPUT);
pinMode(A2, INPUT);
pinMode(6, OUTPUT);
}
void loop()
{
analogWrite(3, analogRead(A0));
analogWrite(5, analogRead(A1));
analogWrite(6, analogRead(A2));
delay(10); // Delay a little bit to improve simulation performance
}

Conclusion :
EXPERIMENT NO. 10 (Group B)

● Aim: Write a program read the temperature sensor and send the values to the serial
monitor on the computer

● Outcome: Understanding working principle of DHT11, LM35 temperature sensor.

● Hardware Requirement: Arduino, LED, LM35, DHT11, etc

● Software Requirement: Arduino IDE

● Theory:

LM35 Temperature Sensor

LM35 Temperature Sensor Pinout


LM35 Sensor Pinout Configuration
Pin Pin Name Description
Numbe
r
1 Vcc Input voltage is +5V for typical applications

2 Analo There will be increase in 10mV for raise of every 1°C. Can
g Out range from -1V(-55°C) to 6V(150°C)

3 Ground Connected to ground of circuit

● LM35 Sensor Features


● Minimum and Maximum Input Voltage is 35V and -2V respectively. Typically 5V.
● Can measure temperature ranging from -55°C to 150°C
● Output voltage is directly proportional (Linear) to temperature (i.e.) there will be a rise
of 10mV (0.01V) for every 1°C rise in temperature.
● ±0.5°C Accuracy
● Drain current is less than 60uA
● Low cost temperature sensor
● Small and hence suitable for remote applications
● Available in TO-92, TO-220, TO-CAN and SOIC package
● LM35 Temperature Sensor Equivalent
LM34, DS18B20, DS1620, LM94022

How to use LM35 Temperature Sensor:


LM35 is a precession Integrated circuit Temperature sensor, whose output voltage varies, based on the
temperature around it. It is a small and cheap IC which can be used to measure temperature anywhere
between -55°C to 150°C. It can easily be interfaced with any Microcontroller that has ADC function
or anydevelopment platform like Arduino.
Power the IC by applying a regulated voltage like +5V (VS) to the input pin and connected the ground
pin to the ground of the circuit. Now, you can measure the temperature in form of voltage as shown

below.

If the temperature is 0°C, then the output voltage will also be 0V. There will be rise of 0.01V (10mV)
for every degree Celsius rise in temperature. The voltage can converted into temperature using the
below formulae.

● LM35 Temperature Sensor Applications


● Measuring temperature of a particular environment
● Providing thermal shutdown for a circuit/component
● Monitoring Battery Temperature
● Measuring Temperatures for HVAC applications.

● How Does LM35 Sensor Work?


Main advantage of LM35 is that it is linear i.e. 10mv/°C which means for every degree rise in
temperature the output of LM35 will rise by 10mv. So if the output of LM35 is 220mv/0.22V the
temperature will be 22°C. So if room temperature is 32°C then the output of LM35 will be 320mv i.e.
0.32V.
● LM35 Interfacing Circuit
● DHT11 interfacing with arduino and weather station
DHT11 sensor is used to measure the temperature and humidity. It has a resistive humidity sensing
component and a negative temperature coefficient (NTC). An 8 bit MCU is also connected in it which
is responsible for its fast response. It is very inexpensive but it gives values of both temperature and
humidity at a time.

● Specification of DHT11
● It has humidity range from 20 to 90% RH
● It has temperature range from 0 – 50 C
● It has signal transmission range of 20 m
● It is inexpensive
● It has fast response and it is also durable

● DHT11 Pin out


● The first pin of the DHT11 is vcc pin.
● The second pin of the DHT is Data pin.
● The third pin is not used.
● The fourth pin of the DHT sensor is ground.

● DHT11 interfacing with arduino


First of all connect the ground and the VCC of the DHT11 temperature and humidity sensor to the
ground and 5v of the Arduino. Then connect the data pin of the DHT11 sensor to the pin 2 of the
Arduino.

● Installing the DHT11 Library


To run the following code in Arduino IDE you will first have to install the DHT library in you
Arduino directory.
Download the zip file from here and place it in your Arduino library folder. The path to Arduino
library folder for my computer is
Documents/ Arduino/ Libraries
Unzip the downloaded file and place it in this folder.
After copying the files, the Arduino library folder should have a new folder named DHT containing
the dht.h and dht.cpp. After that copy the following code in the Arduino IDE and upload the code.

● Code of DHT11 interfacing with arduino

// Code for DHT11 Temperature and humidity sensor.


#include " DHT.h " // including the library of DHT11 temperature andhumidity sensor
#define DHTPIN 2 // Selecting the pin at which we have connectedDHT11
#define DHTTYPE DHT11 // Selecting the type of DHT sensors DHT dht (
DHTPIN, DHTTYPE ) ;
void setup ( ) { Serial.begin ( 9600 ) ;
dht.begin ( ) ; // The sensor will start working
}
void loop ( ) {
// Reading temperature or humidity may take about 2 seconds because it is a very slow sensor.

float humidity = dht.readHumidity ( ) ; // Declaring h a variable andstoring the humidity in it.


float temp = dht.readTemperature ( ) ; // Declaring t a variable andstoring the temperature in it.
// Checking if the output is correct. If these are NaN, then there issomething in it.
if ( isnan ( t ) || isnan ( h ) ) { Serial.println ( " Sensor not working
");
}
else
{

Serial.print ( " Temp is " ) ;


Serial.print ( temp ) ; // Printing the temperature ondisplay.
Serial.println ( " *C " ) ; // Printing “ *C ” on display. Serial.print (
" Humidity in % is : " ) ;
Serial.print ( humidity ) ; // Printing the humidity on display Serial.print (
" % \t " ) ; // Printing “%” on display

}
}

● Weather Station using DHT11 and arduino


In this example we will make a weather station that will sense the humidity and temperature and will
show it on the lcd attached to the Arduino. Make the circuit as shown in the diagram. The resistor in
the circuit will make the black light darker. We have used the 220 ohm resistor but you can use any
resistor having value near to that. The potentiometer we used in the circuit is used to set the screen
contrast. We
have used the 10 K ohm value but you can choose any value relative to that one.

● Components Required
● Arduino Uno (you can use any)
● 16 x 2 LCD
● DHT11 Temperature and humidity sensor
● 10 K ohm potentiometer
● 220 ohm resistor

● Code of weather station using arduino and DHT11


// This code is for the weather station using the DHT11 humidity and temperaturesensor.
// Install the library of the DHT before uploading the code in the Arduino IDE#include < dht.h >
// including the DHT library
#include < LiquidCrystal.h > // including the LCD library LiquidCrystal lcd (
12, 11, 5, 4, 3, 2 ) ; // initializing the lcd pinsdht DHT ; // declaring dht a variable
#define DHT11_PIN 8 // initializing pin 8 for dhtvoid setup
(){
lcd.begin ( 16, 2 ) ; // starting the 16 x 2 lcd
}
void loop ( )
{
int chk = DHT.read11(DHT11_PIN ) ; // Checking that either the dht is working
or not
lcd.setCursor ( 0, 0 ) ; // starting the cursor from top left

lcd.print ( " Temperature is : " ) ; // printing the “ Temperature is : ” onthe lcd


lcd.print ( DHT.temperature ) ; // printing the temperature on the lcd lcd.print (
( char ) 223 ) ;
lcd.print ( " C " ) ; // Printing “ C “ on the display
lcd.setCursor ( 0 , 1 );
lcd.print ( " Humidity is : " ) ; // printing “ humidity is : ” on thedisplay
lcd.print ( DHT.humidity ) ; // printing humidity on the display lcd.print
("%"); // printing “ % ” on display
delay ( 1000 ) ; // Giving delay of 1 second.

}
------------------------------------------------------------------------------------------------------------------------
Conclusion: -

-------------------------------------------------------------------------------------------------------------------------
EXPERIMENT NO. 11 (Group B)

Aim: Write a program so it displays the temperature in Fahrenheit as well as


the maximum and minimum temperatures it has seen

● Outcome: Understanding working principle of DHT11, LM35 temperature sensor,


Relationship between different temperature scales

● Hardware Requirement: Arduino, LED, LM35, DHT11, etc

● Software Requirement: Arduino IDE

● Theory:

LM35 Temperature Sensor

LM35 Temperature Sensor Pinout


LM35 Sensor Pinout Configuration
Pin Pin Name Description
Numbe
r
1 Vcc Input voltage is +5V for typical applications

2 Analo There will be increase in 10mV for raise of every 1°C. Can
g Out range from -1V(-55°C) to 6V(150°C)

3 Ground Connected to ground of circuit

● LM35 Sensor Features


● Minimum and Maximum Input Voltage is 35V and -2V respectively. Typically 5V.
● Can measure temperature ranging from -55°C to 150°C
● Output voltage is directly proportional (Linear) to temperature (i.e.) there will be a rise
of 10mV (0.01V) for every 1°C rise in temperature.
● ±0.5°C Accuracy
● Drain current is less than 60uA
● Low cost temperature sensor
● Small and hence suitable for remote applications
● Available in TO-92, TO-220, TO-CAN and SOIC package
Code:
int val;

int tempPin = 0; float tfmax; float tfmin

= 100; void setup()

Serial.begin(9600);

void loop()

val = analogRead(tempPin); float mv = (

val/1024.0)*500; float cel = mv;

float farh = (cel*9)/5 + 32;

// Serial.print("TEMPRATURE = ");

// Serial.print(cel);

// Serial.print("*C");

// Serial.println();

// delay(1000);

if (farh > tfmax)

tfmax = farh;

if (farh < tfmin)

tfmin = farh;

}
Conclusion: -

-------------------------------------------------------------------------------------------------------------------------
EXPERIMENT NO. 12 (Group B)

● Aim: Write a program to show the temperature and shows a graph of the recent
measurements

● Outcome: Understanding working principle of DHT11 temperature sensor, Blynk IOT


Platform

● Hardware Requirement: Arduino(Node MCU), LM35, DHT11, etc

● Software Requirement: Arduino IDE

● Theory:

1. Introduction:
In this project using an esp8266, to show the temperature and humidity DHT11 sensor on your
Smartphone or tablet. The NodeMCU collects the temperature and humidity from DHT11 sensor and
sends it to Blynk app every second.

1.2 Hardware required

Blynk Board and NodeMCU is used in this example. Inset NodeMCU to the Blynk board as shown in
the image ahead then connect NodeMCU to PC or Laptop through USB cable.

2. On Blynk App
You need to perform following steps on Blynk App.

2.1 Create a New Project in BLYNK app.Write Project name Temperature Humidity and
Select NodeMCU from drop down.
2.2 An AUTH token will be sent to your registered email, note this down. Tap on the screen
and add a 2 Gauges.
2.3 Tap on the Widget and select the respective Virtual pins for temperature and humidity data (V0 for
temperature and V1 for humidity).

Note: Make sure to setup Reading rate as ‘1’ second for all Widgets. And add gauges for both
Humidity and Temperature.

3. Code the NodeMCU with the following code.


Before uploading, make sure to paste your authorization token into the auth [] variable. Also make
sure to load your Wifi network settings into the Blynk.begin(auth, “ssid”, “pass”) function.

Following code may be downloaded from here.

// Robo India Tutorial


// Digital Output on LED
// Hardware: NodeMCU Blynk Board #define

BLYNK_PRINT Serial

#include <ESP8266WiFi.h> #include


<BlynkSimpleEsp8266.h>
#include "DHT.h" // including the library of DHT11 temperature and humidity
sensor
#include <SimpleTimer.h> //including the library of SimpleTimer #define
DHTTYPE DHT11 // DHT 11

#define dht_dpin 14
DHT dht(dht_dpin, DHTTYPE); SimpleTimer
timer;
char auth[] = "Your Auth. Key"; // You should get Auth Token in
the Blynk App. (nut
// Go to the Project Settings
icon).

char ssid[] = "Your Wifi Network name"; // Your WiFi credentials.


char pass[] = "Password of your network"; // Set password to "" for opennetworks.
float t; // Declare the variables
float h;

void setup()
{
Serial.begin(9600);// Debug console Blynk.begin(auth,
ssid, pass); dht.begin();
timer.setInterval(2000, sendUptime);
}

void sendUptime()
{

float h = dht.readHumidity(); float t =


dht.readTemperature();
Serial.println("Humidity and temperature\n\n"); Serial.print("Current
humidity = "); Serial.print(h);
Serial.print("% "); Serial.print("temperature =
"); Serial.print(t); Blynk.virtualWrite(V0, t);
Blynk.virtualWrite(V1, h);

void loop()
{
Blynk.run();
timer.run();
}

4. Output
After Uploading the Ardunio code IDE. Press the play button on blynk app to show the output.
-------------------------------------------------------------------------------------------------------------------
-----
Conclusion: -

-------------------------------------------------------------------------------------------------------------------------

You might also like