You are on page 1of 93

IoT – Sensors and

Devices
© Kalasalingam academy of research and education
Course Outline
CO1: : Distinguish between the different concepts of
IoT for its applications.

CO2: Analyze the optimal usage of


microcontroller.
Course description:
CO3: Demonstrate the usage of sensors and
actuators for specific requirements To expose the students to the fundamental
concepts of Microcontrollers and its interfacing,
CO4: Analyze the communication protocols for that will help them put a strong foundation for the
different devices and its applications. implementation of Internet of things in real time.
CO5: Inspect the various cloud services in alignment
with the corresponding IoT devices.

CO6: Work effectively in as team and individual in doing the


experiments following the safety procedures and ethics and
document effectively the experiments carried out in the
laboratory.

© Kalasalingam academy of research and education IOT – SENSORS AND DEVICES 2


Unit-2: Introduction to
Microcontrollers
Syllabus – Lecture contents

 Number system Unit 2


 Logic Gates
 Analog and Digital Signals Introduction to Microntrollers
 ADC & DAC
 PWM
 Microprocessor and Microcontroller
 Microcontroller types - Arduino UNO
Architecture
 ESP8266 Architecture.
© Kalasalingam
© Kalasalingam academy
academy of research
of research and education
and education COURSENAME: IOT: SENSORS AND DEVICES
What is Number System ?
• A system for representing number of certain type.
• Example:
–There are several systems for representing the counting numbers.
– These include the usual base “10” or decimal system : 1,2,3
,…..10,11,12,..99,100,…

© Kalasalingam academy of research and education


Unit 2 Outline & Course in Progress

Lesson 1. Number system


Lesson 2. Logic Gates
Lesson 3. Analog and Digital Signals
Lesson4: Microprocessor and Microcontroller
Lesson5: Microcontroller types - Arduino UNO Architecture
Lesson6: ADC & DAC
Lesson7: PWM
Lesson8: ESP8266 Architecture

© Kalasalingam academy of research and education IOT – SENSORS AND DEVICES


Common Number System
Used by Used in
System Base Symbols humans? computers?
Decimal 10 0, 1, … 9 Yes No
Binary 2 0, 1 No Yes
Octal 8 0, 1, … 7 No No
Hexa- 16 0, 1, … 9, No No
decimal A, B, … F

© Kalasalingam academy of research and education


Counting

Decimal Binary Octal Hexa- decimal Decimal Binary Octal Hexa-


decimal

0 0 0 0 8 1000 10 8
1 1 1 1 9 1001 11 9
2 10 2 2 10 1010 12 A
3 11 3 3 11 1011 13 B
4 100 4 4 12 1100 14 C
5 101 5 5 13 1101 15 D
6 110 6 6 14 1110 16 E
7 111 7 7 15 1111 17 F

© Kalasalingam academy of research and education


Conversion Among Bases
The possibilities:

Decimal Octal

Binary Hexadecimal

© Kalasalingam academy of research and education


Unit 2 Outline & Course in Progress

Lesson 1. Number system


Lesson 2. Logic Gates
Lesson 3. Analog and Digital Signals
Lesson4: Microprocessor and Microcontroller
Lesson5: Microcontroller types - Arduino UNO Architecture
Lesson6: ADC & DAC
Lesson7: PWM
Lesson8: ESP8266 Architecture

© Kalasalingam academy of research and education IOT – SENSORS AND DEVICES


Logic Gates
What are logic gates?
Logic gates are the switches that turn ON or OFF depending on what the user is doing!
They are the building blocks for how computers work.
Logic gates turn ON when a certain condition is true, and OFF when the condition is false
They check whether or not the information they get follows a certain rule
They either spit out the answer true (ON) or false (OFF)
Remember: – True= ON = 1 – False = OFF=0

© Kalasalingam academy of research and education


Logic Gates
Let’s do an example
Let’s say a certain logic gate needs to determine if two
numbers are equal
The rule would be “is equal” , If the two input numbers are
equal, it will go into its ON position, indicating true
If they are not equal, it will go into its OFF position, indicating
falsee!

© Kalasalingam academy of research and education


Logic Gates
But we learned before that computers only think of
things in terms of ON and OFF, which to them is 1 and
0
So a computer wouldn’t take an input of 5 or 6 – all of
the information need to be 0s and 1s
Reminder: Input refers to the information you give
the logic gate, and output refers to what it spits out!
 Let’s try this example again, keeping this rule in
mind!

© Kalasalingam academy of research and education


Logic Gates
HOW DO WE DESCRIBE THE BEHAVIOR OF
GATES AND CIRCUITS? SIX TYPES OF GATES
NOT
BOOLEAN EXPRESSIONS
AND
USES BOOLEAN ALGEBRA, A MATHEMATICAL OR
NOTATION FOR EXPRESSING TWO-VALUED LOGIC
XOR
LOGIC DIAGRAMS NAND
A GRAPHICAL REPRESENTATION OF A CIRCUIT; EACH NOR
GATE HAS ITS
OWN SYMBOL TYPICALLY, LOGIC DIAGRAMS ARE BLACK
AND WHITE WITH GATES DISTINGUISHED
TRUTH TABLES
ONLY BY THEIR SHAPE
A TABLE SHOWING ALL POSSIBLE INPUT VALUE AND
THE
ASSOCIATED OUTPUT VALUES
© Kalasalingam academy of research and education
NOT Gate & AND Gate
A NOT GATE ACCEPTS ONE INPUT SIGNAL (0 OR 1) AN AND GATE ACCEPTS TWO INPUT SIGNALS.
AND RETURNS THE OPPOSITE SIGNAL AS OUTPUT IF BOTH ARE 1, THE OUTPUT IS 1; OTHERWISE, THE OUTPUT IS 0.

© Kalasalingam academy of research and education


OR Gate & EX-OR Gate
AN OR GATE ACCEPTS TWO INPUT SIGNALS AN EXOR GATE ACCEPTS TWO INPUT SIGNALS
IF BOTH ARE 0, THE OUTPUT IS 0; OTHERWISE, IF BOTH ARE THE SAME, THE OUTPUT IS 0; OTHERWISE, THE OUTPUT IS 1
THE OUTPUT IS 1

Note the difference between the XOR gate and the OR gate; they
differ only in one input situation.
When both input signals are 1, the OR gate produces a 1 and the XOR
produces a 0
XOR is called the exclusive OR

© Kalasalingam academy of research and education


NAND Gate and NOR Gate
THE NAND GATE ACCEPTS TWO INPUT SIGNALS THE NOR GATE ACCEPTS TWO INPUT SIGNALS
IF BOTH ARE 1, THE OUTPUT IS 0; OTHERWISE, THE IF BOTH ARE 0, THE OUTPUT IS 1; OTHERWISE, THE OUTPUT IS 0.
OUTPUT IS 1.

© Kalasalingam academy of research and education


EX-NOR Gate
The EX-NOR gate accepts two input signals

If both are same, the output is 1; otherwise, the output is 0.

© Kalasalingam academy of research and education


Universal gate
NAND gates and NOR gates are sometimes called universal gates because they can be used to produce the
other basic Boolean functions.

© Kalasalingam academy of research and education


Unit 2 Outline & Course in Progress

Lesson 1. Number system


Lesson 2. Logic Gates
Lesson 3. Analog and Digital Signals
Lesson4: Microprocessor and Microcontroller
Lesson5: Microcontroller types - Arduino UNO Architecture
Lesson6: ADC & DAC
Lesson7: PWM
Lesson8: ESP8266 Architecture

© Kalasalingam academy of research and education IOT – SENSORS AND DEVICES


What is an Analog Signal?

A signal which is a continuous function of time and used to


carry the information is known as an analog signal. An analog
signal represents a quantity analogous to another quantity, for
example, in case of an analog audio signal, the instantaneous
value of signal voltage represents the pressure of the sound
wave.

© Kalasalingam academy of research and education COURSE NAME


What is a digital signal?

A signal that is discrete function of time, i.e. which is not a


continuous signal, is known as a digital signal. The digital signals
are represented in the binary form and consist of different values of
voltage at discrete instants of time.

© Kalasalingam academy of research and education COURSE NAME


Unit 2 Outline & Course in Progress

Lesson 1. Number system


Lesson 2. Logic Gates
Lesson 3. Analog and Digital Signals
Lesson4: Microprocessor and Microcontroller
Lesson5: Microcontroller types - Arduino UNO Architecture
Lesson6: ADC & DAC
Lesson7: PWM
Lesson8: ESP8266 Architecture

© Kalasalingam academy of research and education IOT – SENSORS AND DEVICES


Microcontrollers and
Microprocessors

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
Introduction to microcontrollers and microprocessors
What is a Microprocessor?
A microprocessor is a controlling unit of a micro-computer wrapped inside a small chip.
It performs Arithmetic Logical Unit (ALU) operations and communicates with the other devices connected
with it. It is a single Integrated Circuit in which several functions are combined.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
Introduction to microcontrollers and microprocessors
What is Microcontroller?
A microcontroller is a chip optimized to control electronic devices.
It is stored in a single integrated circuit which is dedicated to performing a particular task and execute one
specific application.
It is specially designed circuits for embedded applications and is widely used in automatically controlled
electronic devices. It contains memory, processor, and programmable I/O.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
Introduction to microcontrollers and microprocessors

Microprocessor Microcontroller
Microprocessor is the heart of Computer system. Micro Controller is the heart of an embedded
system.
It is only a processor, so memory and I/O Micro Controller has a processor along with internal
components need to be connected externally memory and I/O components.
Memory and I/O has to be connected externally, so Memory and I/O are already present, and the
the circuit becomes large. internal circuit is small.
You can't use it in compact systems You can use it in compact systems.
Cost of the entire system is high Cost of the entire system is low
Due to external components, the total power As external components are low, total power
consumption is high. Therefore, it is not ideal for the consumption is less. So it can be used with devices
devices running on stored power like batteries. running on stored power like batteries.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
Introduction to microcontrollers and microprocessors

Microprocessor Microcontroller
Most of the microprocessors do not have power Most of the microcontrollers offer power-saving
saving features. mode.
It is mainly used in personal computers. It is used mainly in a washing machine, MP3 players,
and embedded systems.
Microprocessor has a smaller number of registers, so Microcontroller has more register. Hence the
more operations are memory-based. programs are easier to write.

Microprocessors are based on Von Neumann model Micro controllers arc based on Harvard architecture

It is a central processing unit on a single silicon-based It is a by-product of the development of


integrated chip. microprocessors with a CPU along with other
peripherals.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
Introduction to microcontrollers and microprocessors
Microprocessor Microcontroller
It has no RAM, ROM, Input-Output units, timers, and It has a CPU along with RAM, ROM, and other
other peripherals on the chip. peripherals embedded on a single chip.

It uses an external bus to interface to RAM, ROM, and It uses an internal controlling bus.
other peripherals.
Microprocessor-based systems can run at a very high Microcontroller based systems run up to 200MHz or
speed because of the technology involved. more depending on the architecture.

It's used for general purpose applications that allow It's used for application-specific systems.
you to handle loads of data.

It's complex and expensive, with a large number of It's simple and inexpensive with less number of
instructions to process. instructions to process.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
Introduction to microcontrollers and microprocessors
Applications of Microprocessor
Calculators
Accounting system
Games machine
Complex industrial controllers
Traffic light
Control data
Military applications
Defense systems

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
Introduction to microcontrollers and microprocessors
Applications of Microcontroller
Mobile phones
Automobiles
CD/DVD players
Washing machines
Cameras
Security alarms
Keyboard controllers
Microwave oven

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
Unit 2 Outline & Course in Progress

Lesson 1. Number system


Lesson 2. Logic Gates
Lesson 3. Analog and Digital Signals
Lesson4: Microprocessor and Microcontroller
Lesson5: Microcontroller types - Arduino UNO Architecture
Lesson6: ADC & DAC
Lesson7: PWM
Lesson8: ESP8266 Architecture

© Kalasalingam academy of research and education IOT – SENSORS AND DEVICES


Different microcontrollers

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
Different microcontrollers

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 33
Different microcontrollers

How are Microcontrollers Classified

The microcontrollers are characterized regarding bus-width, instruction set, and memory structure.

For the same family, there may be different forms with different sources.

Classification According to Number of Bits:

8-bit microcontroller

16-bit microcontroller

32-bit microcontroller

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
Different microcontrollers

Classification According to Memory Devices:


Embedded memory microcontroller:
When an embedded system has a microcontroller unit that has all the
functional blocks available on a chip is called an embedded
microcontroller. For example, 8051 having program & data memory, I/O
ports, serial communication, counters and timers and interrupts on the
chip is an embedded microcontroller.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
Different microcontrollers

Classification According to Memory Devices:


External Memory Microcontroller:
When an embedded system has a microcontroller unit that
has not all the functional blocks available on a chip is called an
external memory microcontroller.
For example, 8031 has no program memory on the chip is an
external memory microcontroller.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
Different microcontrollers

Classification According to Instruction Set:


CISC:
CISC is a Complex Instruction Set Computer. It
allows the programmer to use one instruction in
place of many simpler instructions.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
Different microcontrollers

Classification According to Instruction Set:


RISC:
The RISC is stands for Reduced Instruction set Computer, this type of instruction sets reduces the design of
microprocessor for industry standards. It allows each instruction to operate on any register or use any
addressing mode and simultaneous access of program and data.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
Different microcontrollers

Classification According to Memory Architecture:

Harvard Architecture:

In Harvard architecture separate storage and signal buses


are provided for different set of instructions and data. This
architecture has the entire data storage within the CPU and
there is no access available for instruction storage as data.

This architecture provides simultaneous access to an


instructions and data stored inside internal buses of
microcontroller.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
Different microcontrollers

Classification According to Memory Architecture:

Von Neumann Architecture:

This architecture of microcontroller was proposed by scientist John


Von Neumann. In this architecture for both instruction and data a
single data path or bus is present.

Therefore, the CPU performs a single operation at a time. It either


performs Read/Write operation on data, or fetches a set of
instruction from memory. Hence instruction fetch and a data transfer
operation cannot occur simultaneously by using a common bus.

COURSE NAME : IOT – SENSORS AND DEVICES


© Kalasalingam academy of research and education
Different microcontrollers

Classification According to the basis of Service Provider:

 AVR: AVR microcontroller is developed by Atmel service provider, AVR architecture is based on the Harvard architecture. It is
based on Reduced Instruction Set Computers(RISC). AVR is not an acronym it is just a name given to the RISC architecture based
microcontroller.

 PIC: PIC microcontroller is also a Harvard architecture-based controller. PIC is an acronym stands for "Peripheral Interface
Controller". This type of microcontroller supports programming in C, Assembly and BASIC C.

 Hitachi: Hitachi microcontroller belongs to H8 family of the controller. H8 is name used in large family of 8-bit, 16-bit and 32-bit
microcontroller developed by Renesas Technology, founded in an early 1990s within Hitachi semiconductors.

 Motorola: Motorola microcontroller is highly integrated microcontroller that is used for high-performance data manipulation
operation. This microcontroller unit uses a System Integration Module (SIM), Time Processing Unit (TPU) and Queued Serial
Module(QSM).

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
Arduino UNO & its Architecture

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
Arduino Boards

Arduino board was designed in the Ivrea Interaction Design Institute intended
for students without a background in electronics and programming concepts.

 This board started altering to adapt to new requirements and challenges,


separating its presence from simple 8-bit boards to products for IoT (Internet of
Things) applications, 3D printing, wearable, and embedded surroundings.

All boards are entirely open-source, allowing users to build them separately
and finally adapt them to their exact needs.

Arduino board has been used for making different engineering projects and
different applications. The Arduino software is very simple to use for beginners,
yet flexible adequate for advanced users. It runs Windows, Linux, and Mac.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICESSSS 43
The Function of the Arduino Board

The flexibility of the Arduino board is enormous so that one can do anything they imagine.

This board can be connected very easily to different modules such as obstacle sensors, presence detectors,
fire sensors, GSM Modules GPS modules, etc.

 The main function of the Arduino board is to control electronics through reading inputs & changing it into
outputs because this board works like a tool.

This board is also used to make different electronics projects in the field of electronics, electrical, robotics,
etc.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 44
Advantages

Arduino also makes simpler the working process of microcontroller, but it gives some advantages over other
systems for teachers, students, and beginners.

Inexpensive

Cross-platform

The simple, clear programming environment

Open source and extensible software

Open source and extensible hardware

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 45
Types : Arduino Uno (R3) – Pin details

Source : https://www.elprocus.com/

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 46
Types : Arduino Uno (R3)

Arduino Uno (R3)

The Uno is a huge option for your initial Arduino.

This Arduino board depends on an ATmega328P based microcontroller.

As compared with other types of Arduino boards, it is very simple to use like the
Arduino Mega type board.

It consists of 14-digital I/O pins, where 6-pins can be used as PWM(pulse width
modulation outputs), 6-analog inputs, a reset button, a power jack, a USB
connection, an In-Circuit Serial Programming header (ICSP), etc.

 It includes everything required to hold up the microcontroller; simply attach it to


a PC with the help of a USB cable and give the supply to get started with an AC-
to-DC adapter or battery.
© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 47
UNO Architecture
 Arduino’s processor basically uses the Harvard architecture where the program code and

program data have separate memory.

 It consists of two memories- Program memory and the data memory.

 The code is stored in the flash program memory, whereas the data is stored in the data

memory.

 The Atmega328 has 32 KB of flash memory for storing code (of which 0.5 KB is used for the

bootloader), 2 KB of SRAM and 1 KB of EEPROM and operates with a clock speed of 16MHz.
© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 48
UNO Architecture

Source : https://www.elprocus.com/
© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 49
UNO Pin details
Pin Category Pin Name Details
Power Vin, 3.3V, 5V, GND Vin: Input voltage to Arduino when using an external power source.
5V: Regulated power supply used to power microcontroller and other
components on the board.
3.3V: 3.3V supply generated by on-board voltage regulator. Maximum
current draw is 50mA.
GND: ground pins.
Reset Reset Resets the microcontroller.
Analog Pins A0 – A5 Used to provide analog input in the range of 0-5V

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 50
UNO Pin details
Pin Category Pin Name Details
Input/Output Digital Pins 0 - 13 Can be used as input or output pins.
Pins
Serial 0(Rx), 1(Tx) Used to receive and transmit TTL serial data.
External 2, 3 To trigger an interrupt.
Interrupts
PWM 3, 5, 6, 9, 11 Provides 8-bit PWM output.
SPI 10 (SS), 11 (MOSI), 12 (MISO) Used for SPI communication.
and 13 (SCK)
Inbuilt LED 13 To turn on the inbuilt LED.
TWI A4 (SDA), A5 (SCA) Used for TWI communication.
AREF AREF To provide reference voltage for input voltage.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 51
UNO Architecture

Source : https://www.elprocus.com/
© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 52
UNO Architecture
 The 14 digital input/output pins can be used as input or output pins by using pinMode(),
digitalRead() and digitalWrite() functions in arduino programming. Each pin operate at 5V and can
provide or receive a maximum of 40mA current, and has an internal pull-up resistor of 20-50 KOhms
which are disconnected by default.
 Out of these 14 pins, some pins have specific functions as listed below:
 Serial Pins 0 (Rx) and 1 (Tx): Rx and Tx pins are used to receive and transmit TTL serial data.
 They are connected with the corresponding ATmega328P USB to TTL serial chip.
 External Interrupt Pins 2 and 3: These pins can be configured to trigger an interrupt on a low value,
a rising or falling edge, or a change in value.
 PWM Pins 3, 5, 6, 9 and 11: These pins provide an 8-bit PWM output by using analogWrite()
function.
© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 53
UNO Architecture
 SPI Pins 10 (SS), 11 (MOSI), 12 (MISO) and 13 (SCK): These pins are used for SPI communication.
 In-built LED Pin 13: This pin is connected with an built-in LED, when pin 13 is HIGH – LED is on and
when pin 13 is LOW, its off.
 Along with 14 Digital pins, there are 6 analog input pins, each of which provide 10 bits of resolution,
i.e. 1024 different values. They measure from 0 to 5 volts but this limit can be increased by using
AREF pin with analog Reference() function.
 Analog pin 4 (SDA) and pin 5 (SCA) also used for TWI communication using Wire library.
 Arduino Uno has a couple of other pins as explained below:
 AREF: Used to provide reference voltage for analog inputs with analogReference() function.
 Reset Pin: Making this pin LOW, resets the microcontroller.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 54
UNO Architecture
The basic working of CPU of ATmega328:-

 The data is uploaded in serial via the port (being uploaded from the computer’s Arduino IDE). The data is
decoded and then the instructions are sent to instruction register and it decodes the instructions on the
same clock pulse.

 On the next clock pulse the next set of instructions are loaded in instruction register.

 In general purpose registers the registers are of 8-bit but there are 3 16-bit registers also.

8-bit registers are used to store data for normal calculations and results.

16-bit registers are used to store data of timer counter in 2 different register. E.g., X-low & X-high.
They are fast and are used to store specific hardware functions.
© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 55
UNO Architecture
The basic working of CPU of ATmega328 (Contd…..):-
 EEPROM stores data permanently even if the power is cut out. Programming inside a EEPROM is slow.
 Interrupt Unit checks whether there is an interrupt for the execution of instruction to be executed in ISR
(Interrupt Service Routine).
 Serial Peripheral Interface (SPI) is an interface bus commonly used to send data between microcontrollers
and small peripherals such as Camera, Display, SD cards, etc. It uses separate clock and data lines, along
with a select line to choose the device you wish to talk to.
 Watchdog timer is used to detect and recover from MCU malfunctioning.
 Analog comparator compares the input values on the positive and negative pin, when the value of positive
pin is higher the output is set.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 56
UNO Architecture
The basic working of CPU of ATmega328 (Contd…..):-
 Status and control is used to control the flow of execution of commands by checking other blocks inside
the CPU at regular intervals.
 ALU (Arithmetic and Logical unit)The high performance AVR ALU operates in direct connection with all
the 32 general purpose working registers. Within a single clock cycle, arithmetic operations b/w general
purpose registers are executed. The ALU operations are divided into 3 main categories – arithmetic,
logical and bit-function.
 I/O pins The digital inputs and outputs (digital I/O) on the Arduino are what allow you to connect the
Arduino sensors, actuators, and other ICs. Learning how to use them will allow you to use the Arduino to
do some useful things, such as reading switch inputs, lighting indicators, and controlling relay outputs.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 57
ADC and DAC

Connecting digital circuitry to sensor devices is simple if the sensor devices are inherently digital themselves.
Switches, relays, and encoders are easily interfaced with gate circuits due to the on/off nature of their
signals.
However, when analog devices are involved, interfacing becomes much more complex.
What is needed is a way to electronically translate analog signals into digital (binary) quantities, and vice
versa.
An analog-to-digital converter, or ADC, performs the former task while a digital-to-analog converter, or DAC,
performs the latter.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 58
Unit 2 Outline & Course in Progress

Lesson 1. Number system


Lesson 2. Logic Gates
Lesson 3. Analog and Digital Signals
Lesson4: Microprocessor and Microcontroller
Lesson5: Microcontroller types - Arduino UNO Architecture
Lesson6: ADC & DAC
Lesson7: PWM
Lesson8: ESP8266 Architecture

© Kalasalingam academy of research and education IOT – SENSORS AND DEVICES


ADC

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
ADC

An ADC inputs an analog electrical signal such as voltage or current and outputs a binary number. In block
diagram form, it can be represented as such:

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 61
ADC

Connecting digital circuitry to sensor devices is simple if the sensor devices are inherently digital
themselves.

 Switches, relays, and encoders are easily interfaced with gate circuits due to the on/off nature of their
signals.

However, when analog devices are involved, interfacing becomes much more complex. What is needed is a
way to electronically translate analog signals into digital (binary) quantities, and vice versa.

An analog-to-digital converter, or ADC, performs the former task while a digital-to-analog converter, or DAC,
performs the latter.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 62
ADC : IC - ADC0808/0809

ADC0808 is a converter that has 8 analog inputs and 8 digital outputs.

ADC0808 allows us to monitor up to 8 different transducers using only a single chip.

 This eliminates the need for external zero and full-scale adjustments.

ADC0808 is a monolithic CMOS device, offers high speed, high accuracy, minimal temperature
dependence, excellent long-term accuracy and repeatability and consumes minimal power.

 These features make this device ideally suited to applications from process and machine control to
consumer and automotive applications.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 63
ADC : IC - ADC0808/0809

Source: https://www.eeeguide.com/
© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 64
ADC : IC - ADC0808/0809
Pin Number Pin Name Description
1 to 5, These 7 pins are the input pins for Analog
Analog Channel 1 to 5 voltage(sensor).
27, 28
This is an input pin which is made high to start
6 START
conversion.
End of Conversion This is an output pin which goes high once the conversion
7
(EOC) is over.
8,14,15,18, Output digital pins which gives the result of the ADC
Output (2-1 to 2-7) conversion.
19,20,21
Must be made high to get output on output pins.
9 OUT EN

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 65
ADC : IC - ADC0808/0809

Pin Number Pin Name Description

10 CLOCK Must be given clock signals (0V-5V) 20Mhz approx.

11 Vcc Powers the IC typically with 5V.

12 V ref(+) Reference voltage pin, typically +5V is used normally.

13 Ground Connect to ground of the circuit.

16 Vref(-) Vref is connected to ground normally.

22 Address Latch Enable(ALE) This pin is should be temporarily made high to select ADC
channel.
23,24,25 ADD A, ADD B, ADD C These three pins are used to select the channel

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 66
ADC : IC - ADC0808/0809 - Usage

ADC0808 Features

1. Easy to interface with all Microprocessors or works Stand alone.


2. Eight channel 8-bit ADC module
3. Can measure up to 8 Analog values seamlessly
4. On chip Clock not available, external Oscillator is needed (Clock)
5. Digital output varies from 0 to 255, Operating power is 15mW, conversion time 100us
6. When Vref = 5V, for every 19.53mV of analog value there will be rise of one bit on digital side
(Step size)
7. Available in 28-pin PDIP, SOIC packages

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 67
ADC : IC - ADC0808/0809 - Usages

 The ADC0808 IC is a commonly used ADC module for projects where an external ADC is required.
It is a 28-pin Eight channel 8-bit ADC module.

 Meaning it can measure up to eight ADC value from 0V to 5V and the precision when voltage
reference (Vref –pin 9) is +5V is 19.53mV (Step size).

 That is for every increase of 19.53mV on input side there will be an increase of 1 bit at the output
side.

 This IC is very Ideal to use with Microprocessors like Raspberry Pi, Beagle bone etc.. Or even to
use as a standalone ADC module.

 Every ADC module requires a clock to function; this IC requires an external clock pulse to work.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 68
DAC

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
DAC

A DAC, on the other hand, inputs a binary number and outputs an analog voltage or current signal. In block
diagram form, it looks like this:

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 70
DAC : IC - DAC0808

DAC0808 is a D/A converter IC and is used for converting 8 bit digital data input to analog signal
output.

 It is a monolithic IC featuring a full scale output current settling time of 150 ns while dissipating
only 33 mW with ±5V supplies.

The chip accuracy of conversion is good and power consumption is also low to make it popular.

The power supply currents of the DAC0808 are independent of bit codes, and exhibits essentially
constant device characteristics over the entire supply voltage range.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 71
DAC : IC - DAC0808

Source: https://www.eeeguide.com/

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 72
DAC : IC - DAC0808 – Pin details
Pin number Pin Name Description
1 NC No connection
2 GND Ground Pin
3 VEE Negative (-ve) power supply
4 IO Input/Output signal pin

5 MSB A1 MSB (Digital i/p bit-1)

6 A2 Digital i/p bit-2


7 A3 Digital i/p bit-3
8 A4 Digital i/p bit-4

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 73
DAC : IC - DAC0808 – Pin details
Pin number Pin Name Description
9 A5 Digital i/p bit-5
10 A6 Digital i/p bit-6
11 A7 Digital i/p bit-7
12 A8 Digital i/p bit-8 (Least Significant Bit)
13 VCC Positive (+ve) power supply

14 VREF+ Positive (+ve) reference voltage

15 VREF- Negative (-ve) reference voltage


16 Compensation (Compensation)-Compensation capacitor pin

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 74
DAC : IC - DAC0808 – Features

Features of IC DAC0808

The features of IC DAC0808 include the following.

 Relative exactness at ±0.19% highest error

 The range of voltage power supply will be ±4.5V to ±18VN.

 Noninverting digital i/ps are compatible with CMOS & TTL.

 The settling time is very fast 150 ns.

 Highest power dissipation will be 1000 mW.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 75
DAC : IC - DAC0808 – Features

Features of IC DAC0808

 The digital data input is 8-bit parallel.

 Input slew rate is high speed 8 mA/μs

 The match of Full-scale current is ±1 LSB.

 Low power utilization is 3 mW at ±5V.

 The range of operating temperature will be 0ºC-to- +75ºC.

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 76
DAC : IC - DAC0808 – Applications

The applications of IC DAC0808 include the following.

 Conversion of Audio

 Electrical measurements

 Analog circuits as well as digital circuits

 And many more hobbyist applications

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 77
ADC and DAC

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
ADC and DAC

Together, they are often used in digital systems to provide complete interface with analog sensors and
output devices for control systems such as those used in automotive engine controls:

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 79
Example of ADC/DAC conversion

In modern life, Analog to Digital Converter (ADC) and Digital to Analog Converter (DAC) are very important
components in electronic equipment.
Take the audio signal processing in Figure as an example, ADC converts the analog signal collected by audio
input equipment, such as a microphone, into a digital signal that can be processed by computer. The
computer may add sound effect such as echo and adjust the tempo and pitch of the music. DAC converts the
processed digital signal back into the analog signal that is used by audio output equipment such as a speaker.

Source: http://www.cmm.gov.mo/

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES 80
Unit 2 Outline & Course in Progress

Lesson 1. Number system


Lesson 2. Logic Gates
Lesson 3. Analog and Digital Signals
Lesson4: Microprocessor and Microcontroller
Lesson5: Microcontroller types - Arduino UNO Architecture
Lesson6: ADC & DAC
Lesson7: PWM
Lesson8: ESP8266 Architecture

© Kalasalingam academy of research and education IOT – SENSORS AND DEVICES


PWM

© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES
What is Pulse Width Modulation ?

Pulse-width modulation (PWM) is a modulation process or technique used in most


communication systems for encoding the amplitude of a signal right into a pulse
width or duration of another signal, usually a carrier signal, for transmission.

 Although PWM is also used in communications, its main purpose is actually to


control the power that is supplied to various types of electrical devices, most
especially to inertial loads such as AC/DC motors.

© Kalasalingam academy of research and education COURSE NAME


PWM Pin

Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means.

Digital control is used to create a square wave, a signal switched between on and off.

This on-off pattern can simulate voltages in between the full VCC of the board (e.g., 5 V on Uno, 3.3 V on a MKR
board) and off (0 Volts) by changing the portion of the time the signal spends on versus the time that the signal
spends off.

The duration of "on time" is called the pulse width. To get varying analog values, you change, or modulate, that
pulse width.

© Kalasalingam academy of research and education IOT – SENSORS AND DEVICES 84


PWM Pin

In the graphic on the right, the green lines represent


a regular time period. This duration or period is the
inverse of the PWM frequency.

In other words, with Arduino's PWM frequency at


about 500Hz, the green lines would measure 2
milliseconds each.

A call to analogWrite() is on a scale of 0 - 255, such


that analogWrite(255) requests a 100% duty cycle
(always on), and analogWrite(127) is a 50% duty cycle
(on half the time) for example.
© Kalasalingam academy of research and education IOT – SENSORS AND DEVICES 85
PWM Pin

The Fading example demonstrates the use of analog output (PWM) to fade an LED. It is available in the File-
>Sketchbook->Examples->Analog menu of the Arduino software.

Once you get this example running, grab your arduino and shake it back and forth.

What you are doing here is essentially mapping time across the space.

To our eyes, the movement blurs each LED blink into a line. As the LED fades in and out, those little lines will
grow and shrink in length.

Now you are seeing the pulse width.

© Kalasalingam academy of research and education IOT – SENSORS AND DEVICES 86


Unit 2 Outline & Course in Progress

Lesson 1. Number system


Lesson 2. Logic Gates
Lesson 3. Analog and Digital Signals
Lesson 4: Microprocessor and Microcontroller
Lesson 5: Microcontroller types - Arduino UNO Architecture
Lesson 6: ADC & DAC
Lesson 7: PWM
Lesson 8: ESP8266 Architecture

© Kalasalingam academy of research and education IOT – SENSORS AND DEVICES


NodeMCU ?

The NodeMCU (Node MicroController Unit) is an open-source software


and hardware development environment built around an inexpensive
System-on-a-Chip (SoC) called the ESP8266.

The ESP8266, designed and manufactured by Espressif Systems,


contains the crucial elements of a computer: CPU, RAM, networking
(WiFi), and even a modern operating system and SDK.

That makes it an excellent choice for Internet of Things (IoT) projects of


all kinds.
© Kalasalingam academy of research and education COURSE NAME
ESP8266 architecture
An ESP8266 is a microcontroller:
Low-power, highly-integrated Wi-Fi solution
A minimum of 7 external components
Wide temperature range: -40°C to +125°C
ESP8285 — 8 Mbit flash embedded

© Kalasalingam academy of research and education COURSE NAME


ESP8266 Pin Configuration
Pin Category Name Description

Micro-USB: NodeMCU can be powered through the


USB port

Micro-USB, 3.3V: Regulated 3.3V can be supplied to this pin to power


Power 3.3V, GND, the board
Vin
GND: Ground pins

Vin: External Power Supply

Control Pins EN, RST The pin and the button resets the microcontroller

© Kalasalingam academy of research and education COURSE NAME


ESP8266 Pin Configuration
Pin Category Name Description

Used to measure analog voltage in the


Analog Pin A0
range of 0-3.3V

GPIO1 to NodeMCU has 16 general purpose input-


GPIO Pins
GPIO16 output pins on its board

SD1, CMD, NodeMCU has four pins available for SPI


SPI Pins
SD0, CLK communication.
NodeMCU has two UART interfaces, UART0
TXD0, RXD0,
UART Pins (RXD0 & TXD0) and UART1 (RXD1 & TXD1).
TXD2, RXD2
UART1 is used to upload the firmware/program.
NodeMCU has I2C functionality support but due
I2C Pins to the internal functionality of these pins, you
have to find which pin is I2C.

© Kalasalingam academy of research and education COURSE NAME


ESP8266 Specifications & Features

 Microcontroller: Tensilica 32-bit RISC CPU Xtensa LX106


 Operating Voltage: 3.3V
 Input Voltage: 7-12V
 Digital I/O Pins (DIO): 16
 Analog Input Pins (ADC): 1
 UARTs: 1
 SPIs: 1
 I2Cs: 1
 Flash Memory: 4 MB
 SRAM: 64 KB
 Clock Speed: 80 MHz
 USB-TTL based on CP2102 is included onboard, Enabling Plug n Play
 PCB Antenna
 Small Sized module to fit smartly inside your IoT projects

© Kalasalingam academy of research and education COURSE NAME


Thank You!

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere,
magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.
© Kalasalingam academy of research and education COURSE NAME : IOT – SENSORS AND DEVICES

You might also like