Unit2 Iot
Unit2 Iot
UNIT 2
IoT Hardware and Software
2
Transducer types
Sensors
Devices that measures physical quantities and convert
them into signals which can be read by instruments.
Actuators
Devices that actuates or moves something. More
specifically, they converts electrical energy into motion
or mechanical energy
Transducer types
Quantity
Input Device Output Device
being
(Sensor) (Actuator)
Measured
Light Dependant Resistor (LDR), Lights & Lamps, LED's &
Light Level
Photodiode, Phototransistor, Solar Cell Displays, Fiber Optics
Thermocouple, Thermistor,
Heater, Fan, Peltier
Temperature Thermostat, Resistive temperature
Elements
detectors (RTD)
Force/Pressur Strain Gauge, Pressure Switch, Load Lifts & Jacks,
e Cells Electromagnetic, Vibration
Potentiometer, Encoders, Motor, Solenoid, Panel
Position
Reflective/Slotted Opto-switch, LVDT Meters
Tacho-generator, Reflective/Slotted AC and DC Motors, Stepper
Speed
Opto-coupler, Doppler Effect Sensors Motor, Brake
Carbon Microphone, Piezo-electric
Sound Bell, Buzzer, Loudspeaker
Crystal
4
Characteristic of Sensors
• Sensitivity
• Linearity
• Range
• Response time
• Accuracy
• Precision
5
Characteristic of Sensors
• Sensitivity is a measure of the change in output of the sensor relative to a unit
change in the input (the measured quantity) Example: The speakers you purchase
for your home entertainment may have a rated sensitivity of 89 dB Signal Pressure
Level per Watt per meter.
• Range It is the minimum and maximum value of physical variable that the
sensor can sense or measure.
2. Temperature Sensor
3. Humidity Sensor
4. Ultrasonic Sensor
5. Motion Sensor
6. Pressure Sensor
7. Gas Sensor
Processing circuit
11
LVDT
13
Rotary Encoders
• Incremental and absolute types
• Incremental encoder needs a counter, loses absolute
position between power glitches, must be re-homed
• Absolute encoders common in CD/DVD drives
14
Temperature Sensors
• The temperature sensor is used to detect the heat
energy which is produced from an object or
environment.
• These sensors are applicable for the Internet of Things
(IoT), which includes from manufacturing to farming.
• The main role of these sensors in manufacturing is for
temperature monitoring of machines.
• Similarly, in the agriculture field, these sensors are used
to monitor the temperature of plants, soil, and water.
Thermocouple
• Thermocouples are the most commonly used type of temperature
sensor. They are used in industrial, automotive, and consumer
applications.
• Thermocouples are self-powered, require no excitation, can
operate over a wide temperature range, and have quick response
times.
Thermocouple
• Thermocouples are made by joining two dissimilar metal
wires together. This causes a Seebeck Effect.
• The Seebeck Effect is a phenomenon in which a
temperature difference of two dissimilar conductors
produces a voltage difference between the two substances.
• It is this voltage difference that can be measured and used
to calculate the temperature.
• In thermocouples the measuring of temperature can be
challenging because of their small output voltage, which
requires precise amplification, susceptibility to external
noise over long wires, and cold junction.
Resistance Temperature Detector
• RTD’s are precision temperature sensors made from high-
purity conducting metals such as platinum, copper or nickel
wound into a coil and whose electrical resistance changes
as a function of temperature.
• As temperature changes, the resistance of any metal
changes as well. This difference in resistance is what RTD
temperature sensors are based on.
• Resistive temperature detectors have positive temperature
coefficients (PTC) their output is extremely linear producing
very accurate measurements of temperature.
• However, they have very poor thermal sensitivity.
Thermistor
• Thermistor is a special type of resistor which changes its
physical resistance when exposed to changes in
temperature like RTD sensor.
• This thermistor offers higher sensitivity than the resistor
temperature detectors.
• Thermistors are made from manganese and oxides of
nickel, which make them susceptible to damages.
• Most of the thermistors have a negative temperature
coefficient. It means, when the temperature increases the
resistance decreases.
• Thermistors are passive resistive devices which means we
need to pass a current through it to produce a measurable
voltage output.
Infrared temperature Sensor
• Infrared sensors are mainly used to measure the heat
which is produced by objects.
• Infrared temperature sensors sense electromagnetic
waves in the 700 nm to 14,000 nm range.
• These sensors are used in the various applications of
IoT like healthcare for monitoring the flow of blood, BP,
etc.
• These sensors are used in smartphones for controlling,
wearable devices for detecting the amount of light,
detection of blind-spot within vehicles, etc.
Thermometer
• A thermometer is a device used
to measure the temperature of
solids, liquids, or gases.
• Thermometer contains a liquid,
which is mercury or alcohol in its
glass tube.
• The volume of the thermometer
is linearly proportional to the
temperature – when the
temperature increases, the
volume of the thermometer also
increases.
Humidity Sensors
• Humidity is defined as the amount of water present in the
surrounding air.
• A humidity sensor is an electronic device that measures
the humidity in its environment and converts its findings
into a corresponding electrical signal.
• The units for measurement of humidity is RH (relative
humidity), D/F PT (Dew/frost point) & PPM (parts per
million).
• Humidity sensors can be divided into two groups, as each
category uses a different method to calculate humidity:
relative humidity (RH) sensors and absolute humidity (AH)
sensors.
Important Terms Related to Humidity
Relative Humidity(RH): is the amount of moisture in the
air compared to what the air can hold at that temperature.
Moisture: means water content of any material or
substance. But practically, the term Moisture refers to the
water content in solids and liquids.
Dew Point: is the temperature at which the relative
humidity is 100 %
When air temperature reaches the dew point temperature:
100 % relative Humidity
Condensation or precipitation occurs
Classification of Humidity Sensors
• Capacitive Relative Humidity Sensors
•The distance from the sensor and signalling circuit is very limited.
•HVAC Systems
•Printers and Fax Machines
•Weather Stations
•Automobiles
•Food Processing
•Refrigerators, Ovens and Dryers
Resistive Humidity Sensors
• Resistive Humidity Sensors are another important type of Humidity
Sensors that measure the resistance (impedance) or electrical
conductivity.
• The principle behind resistive humidity sensors is the fact that the
conductivity in non – metallic conductors is dependent on their water
content.
Resistive Humidity Sensors
Advantages of Resistive Humidity Sensors
• Low cost
•Small Size
•The distance between the sensor and signal circuit can be large (suitable for
remote operations).
• Highly interchangeable as there are no calibration standards.
Resistive or Electrical Conductive Humidity sensors are low cost sensors with
relatively small size. They are often used in several industrial, domestic or
residential and commercial applications.
Thermal Conductivity Humidity Sensors
• Thermal Conductivity Humidity Sensors are also known as Absolute Humidity
(AH) Sensors as they measure the Absolute Humidity.
• Absolute Humidity doesn’t take temperature in to account but it changes with
temperature and pressure.
• Thermal Conductivity Humidity Sensors measure the thermal conductivity of
both dry air as well as air with water vapour. The difference between the
individual thermal conductivities can be related to absolute humidity.
Thermal Conductivity Humidity Sensors
Advantages of Thermal Conductivity Humidity Sensors
• Drying kilns
• Pharmaceutical plants
• Owens
• Clothes dryers and drying machines
Ultrasonic Sensor
• An ultrasonic sensor is an
instrument that measures the
distance to an object using
ultrasonic sound waves.
• In IoT ultrasonic sensors are used for
non-contact detection of solid and
liquid objects.
• These sensors are used for a wide
variety of functions from monitoring
the level of water in a tank to fluid
identification/concentration, to
detecting object proximity.
Ultrasonic Sensor
• Ultrasonic sensors work by sending out a sound wave at a
frequency above the range of human hearing.
• It sends an ultrasonic pulse out at 40kHz which travels through the
air and if there is an obstacle or object, it will bounce back to the
sensor.
• Ultrasonic sensors have two main components: the transmitter
(which emits the sound using piezoelectric crystals) and the
receiver (which encounters the sound after it has travelled to and
from the target).
• In order to calculate the distance between the sensor and the
object, the sensor measures the time it takes between the emission
of the sound by the transmitter to its contact with the receiver.
Motion Sensor
• A motion sensor or motion detector is an electronic
device that is designed to detect and measure
movement.
• Motion sensors are used primarily in home and business
security systems.
• There various kinds of motion sensors are available in
the market. They are namely PIR, Ultrasonic, Microwave,
Tomographic and combined types.
What is an Arduino ?
• Open Source electronic prototyping platform
based on flexible easy to use hardware and
software.
What is an Arduino?
• A microcontroller board, contains on-board power
supply, USB port to communicate with PC, and
an Atmel microcontroller chip.
• It simplify the process of creating any control
system by providing the standard board that can
be programmed and connected to the system
without the need to any sophisticated PCB design
and implementation.
• It is an open source hardware, any one can get the
details of its design and modify it or make his own
one himself.
Arduino Boards
Arduino Uno
Getting started with Programming
Arduino IDE
Arduino IDE
Arduino IDE
Code Structure
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Code Structure
• setup : It is called only when the Arduino is
powered on or reset. It is used to initialize
variables and pin modes
• analogWrite (2,128);
Serial Communication
ADC Example
• // These constants won't change. They're used to give names to the pins used:
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(2);
}
Advantages
• Very easy to get started.
• It can be used for real-time applications for
both hardware, software and IDE is open
source.
• Not much programming knowledge needed to
do basic stuff.
• It is very easy to extend and has tons of user-
contributed shields and libraries. Shields are
available to do attractive much anything.
Disadvantages
• It is not very powerful when compared with
Raspberry Pi
• You need to program using either Arduino or
C/C++
• Connecting to the internet is slightly difficult,
but not impossible. Parsing of Arduino with
YQL and JSON is possible.
What is an Raspberry Pi ?
• Raspberry Pi is a small single board computer. By connecting
peripherals like Keyboard, mouse, display to the Raspberry Pi, it
will act as a mini personal computer.
• Raspberry Pi is popularly used for real time Image/Video
Processing, IoT based applications and Robotics applications.
• Raspberry Pi is slower than laptop or desktop but is still a computer
which can provide all the expected features or abilities, at a low
power consumption.
• Raspberry Pi Foundation officially provides Debian based Raspbian
OS. Also, they provide NOOBS OS for Raspberry Pi. We can install
several Third-Party versions of OS like Ubuntu, Archlinux, RISC
OS, Windows 10 Core, etc.
• Raspbian OS is official Operating System available for free to use.
This OS is efficiently optimized to use with Raspberry Pi.
What is an Raspberry Pi ?
• Raspbian have GUI which includes tools for Browsing, Python
programming, office, games, etc.
• We should use SD card (minimum 8 GB recommended) to store the
OS (operating System).
• Raspberry Pi is more than computer as it provides access to the on-
chip hardware i.e. GPIOs for developing an application. By
accessing GPIO, we can connect devices like LED, motors, sensors,
etc and can control them too.
• It has ARM based Broadcom Processor SoC along with on-chip
GPU (Graphics Processing Unit).
• The CPU speed of Raspberry Pi varies from 700 MHz to 1.2 GHz.
Also, it has on-board SDRAM that ranges from 256 MB to 1 GB.
• Raspberry Pi also provides on-chip SPI, I2C, I2S and UART
modules.
Versions of Raspberry Pi
Raspberry Pi 3 Raspberry Pi 2
Features Raspberry Pi zero
Model B Model B
Wireless No No No
Raspberry Pi 3
Raspberry Pi 3
• HDMI (High-Definition Multimedia Interface): It is used
for transmitting uncompressed video or digital audio data to
the Computer Monitor, Digital TV, etc. Generally, this
HDMI port helps to connect Raspberry Pi to the Digital
television.
• CSI Camera Interface: CSI (Camera Serial Interface)
interface provides a connection in between Broadcom
Processor and Pi camera. This interface provides electrical
connections between two devices.
• DSI Display Interface: DSI (Display Serial Interface)
Display Interface is used for connecting LCD to the
Raspberry Pi using 15-pin ribbon cable. DSI provides fast
High-resolution display interface specifically used for
sending video data directly from GPU to the LCD display.
Raspberry Pi 3
• Composite Video and Audio Output: The
composite Video and Audio output port carries
video along with audio signal to the Audio/Video
systems.
• Power LED: It is a RED colored LED which is
used for Power indication. This LED will turn ON
when Power is connected to the Raspberry Pi. It is
connected to 5V directly and will start blinking
whenever the supply voltage drops below 4.63V.
• ACT PWR: ACT PWR is Green LED which
shows the SD card activity.
Raspberry Pi GPIO Access
GPIO (General Purpose Input Output) pins can
be used as input or output and allows raspberry
pi to connect with general purpose I/O devices.
• Raspberry pi 3 model B took out 26 GPIO pins
on board.
• Raspberry pi can control many external I/O
devices using these GPIO’s.
• These pins are a physical interface between the
Pi and the outside world.
Raspberry Pi GPIO Access
• We can program these pins according to our needs to
interact with external devices. For example, if we want to
read the state of a physical switch, we can configure any of
the available GPIO pins as input and read the switch status
to make decisions. We can also configure any GPIO pin as
an output to control LED ON/OFF.
• Raspberry Pi can connect to the Internet using on-board Wi-
Fi or Wi-Fi USB adapter. Once the Raspberry Pi is
connected to the Internet then we can control devices, which
are connected to the Raspberry Pi, remotely.
• Some of the GPIO pins are multiplexed with alternate
functions like I2C, SPI, UART etc.
• We can use any of the GPIO pins for our application.
Raspberry Pi GPIO Access
Advantages
• It is very easy to connect to the internet.
• Entire Linux software stack is available.
• Can be programmed using a variety of
programming languages.
Disadvantages
• Accessing hardware is not real-time. If the
CPU is busy, then interfacing with the
hardware can be delayed.
• Does not have enough power to drive
inductive loads.
• There is no inbuilt Analog to Digital converter
available.
• The hardware design is not open source. Even
though it is not a big deal, for some people it
might a deal-breaker.
LiteOS
•LiteOS is a real-time operating system (RTOS).
•This operating system allows users to operate wireless sensor networks like operating Unix, which
•It follows a hybrid programming model that allows both event-driven and thread-driven
programming
LiteOS Architecture
LiteOS
Programming Model:
•LiteOS is a multitasking OS and it supports multithreading.
•processes run applications as separate threads.
•LiteOS also provides support for event handling. Application programmers can register event
handlers using a callback facility provided by LiteOS.
•To avoid potential race conditions, LiteOS provides atomic_start() and atomic_end()
functions. Whenever shared data among different threads is accessed or modified, it is highly
recommend to use these functions.
LiteOS
Scheduling:
•LiteOS provides an implementation of Round Robin scheduling and Priority-based
scheduling.
•The tasks run to completion or until they request a resource that is not currently
available.
•When a task requires a resource that is not available, the task enables interrupts and
goes to sleep mode.
•Once the required resource becomes available, the appropriate interrupt is signaled
and the task resumes it execution from where it had left. When a task completes its
operation it leaves the kernel.
•When there are no active tasks in the system, the sensor node goes to sleep mode.
Before going to sleep mode the node enables its interrupts so that it can wake up at
the proper event or time.
LiteOS
Memory Protection and Management
•Inside the kernel, LiteOS supports dynamic memory allocation through the use of
C-like malloc and free functions.
•User applications can use these APIs to allocate and de-allocate memory at run-
time.
•Dynamic memory grows in the opposite direction of the LiteOS stack.
•The LiteOS kernel compiles separately from the application, therefore the address
space is not shared between the kernel and the application.
Similarly, each user application has its separate address space. Processes and Kernel
memory safety is enforced through separate address spaces.
LiteOS
Communication Protocol Support
•LiteOS provides communication support in the form of files
•LiteOS creates a file corresponding to each device on the sensor node.
•Whenever there is some data that needs to be sent, the data is placed into the
radio file and is afterward wirelessly transmitted.
•At the network layer LiteOS supports geographical forwarding.
• Each node contains a table that can only hold 12 entries.
LiteOS
Resource Sharing
LiteOS suggest the use of APIs provided for synchronization whenever a thread
wants to access resources that are shared by multiple threads. The LiteOS
documentation does not provide any detail on how system resources are shared
among multiple executing threads.
LiteOS
Support for Real-Time Applications
•LiteOS does not provide any implementation of networking protocols that support
real-time multimedia applications.
•It provides a priority-based process scheduling algorithm but once a process is
scheduled it runs to completion
•This can result in a missed deadline of a higher priority process that enters the ready
queue once a low priority process has been scheduled.
LiteOS
Additional Features
Layered architecture
Uses C and Partial C++ support
Provides device drivers, communication and sensor data
handling as services
Also comprises uIP Stack, a device driver loader and a
Protothreading system
Protothreads are simple light weight multi threading
system that uses a stack-less implementation
Contiki is an open source operating system for the Internet of Things.
runs on networked embedded systems and wireless sensor nodes.
Contiki is a highly portable OS and it is build around an event-driven
kernel.
Contiki provides preemptive multitasking that can be used at the
individual process level.
Polling mechanism is used to avoid race condition.
Any scheduled event will run to completion, however, event handlers
can use internal mechanisms for preemption.
Contiki OS Architecture
Functional Aspect:
It’s kernel functions as an event-driven kernel; multithreading is supported by
an application library. In this sense it is a hybrid OS.
Contiki realises the separation of kernel of the basic system support form the
rest of the dynamically loadable and programmable services (called
processes).
The services communicate with each other through the kernel by posting
events.
The ContikiOS kernel does not provide any hardware abstraction; but it
allows device drivers and application directly communicate with the
hardware.
Each Contiki service manages its own state in a private memory space and the
kernel keeps a pointer to the process state.
Programming Model:
Contiki supports preemptive multithreading. Multi-threading is implemented as a library
on top of the event-driven kernel.
The library can be linked with applications that require multithreading. The Contiki
multithreading library is divided in two parts: a platform independent part and a platform
specific part
Contiki uses protothreads.
Protothreads are designed for severely memory constraint devices because they are stack-
less and lightweight.
The main features of protothreads are: very small memory overhead (only two bytes per
protothread), no extra stack for a thread, highly portable (i.e., they are fully written in C and
hence there is no architecture-specific assembly code). Since events run to completion and
Contiki does not allow interrupt handlers to post new events, no process synchronization is
provided in Contiki.
Scheduling
Contiki is an event-driven OS, therefore it does not employ any sophisticated scheduling
algorithm. Events are fired to the target application as they arrive. In case of interrupts,
interrupt handlers of an application runs w.r.t. their priority.
Contiki provides another lightweight layered protocol stack, called Rime, for network-based
communication. Rime provides single hop unicast, single hop broadcast, and multi-hop
communication support. Rime supports both best effort and reliable transmission.
Resource Sharing
Since events run to completion and Contiki does not allow interrupt handlers to post new
events, Contiki provides serialized access to all resources.