UPDATED ESIOT NOTES
UPDATED ESIOT NOTES
The unit performs arithmetic and logical operations on 8-bit data as it has ALU, with internal
registers and program counters.
Several logical operations are performed by the ALU according to the program stored in the memory.
The processor of 8051 microcontrollers possesses a special feature by which it can process single bit
or 8-bit data. This simply means that it has the ability to access each single bit data either to clear, set
or move etc. for any logical computation.
1.2.2. Memory: Basically 8051 microcontroller consists of on-chip program memory i.e., ROM and
on-chip data memory i.e., RAM.
Let us first understand
• ROM
8051 microcontroller has 4 KB ROM with 0000H to 0FFFH as the addressable space. It is
completely a program or code memory that means used by the programmer to store the programs that
are to be executed by the microcontroller.
• The operations that are executed by the device in which the microcontroller is present are stored in
the ROM of the memory at the time of fabrication. Hence cannot be changed or modified.
• RAM
8051 holds a 128 bytes RAM. Basically, RAM is used to store data or operands for only a small time
duration. It can be altered anytime according to the need of the user. It is also known as the data
memory as it stores the data temporarily.
1.2.3. Input/ Output port: 8051 consists of 4 parallel ports of 8 bit each thereby providing 32 input-
output pins. All the 4 ports function bidirectional i.e., either input or output according to the software
control.
1.2.4. Timer and Control Unit: Timers are used to create a time gap or delay between 2 events.
8051 microcontroller consists of 2 timers of 16 bit each by which the system can produce two delays
simultaneously in order to generate the appropriate delay.
1.2.5. 8051 Flag Bits and PSW Register
The program status word (PSW) register is an 8-bit register, also known as flag register. It is of 8-bit
wide but only 6-bit of it is used. The two unused bits are user-defined flags.
1.2.6. The Data Pointer (DPTR) is the 8051's only user-accessible 16-bit (2-byte) register. The
Accumulator, R0–R7 registers and B register are 1-byte value registers. DPTR is meant for pointing
to data. It is used by the 8051 to access external memory using the address indicated by DPTR.
P3.0 (RXD) : 10th pin is RXD (serial data receive pin) which is for serial input. Through this
input signal microcontroller receives data for serial communication.
• P3.1 (TXD) : 11th pin is TXD (serial data transmit pin) which is serial output pin. Through this
output signal microcontroller transmits data for serial communication.
• P3.2 and P3.3 (INT0′, INT1′ ) : 12th and 13th pins are for External Hardware Interrupt 0 and
Interrupt 1 respectively. When this interrupt is activated(i.e. when it is low), 8051 gets
interrupted in whatever it is doing and jumps to the vector value of the interrupt (0003H for
INT0 and 0013H for INT1) and starts performing Interrupt Service Routine (ISR) from that
vector location.
• P3.4 and P3.5 (T0 and T1) : 14th and 15th pin are for Timer 0 and Timer 1 external input.
They can be connected with 16 bit timer/counter.
• P3.6 (WR’) : 16th pin is for external memory write i.e. writing data to the external memory.
• P3.7 (RD’) : 17th pin is for external memory read i.e. reading data from external memory.
• Pin 18 and Pin 19 (XTAL2 And XTAL1) – These pins are connected to an external oscillator
which is generally a quartz crystal oscillator. They are used to provide an external clock
frequency of 4MHz to 30MHz.
• Pin 20 (GND) – This pin is connected to the ground. It has to be provided with 0V power
supply. Hence it is connected to the negative terminal of the power supply.
• Pin 21 to Pin 28 (Port 2) – Pin 21 to pin 28 are port 2 pins also referred to as P2.0 to P2.7.
When additional external memory is interfaced with the 8051 microcontroller, pins of port 2 act
as higher-order address bytes. These pins are bidirectional.
• Pin 29 (PSEN) – PSEN stands for Program Store Enable. It is output, active-low pin. This is
used to read external memory. In 8031 based system where external ROM holds the program
code, this pin is connected to the OE pin of the ROM.
• Pin 30 (ALE/ PROG) – ALE stands for Address Latch Enable. It is input, active-high pin.
This pin is used to distinguish between memory chips when multiple memory chips are used. It
is also used to de-multiplex the multiplexed address and data signals available at port 0. During
flash programming i.e. Programming of EPROM, this pin acts as program pulse input (PROG).
• Pin 31 (EA/ VPP) – EA stands for External Access input. It is used to enable/disable external
memory interfacing. In 8051, EA is connected to Vcc as it comes with on-chip ROM to store
programs. For other family members such as 8031 and 8032 in which there is no on- chip ROM,
the EA pin is connected to the GND.
• Pin 32 to Pin 39 (Port 0) – Pin 32 to pin 39 are port 0 pins also referred to as P0.0 to P0.7.
They are bidirectional input/output pins. They don’t have any internal pull-ups. Hence, 10 K?
pull-up registers are used as external pull-ups. Port 0 is also designated as AD0-AD7 because
8051 multiplexes address and data through port 0 to save pins.
• Pin 40 (VCC) – This pin provides power supply voltage i.e. +5 Volts to the circuit.
8051MicrocontrollerArchitecuture
The above instruction and its execution. The opcode 74H is saved at 0202 address. The data 6AH
is saved at 0203 address in the program memory. After reading the opcode 74H, the data at the
next program memory address is transferred to accumulator A (E0H is the address of
accumulator). Since the instruction is of 2-bytes and is executed in one cycle, the program
counter will be incremented by 2 and will point to 0204 of the program memory.
Note − The '#' symbol before 6AH indicates that the operand is a data (8 bit). In the absence of
'#', the hexadecimal number would be taken as an address.
Note − We have not used '#' in direct addressing mode, unlike immediate mode. If we had used
'#', the data value 04H would have been transferred to the accumulator instead of 1FH.
Now, take a look at the following illustration. It shows how the instruction gets executed.
Register Direct Addressing Mode
In this addressing mode, we use the register name directly (as source operand). Let us try to
understand with the help of an example.
MOV A, R4
At a time, the registers can take values from R0 to R7. There are 32 such registers. In order to use 32
registers with just 8 variables to address registers, register banks are used. There are 4 register banks
named from 0 to 3. Each bank comprises of 8 registers named from R0 to R7. named from 0 to 3. Each
bank comprises of 8 registers named from R0 to R7. At a time, a single register bank can be selected.
Selection of a register bank is made possible through a Special Function Register (SFR) named Processor
Status Word (PSW). PSW is an 8-bit SFR where each bit can be programmed as required. Bits are
designated from PSW.0 to PSW.7. PSW.3 and PSW.4 are used to select register banks
Register Indirect Addressing Mode
In this addressing mode, the address of the data is stored in the register as operand. MOV A, @R0
Here the value inside R0 is considered as an address, which holds the data to be transferred to the
accumulator. Example: If R0 has the value 20H, and data 2FH is stored at the address 20H, then the
value 2FH will get transferred to the accumulator after executing this instruction. See the following
illustration.
So the opcode for MOV A, @R0 is E6H. Assuming that the register bank #0 is selected, the R0 of
register bank #0 holds the data 20H. Program control moves to 20H where it locates the data 2FH
and it transfers 2FH to the accumulator. This is a 1-byte instruction and the program counter
increments by 1 and moves to 0203 of the program memory.
Indexed Addressing Mode
We will take two examples to understand the concept of indexed addressing mode. Take a look at the
following instructions −
MOVC A, @A+DPTR
and
MOVC A, @A+PC
where DPTR is the data pointer and PC is the program counter (both are 16-bit registers). Consider
the first example.
MOVC A, @A+DPTR
The source operand is @A+DPTR. It contains the source data from this location. Here we are adding
the contents of DPTR with the current content of the accumulator. This addition will give a new
address which is the address of the source data. The data pointed by this address is then transferred to
the accumulator.
The opcode is 93H. DPTR has the value 01FE, where 01 is located in DPH (higher 8 bits) and FE is
located in DPL (lower 8 bits). Accumulator has the value 02H. Then a 16-bit addition is performed
and 01FE H+02H results in 0200 H. Data at the location 0200H will get transferred to lOM oARcP SD|26885763
the accumulator. The previous value inside the accumulator (02H) will be replaced with the new data
from 0200H. The new data in the accumulator is highlighted in the illustration.
This is a 1-byte instruction with 2 cycles needed for execution and the execution time required for
this instruction is high compared to previous instructions (which were all 1 cycle each).
The other example MOVC A, @A+PC works the same way as the above example. Instead of adding
DPTR with the accumulator, here the data inside the program counter (PC) is added with the
accumulator to obtain the target address.
There are four ports P0, P1, P2 and P3 each use 8 pins, making them 8-bit ports. All the ports
upon RESET are configured as output, ready to be used as output ports. To use any of these ports
as an input port, it must be programmed.
1.4.2. Pin configuration of 8051/8031 microcontroller.
Port 0: Port 0 occupies a total of 8 pins (pins 32-39) .It can be used for input or output. To use the pins of
port 0 as both input and output ports, each pin must be connected externally to a 10K ohm pull-up
resistor. This is due to the fact that P0 is an open drain, unlike P1, P2, and P3.Open drain is a term used
for MOS chips in the same way that open collector is used for TTL chips. With external pull-up resistors
connected upon reset, port 0 is configured as an output port. For example, the following code will
continuously send out to port 0 the alternating values 55H and AAH
MOV A,#55H
BACK: MOV P0,A
ACALL DELAY
CPL A
SJMP BACK
Port 0 as Input : With resistors connected to port 0, in order to make it an input, the port must
be programmed by writing 1 to all the bits. In the following code, port 0 is configured first as an
input port by writing 1’s to it, and then data is received from the port and sent to P1.
Port 1: Port 1 occupies a total of 8 pins (pins 1 through 8). It can be used as input or output. In
contrast to port 0, this port does not need any pull-up resistors since it already has pull-up
resistors internally. Upon reset, Port 1 is configured as an output port. For example, the
following code will continuously send out to port1 the alternating values 55h & AAh
MOV A,#55H ; A = 55 hex
BACK: MOV P1,A ;send it to Port 1 ACALL DELAY ;call delay routine
CPL A ;make A=0
SJMP BACK
Port 1 as input: To make port1 an input port, it must programmed as such by writing 1 to all its
bits. In the following code port1 is configured first as an input port by writing 1’s to it, then data
is received from the port and saved in R7 ,R6 & R5
For example, suppose we have a crystal frequency of 11.0592 MHz then the microcontroller will
provide 1/12th i.e.
Timer clock frequency= (Xtal Osc.frequency)/12 = (11.0592 MHz)/12 = 921.6 KHz period T=
1/(921.6 kHz)=1.085 μS
1.5.2. 8051 Timer
8051 has two timers Timer0 (T0) and Timer1 (T1), both are 16-bit wide. Since 8051 has 8-bit
architecture, each of these is accessed by two separate 8-bit registers as shown in the figure below.
These registers are used to load timer count.
8051 has a Timer Mode Register and Timer Control Register for selecting a mode of operation and
controlling purpose.
Let's see these registers,
M1 M0 Mode Operation
0 0 0(13-bittimermode) 13-bittimer/counter,8-bit ofTHx&5-bit ofTLx
0 1 1(16-bittimermode) 16-bittimer/counter,THxcascadedwithTLx
8-bittimer/counter(auto-reloadmode),TLxreload with
1 0 2(8-bitauto-reloadmode)
the value held by THx each time TLx overflow
Splitthe 16-bittimer into two8-bittimersi.e.THx and
1 1 3(splittimermode)
TLx like two 8-bit timer
1.5.2.2. TCON Register
TCON is an 8-bit control register and contains a timer and interrupt flags.
Bit 7 - TF1: Timer1 Overflow Flag
1 = Timer1 overflow occurred (i.e. Timer1 goes to its max and roll over back to zero).
0 = Timer1 overflow not occurred.
It is cleared through software. In the Timer1 overflow interrupt service routine, this bit will get
cleared automatically while exiting from ISR.
Bit 6 - TR1: Timer1 Run Control Bit
1 = Timer1 start.
0 = Timer1 stop.
It is set and cleared by software.
Bit 5 – TF0: Timer0 Overflow Flag
1 = Timer0 overflow occurred (i.e. Timer0 goes to its max and roll over back to zero).
0 = Timer0 overflow not occurred.
It is cleared through software. In the Timer0 overflow interrupt service routine, this bit will get
cleared automatically while exiting from ISR.
Bit 4 – TR0: Timer0 Run Control Bit
1 = Timer0 start.
0 = Timer0 stop.
It is set and cleared by software.
Bit 3 - IE1: External Interrupt1 Edge Flag
1 = External interrupt1 occurred.
0 = External interrupt1 Processed.
It is set and cleared by hardware. lOM oARcPSD|268 857 63
Bit 2 - IT1: External Interrupt1 Trigger Type Select Bit 1 = Interrupt occurs on falling edge at INT1
pin. 0 = Interrupt occur on a low level at the INT1 pin.
Bit 1 – IE0: External Interrupt0 Edge Flag
1 = External interrupt0 occurred.
0 = External interrupt0 Processed.
It is set and cleared by hardware.
Bit 0 – IT0: External Interrupt0 Trigger Type Select Bit 1 = Interrupt occurs on falling edge at INT0
pin. 0 = Interrupt occur on a low level at INT0 pin.
Let's see the timers modes
1.5.3. 8051 Timer Modes
Timers have their operation modes which are selected in the TMOD register using M0 & M1 bit
combinations.
Mode 0 (13-bit timer mode)
The Mode 0 operation is the 8-bit timer or counter with a 5-bit pre-scaler. So it is a 13-bit
timer/counter. It uses 5 bits of TL0 or TL1 and all of the 8-bits of TH0 or TH1.
lOMoARcPSD| 26885763
• Context Switching
1|Page
lOMoARcPSD| 26885763
MemoryandI/OInterfacing
Several memory chips and I/O devices are connected to a microprocessor. The following figure
shows a schematic diagram to interface memory chips and I/O devices to a microprocessor.
MemoryInterfacing
When we are executing any instruction, the address of memory location or an I/O device is sent
out by the microprocessor. The corresponding memory chip or I/O device is selected by a
decoding circuit.
Memory requires some signals to read from and write to registers and microprocessor transmits
some signals for reading or writing data.
The interfacing process includes matching the memory requirements with the microprocessor
signals. Therefore, the interfacing circuit should be designed in such a way that it matches the
memory signal requirements with the microprocessor's signals.
I/O interfacing
As we know, keyboard and displays are used as communication channel with outside world.
Therefore, it is necessarythat we interface keyboard and displays with the microprocessor. This
is called I/O interfacing. For this type of interfacing, we use latches and buffers for interfacing
the keyboards and displays with the microprocessor.
But the main drawback of this interfacing is that the microprocessor can perform only one
function.
2|Page
lOMoARcPSD| 26885763
Hence, it is clear that the memory is an important part ofthe 8051 Microcontroller Architecture
(for that matter, any Microcontroller). So, it is important for us to understand the 8051
Microcontroller Memory Organization i.e., how memory is organized, how the processor
accesses each memory and how to interface external memory with 8051 Microcontroller.
Before going in to the details of the 8051 Microcontroller Memory Organization, we will firstsee
a little bit about the Computer Architecture and then proceed with memory organization of 8051
Microcontroller.
Types of ComputerArchitecture
Basically, Microprocessors or Microcontrollers are classified based on the two types ofComputer
Architecture: Von Neumann Architecture and Harvard Architecture.
VonNeumannArchitecture
Von Neumann Architecture or Princeton Architecture is a Computer Architecture, where the
Program i.e., the Instructions and the Data are stored in a single memory. Since the Instruction
Memory and the Data Memory are the same, the Processor or CPU cannot access both
Instructions and Data at the same time as they use a single bus. This type of architecture has
severe limitationsto the performance ofthe systemas it creates a bottleneck while accessing the
memory.
3|Page
lOMoARcPSD| 26885763
HarvardArchitecture
Harvard Architecture, in contrast to Von Neumann Architecture, uses separate memory for
Instruction (Program) and Data. Since the Instruction Memory and Data Memory are separate in
a Harvard Architecture, their signal paths i.e., buses are also different and hence, the CPU can
access both Instructions and Data at the same time.
AlmostallMicrocontrollers,including 8051 Microcontroller implement HarvardArchitecture.
4|Page
lOMoARcPSD| 26885763
There is another way to fetch the instructions: ignore the Internal ROM and fetch all the
instructions only from the External p rogramMemory(ExternalROM). Forthis scenario, the EA
Pin must be connected to GND. Inthis case, the memoryaddresses of the externalROM will be
from 0000H to FFFFH.
5|Page
lOMoARcPSD| 26885763
But
almost all modern variants of 8051 Microcontroller have 256B of RAM. In this 256B, the first
128B i.e., memoryaddresses from00H to 7FH is divided in to Working Registers (organized as
Register Banks), Bit – Addressable Area and General Purpose RAM (also known as Scratchpad
area).
In the first 128B of RAM (from 00H to 7FH), the first 32B i.e., memory from addresses 00H to
1FH consists of 32 Working Registers that are organized as four banks with 8 Registers in each
Bank.
The 4 banks are named as Bank0, Bank1, Bank2 and Bank3. Each Bank consists of 8 registers
named as R0 – R7. Each Register can be addressed in two ways: either by name or by address.
To addressthe register byname, first the corresponding Bank must be selected. Inorderto select
the bank, wehaveto usetheRS0andRS1bitsofthe ProgramStatusWord(PSW) Register (RS0 and
RS1 are 3rd and 4th bits in the PSW Register).
When addressing the Register using its address i.e., 12H for example, the corresponding Bank
may or may not be selected. (12H corresponds to R2 in Bank2).
The next 16Bofthe RAM i.e., from20H to 2FH are Bit – Addressable memorylocations. There
aretotally128 bits that canbe addressed individuallyusing 00H to 7FH orthe entire byte can be
addressed as 20H to 2FH.
6|Page
lOMoARcPSD| 26885763
The designer of an 8051 Microcontroller based system is not limited to the internal RAM and
ROMpresent inthe8051Microcontroller. There isaprovisionofconnecting bothexternalRAM and
ROM i.e., Data Memory and Program.
The reason for interfacing external Program Memoryor ROM is that complex programs written
in high – level languages often tend to be larger and occupy more memory.
Another important reasonisthat chips like 8031 or 8032,which doesn’t have anyinternalROM,
have to be interfaced with external ROM.
A maximum of 64KB of Program Memory (ROM) and Data Memory (RAM) each can be
interface with the 8051 Microcontroller.
The following image showsthe block diagramof interfacing 64KB ofExternalRAM and 64KB of
External ROM with the 8051 Microcontroller.
8051Microcontroller is that Port 0 (P0) cannot be used as an IO Port as it will be used for
multiplexed address and data bus (A0 – A7 and D0 – D7). Not always, but Port 2 may be used as
higher byte of the address bus.
7|Page
lOMoARcPSD| 26885763
Embedded C programming plays a key role in performing specific function by the processor. In
day-to-daylife we used manyelectronic devicessuchas mobile phone, washing machine, digital
camera, etc. These all device working is based on microcontroller that are programmed by
embedded C.
o Easytounderstand
o HighReliability
o Portability
o Scalability
EmbeddedSystemProgramming:
Basic Declaration:
8|Page
lOMoARcPSD| 26885763
Function is a collection of statements that is used for performing a specific task and a collection
of one or more functions is called a programming language. Every language is consisting ofbasic
elements and grammatical rules. The C language programming is designed for function
withvariables, character set, datatypes, keywords, expressionand so onare used for writing a C
program.
#include<microcontroller
name.h>BasicEmbeddedCProgrammin
gSteps
Let'sseetheblockdiagramrepresentationofEmbeddedCProgramming Steps:
The microcontroller programming is different for each type of operating system. Even though
there are many operating system are exist such as Windows, Linux, RTOS, etc but RTOS has
several advantage for embedded system development.
9|Page
lOMoARcPSD| 26885763
Embedded C is one of the most popular and most commonly used Programming Languages in
the development of Embedded Systems. So, we will see some of the Basics of Embedded C
Program and the Programming Structure of Embedded C.
What is an EmbeddedSystem?
An Embedded System is a combination of Hardware and Software. My desktop computer also
has hardware and software. Does that mean a desktop computer is also an Embedded System?
NO. A desktop computer is considered a general purpose system as it can do many differenttasks
that too simultaneously. Some common tasks are playing videos, working on office suites,
editing images (or videos), browsing the web, etc.
An example for embedded system, which we use daily, is a Wireless Router. In order to get
wireless internet connectivity on our mobile phones and laptops, we often use routers. The task
of a wireless router is to take the signal from a cable andtransmit it wirelessly. Andtake wireless
data from the device (like a mobile) and send it throughthe cable.
We use washing machines almost daily but wouldn’t get the idea that it is an embedded system
consisting of a Processor (and other hardware as well) and software.
10|Page
lOMoARcPSD| 26885763
ComponentsofEmbeddedSystem
An Embedded System consists of four main components. They are the Processor
(MicroprocessororMicrocontroller), Memory(RAM and ROM), Peripherals (Input and Output)
and Software (main program).
Processor: The heart ofan Embedded System is the Processor. Based on the functionality ofthe
system, the processor can be anything like a General Purpose Processor, a single purpose
processor, an Application Specific Processor, a microcontroller or an FPGA.
Memory:Memoryisanother important partofanembedded system. It isdivided into RAMand
ROM. Memory in an Embedded System (ROM to be specific) stores the main program andRAM
stores the program variables and temporary data.
Peripherals: In order to communicate with the outside world or control the external devices, an
Embedded System must have Input and Output Peripherals. Some of these peripherals include
Input / Output Ports, Communication Interfaces, Timers and Counters, etc.
Software: All the hardware work according to the software (main program) written. Software
partofanEmbedded Systemincludes initializationof the system, controlling inputsand outputs,
error handling etc.
NOTE: Many Embedded Systems, usually small to medium scaled systems, generally consistsof
a Microcontroller as the main processor. With the help of a Microcontroller, the processor,
memory and few peripherals will be integrated in to a single device.
11|Page
lOMoARcPSD| 26885763
The C Programming Language became so popular that it is used in a wide range ofapplications
ranging from Embedded Systems to Super Computers.
The extension in Embedded C from standard C Programming Language include I/O Hardware
Addressing, fixed point arithmetic operations, accessing address spaces, etc.
KeywordsinEmbeddedC
A Keyword isa specialword witha special meaning to the compiler (a CCompiler for example, is
a software that is used to convert programwritten in C to Machine Code). For example, ifwe take
the Keil’s Cx51 Compiler (a popular C Compiler for 8051 based Microcontrollers) the following
are some of the keywords:
• bit
• sbit
• sfr
• small
• large
ThefollowingtablelistsoutallthekeywordsassociatedwiththeCx51CCompiler.
_at_ alien bdata
bit code compact
data far idata
interrupt large pdata
_priority_ reentrant sbit
sfr sfr16 small
_task_ using xdata
12|Page
lOMoARcPSD| 26885763
DataTypesinEmbeddedC
Data Types in C Programming Language (or anyprogramming language for that matter) help us
declaring variables in the program. There are manydata types in C Programming Language like
signed int, unsigned int, signed char, unsigned char, float, double, etc. In addition to these there
few more data types in Embedded C.
.
• bit
• sbit
• sfr
• sfr16
ThefollowingtableshowssomeofthedatatypesinCx51Compileralongwiththeirranges.
DataType Bits(Bytes) Range
bit 1 0or1(bitaddressablepart ofRAM)
signedint 16(2) -32768to+32767
unsignedint 16(2) 0to65535
signedchar 8(1) -128to+127
unsigned 8(1) 0to255
float 32(4) ±1.175494E-38to±3.402823E+38
double 32(4) ±1.175494E-38to±3.402823E+38
sbit 1 0or1(bitaddressablepart ofRAM)
sfr 8(1) RAMAddresses(80hto FFh)
sfr16 16(2) 0to65535
13|Page
lOMoARcPSD| 26885763
DifferentComponentsofanEmbeddedCProgram
Comments: Comments are readable text that are written to help us (the reader) understand the
code easily. They are ignored by the compiler and do not take up any memory in the final code
(after compilation).
There are two ways you can write comments: one is the single line comments denoted by// and
the other is multiline comments denoted by /*….*/.
Global Variables: Global Variables, as the name suggests, are Global to the program i.e., they
can be accessed anywhere in the program.
Local Variables: Local Variables, in contrast to Global Variables, are confined to their
respective function.
Main Function: Every C or Embedded C Program has one main function, from where the
execution of the program begins.
BasicEmbeddedCProgram
Till now, we have seen a few Basics of Embedded C Program like difference between C and
Embedded C, basic structure or template of an Embedded C Program and different components
of the Embedded C Program.
14|Page
lOMoARcPSD| 26885763
ExampleofEmbeddedCProgram
The following images hows the circuit diagram for the example circuit. It containsan8051based
Microcontroller (AT89S52) along with its basic components (like RESET Circuit, Oscillator
Circuit, etc.) and components for blinking LEDs (LEDs and Resistors).
In order to write the Embedded C Program for the above circuit, we will use the Keil C
Compiler. This compiler is a part of the Keil µVision IDE. The program is shown below.
P1=0xFF;//MakingPORT1PinsHIGHi.e.LEDsareON.
delay(1000);
15|Page
lOMoARcPSD| 26885763
/*CallingDelayfunctionwithFunctionparameteras1000.
*Thiswill causeadelayof 1000mSi.e.1second */
P1=0x00;// MakingPORT1PinsLOWi.e.LEDsareOFF.
delay(1000);
}
}
voiddelay(intd)//DelayFunction Definition
{
unsignedinti=0;//LocalVariable.Accessibleonlyinthisfunction.
/*Thisfollowing stepisresponsible forcausingdelay of1000mS
*(orasperthevalue enteredwhilecallingthedelayfunction)*/
for(;d>0;d–)
{
for(i=250;i>0;i–-);
for(i=248;i>0;i–-);
}
}
16|Page
lOMoARcPSD| 26885763
What is anRTOS?
Simply put, an RTOS is a piece of software designed to efficiently manage the time of a central
processing unit (CPU). This is especially relevant for embedded systems when time is critical.
The key difference between an operating system such as Windows and an RTOS often found in
embedded systems is the response time to external events. An ordinary OS provides a non-
deterministic response to events with no guarantee with respect to when they will be processed,
albeit while trying to stay responsive. The user perceiving the OS to be responsive is more
important than handling underlying tasks. On the other hand, an RTOS' goal is fast and more
deterministic reaction.
(RTOS):Components,Types,Examples
Real-time operating system (RTOS) is an operating system intended to serve real time
applicationthat process data as it comes in, mostlywithout buffer delay. The full formof RTOS is
Real time operating system.
In a RTOS, Processing time requirement are calculated in tenths of seconds increments oftime.It
is time-bound system that can be defined as fixed time constraints. In this type of system,
processing must be done inside the specified constraints. Otherwise, the systemwill fail.
17|Page
lOMoARcPSD| 26885763
Job – A job is a small piece of work that can be assigned to a processor and that may or may not require
resources.
Release time of a job – It’s the time at which a job becomes ready for execution.
Execution time of a job – It is the time taken by a job to finish its execution.
Deadline of a job – It’s the time by which a job should finish its execution.
Processors – They are also known as active resources. They are important for the execution of a job.
Maximum (Relative Deadline) – It is the allowable response time of a job, called its relative deadline.
Response time of a job – It is the length of time from the release time of a job until the instant the job
finishes.
Absolute deadline – This is the relative deadline, which also includes the release time.
Components of RTOS
18|Page
lOMoARcPSD| 26885763
The Scheduler: This component of RTOS tells that in which order, the tasks can be executed
which is generally based on the priority.
Function Library: It is an important element of RTOS that acts as an interface that helps youto
connect kernel and application code. This application allows you to send the requests to the
Kernel using a function library so that the application can give the desired results.
Memory Management: this element is needed in the system to allocate memory to every
program, which is the most important element of the RTOS.
RTOS
19|Page
lOMoARcPSD| 26885763
3. FirmReal-timeOperatingSystem:
RTOS of this type have to follow deadlines as well. In spite of its small impact, missing a
deadline can have unintended consequences, including a reduction in the quality of the
product.
Example:Multimediaapplications.
TasksandProcesses
Many (if not most) embedded computing systems do more than one thing that is, the
environment can cause mode changes that in turn cause the embedded system to behave quite
differently. For example, when designing a telephone answering machine,We can define
recording a phone call and operating the user’s control panel as distinct tasks, because they
perform logically distinct operations and they must be performed at very different rates. These
different tasks are part of the system’s functionality, but that application-level organization of
functionality is often reflected in the structure of the program as well.
A process is a single execution of a program. If we run the same programtwo different times,
we have created two different processes.Eachprocesshasitsownstatethat includesnotonlyits
registersbut allofits memory. In some OSs, the memory management unit isused to keep each
process in a separate address space. Inothers, particularlylightweight RTOSs,the processes run
inthe same address space. Processes that share the same address space are oftencalled threads.
As shown in Figure, this device is connected to serial ports on both ends. The input tothe box is
anuncompressed streamofbytes. The boxemits a compressed string ofbits onthe output serial
line,based on a predefined compressiontable.Suchaboxmaybeused,forexample,to compress data
being sent to a modem.
20|Page
lOMoARcPSD| 26885763
The controlpanelofthe compression box may, for example, include a compression mode button
that disables or enables compression, so that the input text is passed through unchanged when
compression is disabled. We certainly do not know when the user will push the compression
mode buttonthe button may be depressed asynchronously relative to the arrival ofcharacters for
compression.
MultirateSystems
Implementing code that satisfiestiming requirements iseven more complexwhen multiple rates
of computation must be handled. Multirate embedded computing systems are very common,
including automobile engines, printers, and cell phones. In all these systems, certain operations
must be executed periodically, and each operation is executed at its own rate.
TimingRequirementsonProcesses
Processes can have several different types of timing requirements imposed on them by the
application. The timing requirements on a set of processes strongly influence the type of
scheduling that is appropriate. A scheduling policy must define the timing requirements that it
uses to determine whether a schedule is valid. Before studying scheduling proper, weoutline the
types of process timing requirements that are useful in embedded system design.
Figure illustrates different ways in which we can define two important requirements on
processes: release time and deadline.
The release time is the time at which the process becomes ready to execute; this is not
necessarily the time at which it actually takes controlofthe CPU and startsto run. An aperiodic
21|Page
lOMoARcPSD| 26885763
process is bydefinition initiated byan event, such as externaldata arriving or data computed by
another process.
The release time is generally measured fromthat event, although the system may want to make
theprocessreadyat some intervalaftertheevent itself. Foraperiodicallyexecutedprocess,there are
two common possibilities.
In simpler systems, the process may become ready at the beginning of the period. More
sophisticated systems, such as those with data dependencies between processes, may set the
release time at the arrival time of certain data, at atime after the start of the period.
A deadline specifies when a computation must be finished. The deadline for an aperiodic
process is generally measured from the release time, since that is the only reasonable time
reference. The deadline for a periodic process may in general occur at some time other than the
end of the period.
Rate requirements are also fairly common. A rate requirement specifies how quickly processes
must be initiated.
The periodofa process is the time between successive executions. For example, the period ofa
digital filter is defined by the time interval between successive input samples.
22|Page
lOMoARcPSD| 26885763
The process’s rate is the inverse ofits period. Ina multirate system, eachprocess executes at its
own distinct rate.
The most common case for periodic processes is for the initiation interval to be equal to the
period. However, pipelined execution of processes allows the initiation interval to be less than
the period. Figureillustrates process execution in a system with four CPUs.
CPU Metrics
We also need some terminology to describe how the process actually executes. The initiation
time isthetimeatwhichaprocessactuallystartsexecutingontheCPU. The completion time is the time
at which the process finishes its work.
The most basic measure of work is the amount of CPU time expended by a process. The CPU
time of process i is called Ci . Notethat the CPU time is not equalto the completion time minus
initiation time; several other processes may interrupt execution. The total CPU time consumedby
a set of processes is
T=∑Ti
We need a basic measure ofthe efficiency with which we use the CPU. The simplest and most
direct measure is utilization:
U=CPUtimeforusefulwork/totalavailableCPUtime
Utilization is the ratio of the CPU time that is being used for useful computations to the total
available CPU time. This ratio ranges between 0 and 1, with 1 meaning that all of the available
CPUtime is beingused forsystempurposes. The utilization isoftenexpressedasapercentage. If we
measure the total execution time of all processes over an interval of time t, then the CPU
utilization is
U=T/t.
23|Page
lOMoARcPSD| 26885763
Utilization is the ratio of the CPU time that is being used for useful computations to the total
available CPUtime. This ratio ranges between 0 and 1, with 1 meaning that all of the available
CPUtime isbeing usedforsystempurposes.Theutilization isoftenexpressedasapercentage. If
24|Page
lOMoARcPSD| 26885763
we measure the total execution time of all processes over an interval of time t, then the CPU
utilization is U/T
Schedulability means whether there exists a schedule of execution for the processes in a system
that satisfies all their timing requirements. In general, we must construct a schedule to show
schedulability, but insome caseswe caneliminate some setsofprocessesasunschedulable using
some very simple tests. Utilization is one of the key metrics in evaluating a scheduling policy.
Our most basic require- ment is that CPU utilization be no more than 100% since wecan’t use the
CPU more than100% of the time.
When we evaluate the utilization of the CPU, we generallydo soover a finite period that covers
all possible combinations of process executions. For periodic processes, the length of time that
must be considered is the hyper period, which is the least-common multiple ofthe periods ofall
the processes. If we evaluate the hyper period, we are sure to have considered all possible
combinations of the periodic processes.
25|Page
lOMoARcPSD| 26885763
ContextSwitch
Context switching in an operating system involves saving the context or state of a running
process so that it can be restored later, and then loading the context or state of another. process
and run it.
Context Switching refers to the process/method used by the system to change the process from
one state to another using the CPUs present in the system to perform its job.
Example – Suppose in the OS there (N) numbers of processes are stored in a Process Control
Block(PCB). like The process isrunning using the CPUto do itsjob. While a processisrunning,
other processes with the highest priorityqueue up to use the CPU to complete their job.
The operating system’s need for context switching is explained by the reasons listed below.
1. One process does not directly switch to another within the system. Context switchingmakes it
easier fortheoperating systemtousethe CPU’sresourcesto carryoutitstasksandstoreits context
while switching between multiple processes.
2. Context switching enables all processes to share a single CPU to finish their execution and
store the status of the system’s tasks. The execution of the process begins at the same place
where there is a conflict when the process is reloaded into the system.
3. Context switching enables all processes to share a single CPU to finish their execution and
store the status of the system’s tasks. The execution of the process begins at the same place
where there is a conflict when the process is reloaded into the system.
4. Context switching only allows a single CPU to handle multiple processes requests parallelly
without the need for any additional processors.
ContextChangesasaTrigger
The three different categories of context-switching triggers areas follows.
1. Interrupts
2. Multitasking
3. User/Kernelswitch
Interrupts: When a CPU requests that data be read from a disc, if any interruptions occur,
context switching automatically switches to a component of the hardware that can handle the
interruptions more quickly.
26|Page
lOMoARcPSD| 26885763
Multitasking: The abilityfor a processto be switched fromthe CPU sothat another processcan
run is known as context switching. When a process is switched, the previous state is retained so
that the process can continue running at the same spot in the system.
Kernel/User Switch: This trigger is used when the OS needed to switch between the user mode
and kernel mode.
When switching between user mode and kernel/user mode is necessary, operating systems use
the kernel/user switch.
ProcessControlBlock
The Process Control block(PCB) is also known as a Task Control Block. it represents a
process in the Operating System. A process control block (PCB) is a data structure used by a
computer to store all information about a process. It is also called the descriptive process. Whena
process is created (started or installed), the operating system creates a process manager.
StateDiagramofContext Switching
27|Page
lOMoARcPSD| 26885763
Preemptive Scheduling
In Preemptive Scheduling, the tasks are mostly assigned with their priorities. Sometimes it is
important to runatask witha higher prioritybefore another lower prioritytask, even ifthe lower
priority task is still running. The lower priority task holds for some time and resumes when the
higher priority task finishes its execution.
Non-PreemptiveScheduling
Inthis type ofscheduling method, the CPU has beenallocated to a specific process. The process
that keeps the CPU busy, will release the CPU either by switching context or terminating. It is
the only method that can be used for various hardware platforms. That’s because it doesn’t need
special hardware (for example, a timer) like preemptive scheduling.
Example of PriorityScheduling
Consider following fiveprocessesP1to P5.Eachprocesshasitsuniquepriority,bursttime,and arrival
time.
28|Page
lOMoARcPSD| 26885763
Step1)Attime=1,nonewprocessarrive.ExecutioncontinueswithP1.
Step2)At time2 ,no new process arrives,so you can continue with P1.P2 is in the waiting queue.
29|Page
lOMoARcPSD| 26885763
Step3)At time3,no new process arrives so you can continue with P1.P2 process still in the
waiting queue.
30|Page
lOMoARcPSD| 26885763
Step7)At time7,no-new process arrives,so we continue with P3.P2 is in the waiting queue.
31|Page
lOMoARcPSD| 26885763
Step11)At time=11,P4 arrives with priority4.P3 has higher priority,so it continues its execution.
Process Priority Bursttime Arrivaltime
P1 1 4 0
P2 2 1outof3pending 0
P3 1 2outof7pending 6
P4 3 4 11
P5 2 2 12
32|Page
lOMoARcPSD| 26885763
Step14)Attime=14,the P2 processhas finished its execution.P4 and P5 are in the waiting state.
P5 has the highest priority and starts execution.
33|Page
lOMoARcPSD| 26885763
Step16) At time=16,P5 is finished with its execution.P4 is the only processleft.Itstarts execution.
Step18)Let’s calculate the average waiting time for the above example.
Waiting Time = start time – arrival time + wait time for next burst
P1=o-o=o
P2=4-o+7=11
P3=6-6=0
P4=16-11=5
Average Waiting time=(0+11+0+5+2)/5=18/5=3.
34|Page
lOMoARcPSD| 26885763
35|Page
UNIT III
IOT AND ARDUINO PROGRAMMING
Introduction to the Concept of IoT Devices – IoT Devices Versus Computers – IoT
Configurations – Basic Components – Introduction to Arduino – Types of Arduino –
Arduino Toolchain – Arduino Programming Structure – Sketches – Pins –Input/Output
From Pins Using Sketches – Introduction to Arduino Shields –Integration of Sensors
and Actuators with Arduino.
WhatIsIot:
IoT stands for Internet of Things. It refers to the interconnectedness of physical
devices, such as appliances and vehicles, that are embedded with software, sensors, and
connectivity which enables these objects to connect and exchange data. This technology
allows for the collection and sharing of data from a vast network of devices, creating
opportunities for more efficient and automated systems.
IoTEnablers:
RFIDs: uses radio waves in order to electronically track the tag attached to each physical
object.
Sensors: devices that are able to detect changes in an environment (ex:motion detectors).
Different types of Sensors:
1. Temperature Sensors
2. Image Sensors
3. Gyro Sensors
4. Obstacle Sensors
5. RF Sensor
6. IR Sensor
7. MQ-02/05GasSensor
8. LDR Sensor
9. Ultrasonic Distance Sensor
Nano technology: as the name suggests, these are extremely small devices with
dimensions usually less than a hundred nanometers.
Smart networks:(ex:meshtopology).
WorkingofIoT
CharacteristicsoftheInternetofThings
The Internet of Things (IoT) is characterized by the following key features that arementioned
below.
1. Connectivity
The extraction of knowledge from the generated data is very important. For example, asensor
generates data, but that data will only be useful if it is interpreted properly. Each IoT device
has a unique identity. This identification is helpful in tracking the equipment and at times for
querying its status.
3. Scalability
The number of elements connected to the IoT zone is increasing day by day. Hence, an IoT
setup should be capable of handling the massive expansion. The data generated as anoutcome
is enormous, and it should be handled appropriately.
1. Architecture
IoT architecture cannot be homogeneous in nature. It should be hybrid, supporting different
manufacturers' products to function in the IoT network. IoT is not owned by any one engineering
branch. IoT is a reality when multiple domains come together.
2. Safety
There is a danger of the sensitive personal details of the users getting compromised when all
his/her devices are connected to the internet. This can cause a loss to the user. Hence, data
security is the major challenge. Besides, the equipment involved is huge. IoT networks may also
be at risk. Therefore, equipment safety is also critical.
3. Self-Configuring
This is one of the most important characteristics of IoT. IoT devices are able to upgrade their
software in accordance with requirements with a minimum of user participation. Additionally,
they can set up the network, allowing for the addition of new devices to an already-existing
network.
4. Interoperability
IoT devices use standardized protocols and technologies to ensure they can communicate with
each other and other systems. Interoperability is one of the key characteristics of the Internet of
Things (IoT). It refers to the ability of different IoT devices and systems to communicate and
exchange data with each other, regardless of the underlying technology or manufacturer.
5. Embedded Sensors and Actuators
Embedded sensors and actuators are critical components of the Internet of Things (IoT). They
allow IoT devices to interact with their environment and collect and transmit data.
6. Autonomous Operation
Autonomous operation refers to the ability of IoT devices and systems to operate independently
and make decisions without human intervention. This is a crucial characteristic of the Internet of
Things (IoT) and enables a wide range of new applications and services.
**Security Measures:**
Implement security mechanisms to protect your IoT ecosystem from unauthorized access,
data breaches, and cyberattacks. This could involve using encryption, secure bootstrapping,
device authentication, and firewalls.
TypesofIoT Applications:
BenefitsofIoT Devices:
Efficiency: IoTdevicescanoptimizeprocesses,reducewaste,andenhanceresource
utilization.
Automation: Taskscanbeautomatedbasedonreal-timedata,leadingtoimproved
productivity.
Data-DrivenInsights: IoTdevicesprovidedatathatcanbeanalyzedtogaininsights,make
informed decisions, and identify trends.
RemoteMonitoringand Control: Devicescanbemonitoredandcontrolledremotely,
enabling real-time adjustments.
EnhancedUserExperience: IoTdevicescreatepersonalizedexperiencesandconvenience for
users.
ChallengesandConsiderations:
BasiccomponentsofIoT:
Devices/Things: These are physical objects embedded with sensors, actuators, and communication
modules that enable them to collect data, perform actions, and communicate over the internet. Devices can
range from simple sensors to complex machinery.
Sensors: Sensors are components that detect changes in the environment and convert physical
phenomena (like temperature, light, pressure, humidity, etc.) into electrical signals that can be processed by
IoT devices.
Actuators: Actuators are devices that perform actions based on the data received from sensors or
commands from remote systems. Examples include motors, servos, solenoids, and relays.
Computing Units: These are the computing units within IoT devices. They process data from sensors,
control actuators, and execute programmed instructions. They also manage communication with other
devices and systems.
Communication Modules: IoT devices need communication capabilities to send and receive data over
the internet. Communication modules can include Wi-Fi, Bluetooth, Zigbee, LoRa, cellular, Ethernet, and
more.
Network Infrastructure: This includes the underlying network that enables devices to connect to the
internet. It can be wired (like Ethernet) or wireless (like Wi-Fi, cellular, or satellite).
Internet Connectivity: The devices need access to the internet to communicate with other devices and
central systems. This connectivity can be through Wi-Fi, cellular networks, satellite connections, or other
means.
Cloud Platforms: Cloud platforms provide storage, computing power, and services that enable data
processing, analysis, storage, and remote control of IoT devices. Cloud services facilitate the scalability and
management of IoT solutions.
Data Processing and Storage: IoT devices generate a vast amount of data. Data processing involves
analyzing and interpreting this data to extract meaningful insights. Data storage involves storing the
collected data for future reference and analysis.
User Interfaces: User interfaces can be web applications, mobile apps, or dashboards that allow users to
monitor and control IoT devices remotely. These interfaces provide real-time information and enable users
to set preferences or receive alerts.
Security: Security is critical in IoT to protect data, devices, and networks from unauthorized access and
cyberattacks. Security measures include encryption, authentication, access controls, and regular software
updates.
Power Management: IoT devices often operate on limited power sources such as batteries. Power
management strategies are essential to optimize energy consumption and extend the device's operational
lifespan.
Data Analysis: Analyzing the data collected from IoT devices can yield valuable insights for making
informed decisions, predicting trends, and improving operations.
Machine Learning and Artificial Intelligence (AI): IoT systems can leverage machine learning and AI
to improve automation, anomaly detection, and decision-making based on real-time data.
ModernApplications:
Smart Grids and energy saving
Smart cities
Smart homes/Home automation
Healthcare
Earthquake detection
Radiation detection/hazardous gas detection
Smartphone detection
Water flow monitoring
Traffic monitoring
Wearables
Smart door lock protection system
Robots and Drones
Healthcare and Hospitals, Telemedicine applications
Security
Biochip Transponders (For animals in farms)
Heart monitoring implants (Example: Pacemaker, ECG real-time tracking)
AdvantagesofIoT:
1. Improved efficiency and automation of tasks.
2. Increased convenience and accessibility of information.
3. Better monitoring and controlof devices and systems.
4. Greater ability together and analyze data.
5. Improved decision-making.
6. Cost savings.
Disadvantages of IoT:
Security concerns and potential for hacking or data breaches.
Privacy issues related to the collection and use of personal data.
Dependence on technology and potential for system failures.
Limited standardization and interoperability among devices.
Complexity and increased maintenance requirements.
High initial investment costs.
Limited battery life on some devices.
Concerns about job displacement due to automation.
Limited regulation and legal framework for IoT, which can lead to confusion and uncertainty.
Overview of IoT Vs Computers:
One big difference between IoT devices and computers is that the main function of IoT
devices is not to compute(not to be a computer) and the main function of a computer is to
compute functions and to run programs. But on IoT devices that is not its main point, it
hassomeotherfunctionbesidesthat.Asanexamplelikeincars,thefunctionofIoTdevicesare not to
compute anti-lock breaking or to do fuel injection, their main function from the point of view of
a user is to be driven and to move you from place to place and the computer is just to help that
function. For example, The main function of the car is not to compute like anti-lock breaking or
to do fuel injection their main function from the point of view of a user isto drive, to move you
from place to place. But when we embed software in it then the software can beable for fuel limit
detection.
Computers
IOT Devices
Arduino is a project, open-source hardware, and software platform used to design and
build electronic devices. It designs and manufactures microcontroller kits and single-board
interfaces for building electronics projects.
The Arduino boards were initially created to help the students with the non-technical
background. The designs of Arduino boards use a varietyof controllers and microprocessors.
The Arduino board consists of sets of analog and digital I/O (Input / Output) pins,
which are further interfaced to breadboard, expansion boards, and othercircuits. Such
boardsfeaturethemodel,UniversalSerialBus(USB),andserialcommunicationinterfaces, which
are used for loading programs from the computers.
Types ofArduino
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 boardis also used
to make different electronics projects in the field of electronics, electrical, robotics, etc.
6 input,
Arduino Uno 16MhzATmega328 2KBSRAM, 32KB flash 14
0 output
12 input,
Arduino Due 84MHz AT91SAM3X8E 96KBSRAM, 512KB flash 54
2 output
16 input,
Arduino Mega 16MHz ATmega2560 8KBSRAM, 256KB flash 54
0 output
12 input,
Arduino Leonardo 16MHz ATmega32u4 2.5KBSRAM, 32KB flash 20
0 output
Arduino Uno(R3)
Arduino Nano
Arduino Micro
ArduinoDue
LilyPadArduinoBoard
Arduino Bluetooth
Arduino Diecimila
RedBoardArduino Board
ArduinoMega(R3) Board
ArduinoLeonardoBoard
Arduino Robot
Arduino Esplora
ArduinoPro Mic
Arduino Ethernet
ArduinoZero
FastestArduino Board
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
verysimpletouseliketheArduinoMegatypeboard..Itconsistsof14-digital I/Opins, 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.
ArduinoUno(R3)
Arduino Uno is the most frequently used board and it is the standard form apart from
all the existing Arduino Boards. This board is very useful for beginners. Please refer to this
link to know more about Arduino Uno Board
Arduino Nano
This is a small board based on the microcontrollers like ATmega328P otherwise
ATmega628 but the connection of this board is the same as to the Arduino UNO board. This
kind of microcontroller board is very small in size, sustainable, flexible, and reliable.
ArduinoNano
As compared with the Arduino Uno board, it is small in size. The devices like mini
USB and Arduino IDE are necessaryto build the projects. This board mainlyincludes analog
pins-8, digital pins-14 with the set of an I/O pin, power pins-6 & RST (reset) pins-2. Please
refer to this link to know more about Arduino Nano Board.
Arduino Micro
The Arduino Micro board mainly depends on the ATmega32U4 based
Microcontroller that includes 20-sets of pins wherethe7-pins are PWM pins, 12-analoginput
pins. This board includes different components like an ICSP header, RST button, small USB
connection, crystal oscillator-16MHz. The USB connection is inbuilt and this board is the
shrunk version of the Leonardo board.
Arduino Micro
Arduino Due
This Arduino board depends on the ARM Cortex-M3 and it is the first Arduino
microcontroller board. This board includes digital I/O pins-54 where 12-pins are PWM o/p
pins, analog pins -12, UARTs-4, a CLK with 84 MHz, an USB OTG, DAC-2, a power jack,
TWI-2, a JTAG header, an SPI header, two buttons for reset & erase.
ArduinoDue
This board works with 3.3V where the highest voltage that the pins of input/outputcan
stand is 3.3V because providing a high voltage to any I/O pin can lead to damage the board
This board is simply connected to a computer through a small USB cable otherwise it can be
powered through an AC to DC adapter. This Arduino Due board is suitable with all shields of
Arduino at 3.3V.
LilyPadArduinoBoards
Arduino Bluetooth
This Bluetooth mainly depends on the microcontroller like ATmega168 and thisboard
is also called Arduino BT. This kind of board includes different components likedigital pins-
16, analog pins-6, crystal oscillator-16MHz, reset button, screw terminals, ICSP header. In
this board, the screw terminals are mainly used for power. The programming ofthis Bluetooth
microcontroller can be done with Bluetooth like a wireless connection.
Arduino Diecimila
The microcontroller board like Arduino Diecimila mainly depends on the
ATmega168. This board includes digital I/O pins -14 where 6-pins can be used like PWM
outputs & analog inputs-6, a USB connection, a crystal oscillator-16 MHz, an ICSP header, a
reset button & a power jack. This board can be connected to a computer through a USB cable
and it can be activated using a battery and an AC-DC adapter.
Arduino Diecimila
As the name suggests, the meaning of Diecimila in Italian is 10,000 which means that
marks the truth that above 10k Arduino boards have been designed. In a set of USB Arduino
boards, it is the latest one as compared with other versions.
RedBoardArduino Boards
Arduino Mega(R3)Board
The Arduino Mega is similar to the UNO‟s big brother. It includes lots of digital I/O
pins (from that, 14-pins can be used as PWM o/ps), 6-analog inputs, a reset button, a power
jack, a USB connection, and a reset button. 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. The huge number of pins make this Arduino
board very helpful for designing projects that need a bunch of digital i/ps or o/ps like lots of
buttons. Please refer to this link to know more about Arduino Mega (R3) Board
ArduinoMega(R3) Board
Arduino Robot
This kind of board is the first Arduino over wheels. This Arduino robot includes two
processors on each of its boards. The two boards are the motor board and control board where
the motor board controls the motors & the control board is used to read the sensors for
operating. Every board is a complete Arduino board and its programming can be done
through the Arduino IDE. These are microcontroller boards that depend on the ATmega32u4.
The pins of this Robot are mapped to actuators and sensors onboard.The process of
programming the robot is the same as the Arduino Leonardo board. It is also named a small
computer and it is extensively used in robotics.
This board includes the speaker, color screen, buttons-5, motors-2, a digital compass,
an SD card reader, potentiometers-2 & floor sensors-5. The library of this robot can be used
for controlling the sensors as well as the actuators.
Arduino Esplora
Arduino Esplora
So connecting the components like actuators or sensors is very simple. Thus,
programming is somewhat different as compared with other types of Arduino boards. This
esplora board includes its own library so that the data from the sensors & actuators are very
easy to read and write.
Arduino ProMic
The Arduino Pro Micro board is the same as the Arduino Mini board apart from the
ATmega32U4 Microcontroller. This pro mic board includes digital I/O pins-12, pulse width
modulation (PWM) pins-5, serial connections of Tx & Rx &10-bit ADC.
Arduino Ethernet
The Arduino Ethernet board depends on the microcontroller like ATmega328. This
kind of microcontroller board includes analog pins-5, digital I/O pins-14, RST button, an
RJ45 connection, crystal oscillator, a power jack, ICSP header, etc. The connection of the
Arduino board can be done through the Ethernet shield to the internet.
Arduino Zero
This is a powerful as well as simple 32-bit board and it provides the best platform for
innovative projects like wearable technology, smart IoT devices, crazy robotics, high-tech
automation, etc. This board expands by providing improved performance, permitting a range
of project opportunities & performs like a great educational tool.
ArduinoZero
Thisboardincludesanaloginputpins-6,digitalI/Opins-14,apowerjack,AREF button,
UART port pins, a USB connector & an In-Circuit Serial Programming (ICSP) header, a
power header, etc.
RAM– 1 Mbyte
DMAcontrollers-4
Communication peripherals-Upto 35
16-bitMaxResolutionwith3×ADCs
D/Aconverterswith2× 12-bit
Hardware with JPEG Codec
Timers-22&Watchdogs– 200Mhz
HW Calendar &RTC with Sub-second Accuracy
Cryptographic Acceleration
Toolchain(IDE)
A toolchain is a set of programming tools that is used to perform a complex set of
operations. In the Arduino Software (IDE), the toolchain is hidden from the user, but it is
used to compile and upload the user Sketch. It includes a compiler, assembler, linker, and
Standard C & math libraries.The source code for the Java environment is released under the
GPL and the C/C++ microcontroller libraries are under the LGPL.
StructureofSketch
A sketch can be divided into two parts:
Setup()
Loop()
Thefunctionsetup()isthepointwherethecodestarts,justlikethemain()functionin C and
C++
I/OVariables, pinmodes are initializedintheSetup() function
Loop()function, as the namesuggests, iterates the specified task in the program
Structure
Arduino programs can be divided in three main parts: Structure, Values (variables
and constants), and Functions. In this tutorial, we will learn about the Arduino software
program, step by step, and how we can write the program without any syntax or compilation
error.
Let us start with the structure. Software structure consists of two main functions. −
Setup( ) function - The setup() function is called when a sketch starts. Use it to
initializethe variables (not declaration),pin modes, start using libraries, etc. Thesetup
function will only run once, after each power up or reset of the Arduino board.
Loop( ) function - After creating a setup() function, which initializes and sets theinitial
values, the loop() function does precisely what its name suggests, and loops
consecutively, allowing your program to change and respond. Use it to activelycontrol
the Arduino board
Voidsetup ( ){
}
PURPOSE− Thesetup()function is called when a sketch starts. Use it to initializethe
variables, pin modes, start using libraries, etc. The setup function will only run once,
after each power up or reset of the Arduino board.
INPUT −-
OUTPUT−-
RETURN−-
VoidLoop( ){
}
PURPOSE− After creating asetup()function, which initializes and sets the initial
values, theloop()function does precisely what its name suggests, and loops
consecutively, allowing your program to change and respond. Use it to activelycontrol
the Arduino board.
INPUT −-
OUTPUT−-
RETURN−-
ArduinoUnoPinsDiagram
ARDUINOI/O(Input,Output)Functions
1. Pin Mode()-The pin Mode()function is used to configure a specific pin to behave either
as an input or an output.
2. digitalWrite()-
ThedigitalWrite()functionisusedtowriteaHIGHoraLOWvaluetoadigitalpin.
3. digitalRead()-Readsthevaluefromaspecifieddigitalpin,eitherHIGHorLOW.
4. analogRead( ) function- we can read the voltage applied to one of the pins. This
functionreturnsanumberbetween0and1023,whichrepresentsvoltagesbetween0 and 5 volts.
5. analogWrite()function-Writesananalogvaluetoapin.
Input/Ouput(I/O)inArduino
Setsapintoactaseitheraninputoranoutput
pinisthenumberofthepin
1-13forthedigitalpins
A0-A5fortheanaloginputpins
ModeistheI/Omodethepinissetto
INPUT,OUTPUT
DigitalInput
val;
Pin val=digitalRead(3);
pinvalissettothestateofdigitalpin3
Digital Output
Assigns thestateofanoutputpin
AssignseitherLOW(0volts)orHIGH(5volts)
digitalWrite(3, HIGH);
Digitalpin3issetHIGH(5volts)
Analog Input
pin val;
Pin val=analogRead(A3);
ARDUINO SHIELDS
TypesofShields
Ethernet shield
XBee shield
Proto shield
Relay shield
Motor shield
LCD shield
Bluetooth shield
Capacitive Touchpad shield
The Ethernet shields are used to connect the Arduino board to the Internet. We need to mount the
shield on the top of the specified Arduino board.
The USB port will play the usual role to upload sketches on the board.
The latest version of Ethernet shields consists of a micro SD card slot. The micro SD card slot can
be interfaced with the help of the SD card library.
Xbee Shield
o WecancommunicatewirelesslywiththeArduinoboardbyusingtheXbeeShield with
Zigbee.
o Itreducesthehassleofthecable,whichmakesXbeeawirelesscommunication model.
o TheXbeewirelessmoduleallowsustocommunicateoutdoorupto300feetand indoor upto
100 feet.
o TheXbeeshield is shown below:
Proto shield
Relay shield
The Arduino digital I/O pins cannot bear the high current due to its voltage and current limits. The
relay shield is used to overcome such situations. It provides a solution for controlling the devices
carrying high current and voltage.
The shield consists of four relays and four LED indicators.
It also provides NO/NC interfaces and a shield form factor for simple connection to the Arduino
board.
The LED indicators depict the ON/OFF condition of each relay.
The relay used in the structure is of high quality.
The NO (Normally Open), NC (Normally Closed), and COM pins are present on each relay.
Motor shield
The motor shield helps us to control the motor using the Arduino board.
It controls the direction and working speed of the motor. We can power the motor shield either by
the external power supply through the input terminal or directly by the Arduino.We can also
measure the absorption current of each motor with the help of the motor shield.
o The motor shield is based on the L298 chip that can drive a step motor or two DC
motors. L298 chip is a full bridge IC. It also consists of the heat sinker, which
increases the performance of the motor shield.
o It can drive inductive loads, such as solenoids, etc.
o Theoperatingvoltageisfrom5Vto12V.
LCDshield
The keypad of the LCD (Liquid Crystal Display) shield includes five buttons called up, down, left,
right, and select.
There are 6 push buttons present on the shield that can be used as a custom menu control panel.
It consists of the 1602 white characters, which are displayed on the blue backlight LCD.
The LED present on the board indicates the power ON.
The five keys present on the board help us to make selections on menus and from the board to our
project.
o The LCD shield is popularly designed for the classic boards such as Duemilanove,
UNO, etc.
Bluetooth shield
o The Bluetooth shield can be used as a wireless module for transparent serial
communication.
o It includes a serial Bluetooth module. D0 and D1 are the serial hardware ports in the
Bluetooth shield, which can be used to communicate with the two serial ports (from
D0 to D7) of the Arduino board.
o We can install Groves through the two serial ports of the Bluetooth shield called a
Grove connector. One Grove connector is digital, while the other is analog.
The communication distance of the Bluetooth shield is up to 10 m at home without any obstacle in
between.
It has a touchpad interface that allows integration of the Arduino board with the touch shield.
The Capacitive touchpad shield consists of 12 sensitive touch buttons, which include 3 electrode
connections and 9 capacitive touch pads.
Selecting the appropriate sensors and actuators: Identify the specific sensors and
actuators you need for your project. Arduino supports a wide range of sensors such as
temperature sensors, motion sensors, light sensors, and actuators such as motors, servos, and
LEDs.
Wiring connections: Connect the sensors and actuators to the Arduino board using
jumper wires or appropriate connectors. Arduino boards typically have digital input/output
(I/O) pins, analog input pins, and power pins that you can use for wiring.
For digital sensors and actuators, you can connect them to the digital I/O pins. These
pins can be configured as either input or output. Analog sensors can be connected to the
analog input pins, which can read continuous voltage values.
Power and ground connections should be made to provide appropriate voltage and
common reference for the sensors and actuators.
Code development: Write the Arduino code to read sensor data and control the
actuators. The code should include appropriate functions and commands to initialize the
sensors, read their values, and control the actuators based on the sensor inputs. The specific
code will depend on the sensors and actuators you are using, so refer to their respective
documentation and examples.
Uploading and testing: Upload the code to the Arduino board and test the integration.
Use the Serial Monitor in the Arduino IDE to view sensor readings or debug any issues.Make
sure the sensors and actuators are functioning as expected.
By following these steps, you can integrate sensors and actuators with Arduino to
create interactive projects and prototypes. The possibilities are vast, ranging from simple
projects like temperature monitoring and LED control to complex robotics and automation
systems.
UNIT- 4 IOT COMMUNICATION AND OPEN PLATFORMS
IoT devices are found everywhere and will enable circulatory intelligence in the future. For
operational perception, it is important and useful to understand how various IoT devices
communicate with each other. Communication models used in IoT have great value. The
IoTs allow people and things to be connected any time, any space, with anything and
anyone, using any network and any service.
Publishers are the source of data. It sends the data to the topic which are
managed by the broker. They are not aware of consumers.
Consumers subscribe to the topics which are managed by the broker.
Hence, Brokers responsibility is to accept data from publishers and send it to the
appropriate consumers. The broker only has the information regarding the
consumer to which a particular topic belongs to which the publisher is unaware
of.
3. Push-Pull Model
The push-pull model constitutes data publishers, data consumers, and data queues.
4. Exclusive Pair
Simplicity: REST APIs are relatively simple to design and implement, making them a
popular choice for building APIs for web applications.
Flexibility: REST APIs can be used to support a wide range of applications and
services, from simple web applications to complex enterprise systems.
Caching: REST APIs can leverage caching to improve performance and reduce server
load.
Stateless: REST APIs are stateless, meaning that each request is processed
independently of any previous requests, making them easy to scale and distribute.
Web Socket APIs allow bi-directional, full-duplex communication between clients and
servers. It follows the exclusive pair communication model. This Communication API does
not require a new connection to be set up for each message to be sent between client s and
servers. Once the connection is set up the messages can be sent and received continuously
without any interruption. WebSocket APIs are suitable for IoT Applications with low
latency or high throughput requirements.
Advantages of WebSocket API:
Complexity: WebSocket APIs are more complex to design and implement than REST
APIs, requiring additional programming skills and knowledge.
Security: WebSocket APIs can be vulnerable to security threats if not properly secured.
Compatibility: WebSocket APIs are not supported by all browsers, requiring fallback
mechanisms for older browsers.
Both REST API and WebSocket API are used to build APIs for web applications.
Both REST API and WebSocket API are standardized interfaces that enable
communication between the server and client.
Both REST API and WebSocket API can be customized to suit the specific needs of a
particular application or system.
Both REST API and WebSocket API can be secured using various authentication and
encryption methods.
Difference between Rest API and Web Socket API :
It is Stateless protocol. It will not store It is Stateful protocol. It will store the
1.
the data. data.
It depends upon the HTTP methods to It depends upon the IP address and
7.
retrieve the data.. port number to retrieve the data
It is slower than web socket regarding web socket transmits messages very
8.
the transmission of messages. fastly than REST API.
Message Queuing Telemetry Transport (MQTT): The message query telemetry transport
protocol is a communication-based protocol that is used for IoT devices. This protocol is
based on the publish-subscribe methodology in which clients receive the information
through a broker only to the subscribed topic. A broker is a mediator who categorizes
messages into labels before being delivered.
Light-weight and reliable: The MQTT message is compact, which can realize stable
transmission on severely limited hardware equipment and network with low bandwidth
and high delay.
Created for the IoT: It provides comprehensive IoT application features such as
heartbeat mechanism, testament message, QoS quality level
Better ecosystem: It covers all-language platform's clients and SDKs, and it has mature
Broker server software, which can support massive Topic and ten-million-level device
access and provide rich enterprise integration capabilities.
CoAP
Constrained Application Protocol (COAP): The constrained application protocol is a
client server-based protocol. With this protocol, the COAP packet can be shared between
different client nodes which are commanded by the COAP server. The server is responsible
to share the information depending on its logic but has not acknowledged it. This is used
with the applications which support the state transfer model.
It supports IP multicast
It supports observation mode
It supports asynchronous communication
LoRaWAN
LoRaWAN refers to Long Rage Wide Area Network which is a wide area network
protocol. It is an optimized low-power consumption protocol design to support large-scale
public networks with millions of low-power devices. A single operator operates the
LoRaWAN. The LoRaWAN network is a bi-directional communication for IoT application
with low cost, mobility, and security..
Over-the-air Activation (OTAA): A device has to establish a network key and an application
session key to connect with the network.
Activation by Personalization (ABP): A device is hardcoded with keys needed to communicate
with the network, making for a less secure but easier connection.
o Standard: LoRaWAN
o Frequency: Various
o Range: 2-5km (urban environment), 15km (suburban environment)
o Data Rates: 0.3-50 kbps.
6LoWPAN
The 6LoWPAN protocol refers to IPv6 Low Power Personal Area Network which uses a
lightweight IP-based communication to travel over low data rate networks. It has limited
processing ability to transfer information wirelessly using an internet protocol. So, it is
mainly used for home and building automation. The 6LoWPAN protocol operates only
within the 2.4 GHz frequency range with 250 kbps transfer rate. It has a maximum length of
128-bit header packets.
Security is a major issue for 6LowPAN communication Protocol. There are several attacks
issues at the security level of 6LoWPAN which aim is to direct destruction of the network.
Since it is the combination of two systems, so, there is a possibility of attack from two sides
that targets all the layer of the 6LoWPAN stack (Physical layer, Data link layer, Adaptation
layer, Network layer, Transport layer, Application layer).
1. The device should be having sleep mode in order to support the battery saving.
2. Minimal memory requirement.
3. Routing overhead should be lowered.
Features of 6LoWPAN:
Advantages of 6LoWPAN:
1. 6LoWPAN is a mesh network that is robust, scalable, and can heal on its own.
2. It delivers low-cost and secure communication in IoT devices.
3. It uses IPv6 protocol and so it can be directly routed to cloud platforms.
4. It offers one-to-many and many-to-one routing.
5. In the network, leaf nodes can be in sleep mode for a longer duration of time.
Disadvantages of 6LoWPAN:
Applications of 6LoWPAN:
Communication
It uses Request-Response model. It uses Publish-Subscribe model
Type
Transport layer This mainly uses User Datagram This mainly uses Transmission
protocol protocol(UDP) Control protocol(TCP)
Basis of COAP MQTT
Effectiveness in LNN is
Effectiveness in LNN is low.
Effectiveness excellent.
Bluetooth
Bluetooth Architecture:
Piconet:
Piconet is a type of Bluetooth network that contains one primary node called the
master node and seven active secondary nodes called slave nodes. Thus, we can say
that there is a total of 8 active nodes which are present at a distance of 10 meters.
The communication between the primary and secondary nodes can be one-to-one or
one-to-many. Possible communication is only between the master and slave; Slave-
slave communication is not possible. It also has 255 parked nodes, these are
secondary nodes and cannot take participation in communication unless it gets
converted to the active state.
Scatternet:
It is formed by using various piconets. A slave that is present in one piconet can act as
master or we can say primary in another piconet. This kind of node can receive a message
from a master in one piconet and deliver the message to its slave in the other piconet where
it is acting as a master. This type of node is referred to as a bridge node. A station cannot be
mastered in two piconets.
Advantage:
Disadvantages:
Applications:
We are all familiar with Wi-Fi, which is available on our mobile phones, laptops, or wherever
Wi-Fi is supported. Wi-Fi is a wireless networking technology that permits to connect
wirelessly to a network or to other computer or mobile device. A circular radio frequency
range is used to transmit data in Wi-Fi.
Wireless Fidelity (Wi-Fi) is a generic term for the wireless network in the communication
norm. Wifi operates like a local area network without the use of a wire or cables.
WLAN stands for Wireless Local Area Network. IEEE 802.11 is the rule for
communication. WiFi uses the Physical Data Link Layer (PDLL) to operate.
As mentioned earlier, Wi-Fi has numerous kinds or standards. Here, the names of the
standards are defined.
o Wi-Fi-1 (802.11b, launched in 1999) - This version has link speed from 2Mb/s to 11
Mb/s over 2.4 GHz frequency band
o Wi-Fi-2 (802.11a) launched in 1999. After a month of releasing the previous
version, 802.11a, was released, and it provides upto 54 Mb/s link speed over the 5
GHz band
o Wi-Fi-3 (802.11g) was launched in 2003. In this version, the speed was risen up to
54 to 108 Mb/s over 2.4 GHz
o 802.11i launched in 2004. This is equivalentto802.11g, but only the security feature
was enhanced in this version
o 802.11e launched in 2004. This is also the same as 802.11g; only Voice over
Wireless LAN and multimedia streaming are included.
o Wi-Fi-4 (802.11n) launched in 2009. This version holds up both 2.4 GHz and 5 GHz
radio frequencies, and it provides up to 72 to 600 Mb/s speed.
o Wi-Fi-5 (802.11ac) launched in 2014. It supports a speed of 1733 Mb/s in the 5 GHz
band.
Advantages of WIFI
Wi-Fi Disadvantages
o Mobile phones, laptops, and other devices with batteries consume a lot of power when
using Wi-Fi.
o Even when encryption is in place, security issues can still arise.
o Wi-Fi can be attacked and accessed in the same way that recognised devices become
unidentified to the router.
o In comparison to a direct cable connection, the speed is slower.
o People can be harmed by it because it emits radiation like cell phones.
o Thunderstorms, for example, can interfere with Wi-Fi signals.
o Because it lacks a firewall, unauthorised access to Wi-Fi is possible.
o Since a router is required to access the internet via Wi-Fi, we can't access the internet
if the power goes out.
Zigbee
What is Zigbee? – Zigbee is a low power, low data rate (250kbps) wireless protocol used
primarily for Home automation and industrial control, building automation,sensor data
collection etc
Full Function Device (FFD)- Can communicates with all node types and can
operate in one of three modes:
Operating Frequency
Features of Zigbee:
Disadvantages of Zigbee :
1. Limited range: Zigbee has a relatively short range compared to other wireless
communications protocols, which can make it less suitable for certain types of
applications or for use in large buildings.
2. Limited data rate: Zigbee is designed for low-data-rate applications, which can make
it less suitable for applications that require high-speed data transfer.
3. Interoperability: Zigbee is not as widely adopted as other IoT protocols, which can
make it difficult to find devices that are compatible with each other.
4. Security: Zigbee’s security features are not as robust as other IoT protocols, making it
more vulnerable to hacking and other security threats.
Zigbee Applications:
1. Home Automation
2. Medical Data Collection
3. Industrial Control Systems
4. meter reading system
5. light control system
6. Commercial
7. Government Markets Worldwide
8. Home Networking
GPS
Global Positioning System (GPS) is a navigation system based on satellite. It has created the
revolution in navigation and position location. It is mainly used in positioning, navigation,
monitoring and surveying applications.
Usage of GPS:
There are five most uses of the GPS.
Location:- with the help of GPS we can find the exact position of the object.
Navigation:– we can navigate one location to another with the help of GPS.GPS
technology is also useful for Transportation Management and breathing of Ship at
docks.
Tracking: -with the help of GPS we can Monitor object movement like speed, distance,
position.
Mapping:– GPS also helps in creating maps of the World.
Timing:- GPS also provides the estimated time for reaching destination measurement
its depend on speed and object movement.
GSM
GSM stands for Global System for Mobile Communication. GSM is an open and digital
cellular technology used for mobile communication. It uses 4 different frequency bands of
850 MHz, 900 MHz, 1800 MHz and 1900 MHz . It uses the combination of FDMA and
TDMA.
GSM is having 4 different sizes of cells are used in GSM :
1. BSS : BSS stands for Base Station Subsystem. BSS handles traffic and signaling
between a mobile phone and the network switching subsystem. BSS having two
components BTS and BSC.
2. NSS : NSS stands for Network and Switching Subsystem. NSS is the core network of
GSM. That carried out call and mobility management functions for mobile phone
present in network. NSS have different components like VLR, HLR and EIR.
3. OSS : OSS stands for Operating Subsystem. OSS is a functional entity which the
network operator monitor and control the system. OMC is the part of OSS. Purpose of
OSS is to offer the customer cost-effective support for all GSM related maintenance
services.
Suppose there are 3 Mobile stations which are connected with the tower and that tower is
connected to BTS through TRX, then further connected to BSC and MSC. Let’s understand
the functionality of different components.
1. MS : MS stands for Mobile System. MS comprises user equipment and software needed
for communication with a mobile network. Mobile Station (MS) = Mobile
Equipment(ME) + Subscriber Identity Module (SIM). Now, these mobile stations are
connected to tower and that tower connected with BTS through TRX. TRX is a transceiver
which comprises transmitter and receiver. Transceiver has two performance of sending and
receiving.
2. BTS : BTS stands for Base Transceiver Station which facilitates wireless communication
between user equipment and a network. Every tower has BTS.
3. BSC : BSC stands for Base Station Controller. BSC has multiple BTS. You can consider
the BSC as a local exchange of your area which has multiple towers and multiple towers
have BTS.
4. MSC : MSC stands for Mobile Switching Center. MSC is associated with
communication switching functions such as call setup, call release and routing. Call tracing,
call forwarding all functions are performed at the MSC level.
Services of GSM:
Advantages:
Compatibility: GSM is widely used around the world, so it is compatible with many
different networks and devices.
Security: GSM offers enhanced security features such as authentication, encryption and
confidentiality, which helps to protect the user’s privacy and data.
Efficient use of bandwidth: GSM uses a time-division multiplexing (TDM) technique
which enables many users to share the same frequency channel at different times, making it
an efficient use of the available bandwidth.
Roaming: GSM allows users to roam internationally and use their mobile phones in other
countries that use the same GSM standard.
Wide range of features: GSM supports a wide range of features, including call
forwarding, call waiting, voicemail, conference calling, and more.
Disadvantages:
Limited coverage: GSM networks may have limited coverage in some remote areas, which
can make it difficult for users to make calls or access the internet.
Network congestion: GSM networks may become congested during peak hours, which can
lead to dropped calls or poor call quality.
Security vulnerabilities: Although GSM offers enhanced security features, it is still
vulnerable to certain types of attacks, such as eavesdropping and spoofing.
Data transfer speed: GSM networks offer relatively slow data transfer speeds compared to
newer technologies such as 3G and 4G.
Limited capacity: GSM networks have a limited capacity for handling large volumes of
data, which can be a disadvantage for users who require high-speed internet access or other
data-intensive applications.
Single Board Computers -Raspberry-Pi
Raspberry Pi is launched in 2012 and there have been several iterations and variations
released since then.
Various versions of Raspberry Pi have been out till date. All versions consist of a
Broadcom system on a chip (SoC) with an integrated ARM-compatible CPU and on-chip
graphics processing unit (GPU).
Use for explore computing as for programmings like Scratch and Python
languages.
Structure of board
The latest version of Raspberry Pi (model B, revision 2) comes with a 700 MHz low-
power ARM 1176JZ-F processor And a 512 MB SD Ram.
USB ports
Two USB 2.0 USB ports on Raspberry pi can provide a current of up to 100 mA.
For connecting devices that draw a current of more than 100 mA, an external USB-
powered hub is required.
Ethernet port
Standard RJ45 Ethernet port.
The HDMI port on Raspberry Pi provides both video and audio output.
For monitors that have a DVI port but no HDMI port so use an HDMI to DVI adaptor
or cable.
Audio output
3.5 mm audio output jack is used for audio output to old television along with the
RCA Jack for video.
The audio quality is inferior to the HDMI output.
Status LEDs
Raspberry Pi has 5 status LED is which are:-
SD card slot
Not have a built-in operating system and storage so plug in an SD card
loaded with a Linux image to an SD card slot.
Required at least an 8GB SD card for the setting up NOOBS software
(new out-of-the-box software)
Power input
A micro-USB connector for power input.
GPIO Pin
A number of general-purpose Input / Output pins are used by Raspberry Pi.
There are four types of pins on Raspberry Pi:- True GPIO pins, SPI interface
pins, 12C interface pins, and Serial RX and TX pins.
Voltages
From the above diagram, we can see that there are two 5V pins and two 3V3 pins on the
board. It also has several ground pins (0V). All these pins are unconfigurable.
Outputs
A GPIO pin can be designated as an output pin. The pin set as output pin can be set
to 3V(high) or 0V(low).
Inputs
A GPIO pin can be designated as an input pin. The pin set as input pin can be read as
3V(high) or 0V(low). You can use internal pull-up or pull-down resistors.
above diagram, GPIO2 and GPIO3 pins have fixed pull-up resistors but for the other pins,
you can configure it in software.
Alternative Functions
GPIO pins can be used with a variety of alternative functions. Among them, some are
available on all pins and others on specific pins.
Software PWM are available on all the pins whereas Hardware PWM are available on
GPIO12, GPIO13, GPIO18, and GPIO19.
SPI0: MOSI (GPIO10); MISO (GPIO9); SCLK (GPIO11); CE0 (GPIO8), CE1 (GPIO7)
SPI1: MOSI (GPIO20); MISO (GPIO19); SCLK (GPIO21); CE0 (GPIO18); CE1 (GPIO17);
CE2 (GPIO16)
Serial
TX(GPIO14)
RX(GPIO15)
Raspberry pi Connecting to the Cloud
Connecting a Raspberry Pi to the cloud allows you to access and manage your Raspberry Pi
remotely, exchange data with cloud services, and perform various tasks such as data logging,
remote control, and automation. Here's a general overview of how to connect a Raspberry Pi
to the cloud:
1. Select a Cloud Service Provider: Choose a cloud service provider that fits your needs.
Some popular options include AWS (Amazon Web Services), Microsoft Azure, Google
Cloud Platform, and various IoT-focused platforms like AWS IoT, Azure IoT, or Google
Cloud IoT. Each has its own set of features, pricing, and capabilities.
2. Set Up Your Raspberry Pi: Ensure your Raspberry Pi is set up correctly, connected to the
internet, and running an appropriate operating system like Raspbian (now called Raspberry Pi
OS).
3. Install Necessary Software: Depending on your chosen cloud platform, you may need to
install specific libraries or SDKs on your Raspberry Pi. For example, if you're using AWS,
you would install the AWS SDK for Python (Boto3). If you're using Azure, you might use
the Azure IoT SDK or Azure Python SDK.
4. Create Cloud Resources: Create the necessary resources on your cloud platform. For
example, if you're using AWS IoT, you'd create an IoT Thing, a policy, and certificates.
5. Connect to the Cloud: Write code on your Raspberry Pi to connect to your cloud platform
of choice. This typically involves using the SDK you installed earlier and providing the
necessary authentication credentials (e.g., API keys, certificates, or access tokens).
6. Publish and Subscribe to Topics (MQTT): Many IoT applications use the publish-
subscribe model for communication. MQTT (Message Queuing Telemetry Transport) is a
common protocol for this purpose. You can publish data from your Raspberry Pi to specific
MQTT topics and subscribe to topics to receive commands or data from the cloud.
7. Data Handling and Processing: Once your Raspberry Pi is connected, you can send and
receive data between the Raspberry Pi and the cloud. You may want to implement data
processing, storage, or analytics depending on your project's requirements.
8. Security Considerations: Ensure proper security practices. Use secure connections (HTTPS,
MQTT over TLS), secure your IoT devices and cloud resources, and regularly update your
Raspberry Pi's software to patch any security vulnerabilities.
9. Monitoring and Management: Set up monitoring and management tools provided by your
cloud platform to keep an eye on your Raspberry Pi's health and performance. This might
include dashboards, alerts, and logging.
10. Scale and Optimize: As your project grows, you may need to scale your cloud resources and
optimize your code and infrastructure for performance and cost-efficiency.
UNIT 5 - APPLICATIONS DEVELOPMENT
Embedded System
As its name suggests, Embedded means something that is attached to another thing. An
embedded system can be thought of as a computer hardware system having software
embedded in it. An embedded system can be an independent system or it can be a part of a
large system. An embedded system is a microcontroller or microprocessor based system
which is designed to perform a specific task. For example, a fire alarm is an embedded
system; it will sense only smoke.
It has hardware.
It has application software.
It has Real Time Operating system (RTOS) that supervises the application software
and provide mechanism to let the processor run a process as per scheduling by
following a plan to control the latencies. RTOS defines the way the system works. It
sets the rules during the execution of application program. A small scale embedded
system may not have RTOS.
Advantages
Easily Customizable
Low power consumption
Low cost
Enhanced performance
Disadvantages
Home Automation is a system that allows users to control various appliances of varying
kinds and also makes controlling of home appliances easier and saves energy. Nowadays,
home automation is used more and more. On the other hand, it provides increased comfort
especially when everyone is busy with their work. Home automation installed in houses
does not only increase comfort but also allows centralized control of heating, ventilation,
air-condition, and lighting. Hence, they contribute to an overall cost reduction and also
useful in energy saving which is certainly the main problem today.
In present years, wireless systems like Wi-Fi, Bluetooth have become more and more
common in home networking. Also in home automation, the use of wireless technologies
gives several advantages that could not be achieved using a wired network only.
Home Automation Components: At the most initial level, home automation systems are
made up of three elements-
1. A smart device.
2. A hub.
3. A connected application.
While some other home automation systems work with just two elements which include a
single device that works with the help of an app on mobile or a tablet or a system that
includes a hands-free hub that controls home automation system while most of the systems
work using all the above three components.
1. Smart Devices: These are the real powerhouse of any home automation system. These
are the main parts that actually implement the whole system commands. Examples of the
smart devices which can be added to any home automation to complete the whole system
are as follows:
Access Control
Security Devices: This includes security cameras, smart locks.
Home Appliances: Smart refrigerators, washing machines, dishwashers, and ovens
already exist.
Smaller Appliances: As automatic coffee pots and electric kettle have been also around
for a while too
Climate Controls: Climate control system with energy management systems
Smart Thermostats.
Entertainment Pieces: Entertainment includes smart TVs, wireless speakers, and film
projectors
Health Care Devices: Smart humidifiers and smart scales are two common examples
of health care devices.
Lighting Controls: They include dimmers, light bulbs, light strips, and switches, etc.
A high-speed internet plays an important role in smooth connectivity and also plays an
important reliable performance between Wi-Fi-enabled devices.
2. Smart Hubs: The hub is the controlling center of the home automation system. It is the
piece that connects your individual devices and helps them talk to one another.
3. Mobile Apps: The mobile application provides an interface between the user and the
system. It gives you the ability to control or monitor your smart devices remotely. They can
be easily downloaded with the help of a provided application on mobile and provide access
control of the system, power controls, timer access, and many more things.
Home automation works with the help of a network of devices that are connected to the
Internet through different communication systems like Wi-Fi, Bluetooth, ZigBee, and
others. Through these devices can be managed remotely through controllers through an app.
Many of these IoT devices have sensors that monitor changes in motion, temperature, and
light so the user can gain information about the device’s surroundings.
1. Monitoring: This means keeping the control of the system using an app on a device
remotely.
2. Control: This means that the system can be controlled remotely from anywhere through
the app by the user.
3. Automation: Automation means making almost all devices automatic for making it a
better system.
Applications: Some of the most common applications of home automation are as follows-
Heating, ventilation, and air conditioning.
Lighting control system.
Occupancy-aware control system.
Leak detection.
Smoke sensors.
Indoor positioning systems.
Home automation for the elderly and disabled.
Air quality control.
Smart Kitchen.
Connected Cooking.
Voice control devices like Amazon Alexa or Google Home used to control home
appliances or systems etc.
Energy Savings: Self-automated light bulbs, fans, and switchboards save energy,
cutting utility costs over time.
Home Safety: Home automation provides the best technologies for home security.
Consumers purchase these devices because they want to make their homes safer and
more secure. Automatic lighting systems and motion sensors help people to enter doors
and walk late at night.
User Convenient: Because home automation performs role tasks automatically, end-
users experience great convenience. For instance, you could use sensors indoors to turn
on your smart lighting when you unlock the front door.
Better Control: Consumers also choose smart home devices to better control functions
within the home. With home automation technology, you can know easily what’s
happening inside your home at all times.
Comfortable Atmosphere: All Connected devices around our home can also help to
create a comfortable atmosphere—they provide intelligent and reliable lighting, sound,
and temperature, which can all help to create a comfortable environment.
Provide Peace of Mind: This system may help consumers to invest in home
automation for peace of mind.
Remote Access: Being able to control devices remotely means things like unlocking the
door for a plant sitter without having to leave a key under the mat.
Disadvantages Of Home Automation:
IOT in Agriculture
Agriculture is another important domain for IOT. IOT systems play an important role for
crop and soil monitoring and give a proper solution accordingly. IOT leads to smart farming.
Using IOT, farmers can minimize waste and increase productivity. The system allows the
monitoring of fields with the help of sensors. Farmers can monitor the status of the area.
Challenges in the modern agriculture industry
The challenges faced by the farming industry and agriculture are listed as follows -
There are various uses of IOT in agriculture that are discussed as follows -
The data from smart sensors can be further analyzed for automated decision-making and
predictive analysis. Machine learning and predictive analysis will be helpful for farmers to
cope up with the weather conditions such as drought, flood, etc.
Drone-based uses
Drones are also useful in smart farming. On one side, drones are useful to monitor the soil,
air, moisture quality, and on another side, they can also be used for physical activities such as
prevention of physical breakouts in farms, automated spraying of fertilizers, and many more.
Although there are some limitations of using a drone, but it is useful to reduce the manual
workforce.
Real-time crop monitoring
Motion detectors, light detectors, smart-motion sensing sensors, smart sensors are useful to
provide real-time data to farmers of their farms. It will be helpful in the monitoring of the
quality of their products.
Infrastructure requirements
There are some infrastructure requirements for adopting smart farming in IOT. Some of the
requirements are listed as follows -
The water supply is one of the most significant perspectives for legislatures. With intelligent
sensors, the water levels can be checked progressively.
These sensors can send triggers and alarms to key chiefs for low or high water levels. The
spillages and water dispersion can be combined using IoT sensors and ICT frameworks.
All regions with a plentiful water supply can be set apart on the guide; correspondingly, the
guides can feature regions with water spillage or deficiency.
A complete outline of the water supply with GPS directions can be given to water specialists with
IoT frameworks.
2. Health Cards
Clinics and medical services frameworks are significant marks of administration. The smart
city requires a state−of−the−art medical services framework that can follow quantifiable
advancement concerning residents' well−being.
A shrewd card−based framework can be utilized by people that might be utilized in all
administration and approved clinics.
This card will have the verifiable subtleties of the medicines and so on for people. The robust
medical care framework will empower the public authority to look at the clinics and their
administrations to residents.
The smart card empowers the framework to work with simple information assortment. The
cloud−based framework can give essential knowledge to Medical services experts for a
further progressive organization.
The waste and trash the executive's exercises can be improved with intelligent sensors and
IoT Frameworks.
The trash containers can utilize intelligent sensors to demonstrate when they should be
discharged. This diminishes the times that vehicles are expected to gather the trash from the
receptacles and evades what is going on of waste flood.
Metropolitan organizations can involve shrewd receptacles and IoT frameworks for trash
assortment.
4. Transport Systems
The transportation framework for the residents can be improved with IoT−empowered
frameworks. The armadas can be overseen and followed utilizing GPS beacons.
Legislatures can finish armadas' organization, planning, ongoing situating, support, and free
time for executives with IoT frameworks.
The residents can likewise benefit from transportation administrations with a card−based
framework for tickets and so on.
Traffic is one of the significant problem areas for residents. With IoT sensors, traffic can be
controlled better.
The sensors are associated with traffic lights and send data to an incorporated server. The
approaching vehicles are followed utilizing these sensors.
When the quantity of vehicles arrives at a limit, signals are shipped off to the drivers to
redirect. These signs are shown with electronic showcase sheets.
Constant traffic cautions and GIS planning of the streets can further develop gridlocks and
blockage during top hours.
The brilliant city requires advanced usage of framework resources. The plants, apparatus, and
gear are labeled and observed with the brought−together resource of the executive's
framework.
The continuous undertaking stock for different advancement works can be followed utilizing
the brought−together framework.
The situation with framework resources, their usage, upkeep, and the complete lifecycle of
the board should be possible with the brought−together IoT framework.
7. Surveillance Systems
IP cameras and reconnaissance frameworks can assist the public authority with controlling
crime percentages in a city.
The IP cameras can be utilized for surveying and monitoring essential foundations. These
cameras can be associated with unified frameworks with reinforcements for verifiable
information.
The public authority can make a move given the contamination levels; e.g., they can establish
trees in a specific area.
The plant life and contamination levels can likewise be portrayed online with google maps
for executives.
One of the critical difficulties for state−run administrations is to decrease energy utilization
and introduce a proficient appropriation framework set up.
Brilliant framework arrangements, electronic meters, and intelligent lighting frameworks are
a portion of the components that are utilized by legislatures to oversee energy effectively.
The power dispersion guides can show on going energy utilization levels, spillages, and
upkeep plans. The IoT−empowered arrangements can improve the energy of the board for
urban areas.
10. E-Services
This can be overseen through biometric confirmation or smart cards. Residents can benefit
from all taxpayer−driven organizations through this card.
The public authority can collect data through these cards for proactive preparation and the
executives.
The residents can benefit from these offices for paying their water and power bills, local
charges, medical clinic check−ups, etc. Coordinated information additionally helps in
strategy−making and organization.
Internet of Things (IoT) in Healthcare
IoT technology brings numerous applications in healthcare, from remote monitoring to smart
sensors to medical device integration. It keeps the patients safe and healthy as well as
improves the physician delivers care towards the patients.
Healthcare devices collect diverse data from a large set of real-world cases that increases the
accuracy and the size of medical data.
There are various factors that affect the IoT healthcare application. Some of them are mention
below:
o Better Care: Using IoT technology, healthcare professionals get the enormous data
of the patient, analysis the data and facilitate better care to the patient.
The application of the Internet of Things (IoT ) in healthcare transforms it into more smart,
fast and more accurate. There is different IoT architecture in healthcare that brings start
health care system.
Product Infrastructure: IoT product infrastructure such as hardware/software component
read the sensors signals and display them to a dedicated device.
Connectivity: IoT system provides better connectivity (using Bluetooth, WiFi, etc.) of
devices or sensors from microcontroller to server and vice-versa to read data.
Analytics: Healthcare system analyzes the data from sensors and correlates to get healthy
parameters of the patient and on the basis of their analyze data they can upgrade the patient
health.