[go: up one dir, main page]

0% found this document useful (0 votes)
43 views78 pages

Module - Ii: Elements of Iot

Uploaded by

thesharingansaga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views78 pages

Module - Ii: Elements of Iot

Uploaded by

thesharingansaga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 78

MODULE -II

Elements of IoT
ARDUINO BOARD

Arduino is a microcontroller-based
open source electronic prototyping
board which can be programmed with
an easy-to-use Arduino IDE.

Arduino Uno is a reference model for the Arduino


platform. The Uno is an MCU board. It includes an
ICSP 6-pin header, which enables embedding
(burning) of programs. The process of programming
an EEPROM/ROM is called burning. ICSP is in-
circuit serial programming, which means burning the
code through connectivity with the ICSP header. Uno
board includes a USB connection, a power jack and
reset button (to start the board and run Bootloader).
USB is also used for pushing programs on to the
board after development using IDE on a computer.
COMPONENTS OF ARDUINO BOARD
Starting clockwise from the top center:
1. Analog Reference pin (orange)
2. Digital Ground (light green)
3. Digital Pins 2-13 (green)
4. Digital Pins 0-1/Serial In/Out - TX/RX (dark green) - These pins cannot be used for
digital i/o (digitalRead and digitalWrite) if you are also using serial communication (e.g.
Serial.begin).
5. Reset Button - S1 (dark blue)
6. In-circuit Serial Programmer (blue-green)
7. Analog In Pins 0-5 (light blue)
8. Power and Ground Pins (power: orange, grounds: light orange)
9. External Power Supply In (9-12VDC) - X1 (pink)
10. Toggles External Power and USB Power (place jumper on two pins closest to desired
supply) - SV1 (purple)
11. USB (used for uploading sketches to the board and for serial communication between the
board and the computer; can be used to power the board) (yellow)
USB connector: used to load a program from the Arduino Power port: The Arduino board can be powered
IDE onto the Arduino board through an AC-to-DC adapter or a battery
2.1mm centre-positive plug:The Arduino
UNO board operates at a voltage of 5 volts,
but it can withstand a maximum voltage of 20
volts. If the board is supplied with a higher
voltage, there is a voltage regulator (it sits
between the power port and USB connector)
that protects the board from burning out.

Atmega328P microcontroller: having 28 pins. It is the


brains of your Arduino. The microcontroller used on the
UNO board is Atmega328P by Atmel ( a major
microcontroller manufacturer). Atmega328P has the
following components like flash memory, 2KB RAM, CPU,
1KB of EEPROM.
Digital pins: these pins labeled “Digital 0 to 13.” These pins
Analog input pins: The Arduino UNO board has
can be used as either input or output pins. When used as
6 analog input pins, labeled “Analog 0 to 5.”
output, these pins act as a power supply source for the
These pins can read the signal from an analog
components connected to them. When used as input pins,
sensor like a temperature sensor and convert it into
they read the signals from the component connected to them.
a digital value. These pins just measure voltage
and not the current because they have very high When digital pins are used as output pins, they supply 40
internal resistance. Hence, only a small amount of milliamps of current at 5 volts, which is more than enough to
current flows through these pins. light an LED.
Reset switch: When this switch is clicked, it Crystal oscillator: This is a quartz crystal oscillator
sends a logical pulse to the reset pin of the which ticks 16 million times a second. On each tick,
Microcontroller, and runs the program again the microcontroller performs one operation, for
from the start. This can be very useful if your example, addition, subtraction, etc.
code doesn’t repeat, but you want to test it
multiple times.
USB interface chip: As a signal translator. It TX – RX indicator: TX stands for transmit, and
converts signals in the USB level to a level that RX for receive. These are indicator LEDs which
blink whenever the UNO board is transmitting
an Arduino UNO board understands.
or receiving data.
Features which make Arduino boards widely used are:
1. Prototyping ease
2. Flexibility and ease of assembling modules on the board
3. Open extensible source code, schematics, software, middleware and IDE; the AVR-C
codes extend on coding in C++, and the libraries can be added with additional
programs, AVR-C codes means C commands and statements for using AVR ports,
serial interfaces and other functional units of the MCU
4. IDE latest version and appropriate OS are open source 3 IDE and software runs on
multiple environments, Linux, Windows and Mac OS-X
5. Number of times programmability of the board during the editing-testing-debugging
cycles, and for development of number of new prototype using the same
6. Hardware open source and extensible using the modules, shields and other circuits with
open version of IDE, software modules and codes from other designers
ARDUINO FAMILY
Arduino Uno, and IoT and Wearable Devices Arduino Boards:
Lists the features of Uno and IoT and wearable device boards as the examples. Additionally, the
features of Arduino ARM based platform are also given.
INTERFACING TO MICROCONTROLLER

A microcontroller (sometimes
called an MCU or Microcontroller
Unit) is a single Integrated Circuit
(IC) that is typically used for a
specific application and designed
to implement certain tasks
Standard Interfacing Circuits:
1. The Standard Transistor Output Device Interfacing:
Interfacing Circuit 1. LED
2. Using a Darlington Driver IC 2. Signal Lamp
3. The Standard Relay Interfacing 3. Buzzer
Circuit 4. Piezo Sounder & Speakers
4. The Standard FET Interfacing 5. Solar & DC (“toy”)
Circuit 6. Motors Unipolar Stepper Motor
7. Bipolar Stepper Motor
8. Radio-Control Servo
9. Counter Module
Input Device Interfacing: 10. Seven Segment Display
1. Switches 11. Solenoid & Isonic Solenoid Valve
2. Potentiometers 12. Smart Wire / Spring
3. Light Dependent Resistor (LDR)
4. Thermistor
CASE STUDY

❑ Home appliances like refrigerator, microcontroller is used for controlling the different
operations of refrigerator. It is getting the temperature from some temperature sensor
and by reading the temperature it is controlling your compressor.
❑ Now it is taking decision that whether to drive whether to run the compressor or not
depending among the temperature inside temperature of the refrigerator.
❑ It is also used to generate some voices or alarms if the temperature gets high like in case
you have opened the door of a refrigerator for a long time or it can display the internal
temperature of the refrigerator on some LCD device.
INPUT DEVICE INTERFACING

SPDT Micro Switch Pinout


A potentiometer (or ‘variable resistor’) has a spindle that can be moved to change the
resistance value of the potentiometer. This can be used to measure rotational or linear
movement.
Arduino connections with Potentiometer
A Light Dependent Resistor (LDR) is a resistor that changes in
value according to the light falling on it. A commonly used
device, the ORP-12, has a high resistance in the dark, and a low
resistance in the light. Connecting the LDR to the
microcontroller is very straight forward, but some software
‘calibrating’ is required.
A thermistor is a resistor that changes in value
according to it’s heat.
In actual fact all resistors change in value as they
heat up or cool down, but thermistors are
manufactured to show a large resistance change.
Connecting the thermistor to the microcontroller is
very straight forward, but some software ‘calibrating’
is required.
PIR Sensor
Ultrasonic Sensor
Voltage Sensor

Flame Sensor
Gas Sensor
Raspberry-Pi

Raspberry pi is the name of the “credit card-sized computer board” developed by the
Raspberry pi foundation. It gets plugged in a TV or monitor and provides a fully
functional computer capability.
❑ 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).
❑ The original device had a single-core Processor speed of device ranges from 700 MHz to
1.2 GHz and a memory range from 256 MB to 1 GB RAM.
❑ To store the operating system and program memory Secure Digital (SD) cards are used.
Raspbian OS which is a Linux operating system is recommended OS by Raspberry Pi
Foundation. Some other third party operating systems like RISC OS Pi. Diet Pi, Kali,
Linux can also be run on Raspberry Pi.
Why use Raspberry Pi
• Robust and affordable,
• Raspberry Pi technology has been deployed in tens of thousands of
applications in a variety of industries across the world.
• With a wide range of computing products and a network of trusted
design partners, Raspberry Pi not only has the technology to help your
business, but can also provide the vital help you need to find your perfect
setup. in tens of thousands of applications in a variety of industries
across the world.
With a wide range of computing products and a network of trusted design partners,
Raspberry Pi not only has the technology to help your business, but can also provide
the vital help you need to find your perfect setup.
Raspberry Pi Interfaces
❑ Serial: The serial interface on Raspberry Pi has receive (Rx) and transmit (Tx) pins
for communication with serial peripherals.
❑ SPI: Serial Peripheral Interface (SPI) is a synchronous serial data protocol used for
communicating with one or more peripheral devices.
❑ I2C: The I2C interface pins on Raspberry Pi allow you to connect hardware modules.
I2C interface allows synchronous data transfer with just two pins - SDA (data line)
and SCL (clock line)
General specifications:
− There are two USB 3.0 ports and two USB 2.0 ports.
− There are two micro-HDMI ports. − GPIO header with 40 pins.
− Gigabit Ethernet.
− 2-lane MIPI DSI display port.
− 2-lane MIPI CSI camera port.
− LPDDR4-3200 SDRAM (2, 4, or 8 GB).
− Broadcom BCM2711.
− Quad-core Cortex-A72 (A.R.M. v8) 1.5 GHz processor.

• The software's offered are RASPBIAN, PIDORA, OPENELEC, RASPBMC, RISC OS,
ARCH LINUX.
• All these software's can be downloaded easily and for free from the official forum under
the NOOBS (new out of the box software) category.
It provides support for functioning and coding in Python as the main programming
language. It also provides support for BASIC, C, C++, JAVA, Perl and Ruby.
Raspberry Pi Example: Interfacing LED and switch with
Raspberry Pi
Booting Process
The booting method involves the following steps:
1. Downloading the NOOBS operating system install manager from the official forum of Raspberry Pi.
2. Formatting a microSD card.
3. Burning the NOOBS image onto a microSD card.
4. Inserting the card into the microSD card slot on the RaspberryPi board.
5. Plugging in keyboard, mouse and monitor cable onto the board and to the monitor.
6. Plugging in the USB power cable.
7. The boot process has now begun and a configuration window appears to enable the camera module if
present and setting the date and time.
8. The command line interface loads up asking for the username and password, upon submitting successful
information the board is fully operational.
9. The graphical user interface can be chosen by typing startx.
10. Default username and passwords for first boot are: username: pi, password: raspberry.
Adoption

Raspberry Pi is intended to get people interested in computing, coding or even to solve


their general needs. People are inclined to use this board for tinkering, for enhancing
everyday experiences like using the FAX machine, innovating Home-robots, media
players, video camera streamers. Some of them include
Pi in the sky: This board is a GPS receiver and radio transmitter designed for tracking
high altitude balloon flights.
R2D2 powered by RaspPi: Xiang’s R2D2 tracks faces and motion, is motorized for
movement, and has the ability to respond to voice commands.
Otto: Otto is a camera product that captures pictures with a twist. It converts them into
animated GIF’s, time lapses, and can added many effects to a picture or to a GIF.
Livebots: Livebots is a project that allows users to control many robots based on
RaspberryPi over the internet.
Lap pi: The project features a laptop built from scratch based on the Raspberry pi board.
Raspberry Pi in the sky
❑ On the hardware side, the
heart of the OTTO is a
Raspberry Pi 3.
❑ The all-important audio
interface is a Fe-Pi Audio
Z V2, though a USB
interface can be used.
❑ The 48 switches and four
rotary encoders are
wrangled by a pair of
Arduino pro micros
which pass the data on to
the Pi.
❑ Data is related to the user
through a 320×200 LCD.
Livebots is a project which allows you to control a robot (powered by the Pi, of
course) over the internet.
The robots are available to control depending on which of them is online at the
moment you visit.
• A Raspberry Pi
based “LapPi” laptop
kit with 7- or 5-inch
screens, keyboard,
camera, speakers,
and 3800mAh
battery.
• Portable, Easy to
carry anywhere,
convenient to carry.
Applications
Controlling AC Power Devices with Relays
• A relay is an electrically operated switch
used to control a circuit by a low-power
signal or to control several circuits by one
signal.
• Relays allow one circuit to switch a second
circuit that can be completely separate from
the first.
• The basic operation involves an
electromagnet that, when energized, either
opens or closes a set of contacts, thereby
switching the circuit.
❑ Pin1 Signal pin (Relay Trigger): This input pin is used to activate the relay.

❑ Pin2 (Ground): This is a ground pin.

❑ Pin3 (VCC): This input supply pin is used to power the relay coil.

❑ Pin4 (Normally Open): This is the relay’s NO (Normally open) terminal.

❑ Pin5 (Common): This is the relay’s common terminal.

❑ Pin6 (Normally Closed): This is the Normally closed (NC) terminal of the relay.
Electromechanical Relay (EMR)
❑ An electromechanical relay uses a physical moving part to connect contacts within
the output component of the relay.

❑ The movement of this contact is generated using electromagnetic forces from the
low-power input signal, allowing the completion of the circuit that contains the high-
power signal.

❑ The physical component within the electromechanical relay commonly makes a


“click” sound, which can actually be useful in some situations, though it can lead to
internal arcing and takes a relatively large amount of time to move.
Solid State Relay (SSR)
❑ A solid state relay just might be the poster child of the semiconductor industry.

❑ SSRs use a low power electrical signal to generate an optical semiconductor signal,
typically with an optocoupler, that transmits and energizes the output signal.

❑ When activated, the input optical signal acts as the “switch” that allows a high voltage
signal to pass through the SSR’s output component.

❑ There are several ways of doing this, but the common theme between them all is the
lack of moving parts, thus making them solid-state.
❑ Relays are composed by an electromagnet that moves a tiny metallic plank, which is
called COM terminal, between two different positions NC terminal and NO terminal.

❑ We can decide in which position the COM terminal is connected to through


activating/deactivating the electromagnet, by connecting a low power signal in the
electromagnet control terminals.
Controlling a Servo Motor
Servo Motors:A servo motor is an electric motor that allows for precise control of
angular position. It incorporates a position feedback mechanism to accurately
control its motion. The term 'servo' is derived from 'servomechanism', which is a
system that uses feedback to automatically provide a controlled power level or
force to move and hold an object at a certain position.

Fig Servo Motor Diagram


Stepper motors have a magnetized
geared core that is surrounded by a
number of coils that act as
electromagnets.
Despite the number of coils electrically
there really are usually only two coils in
a stepper motor, divided into a number
of small coils.

Here, the coil at the top is energized by applying electricity in the polarity shown. The
magnetized shaft is attracted to this coil and then locks into place.
The internal components of a servo motor are described below:
It consists of:
•A motor - Acts as the actuator to rotate the shaft. Can be DC, AC
•Amplifier - Powers the motor as per command signal from a controller.
•Encoder - Acts as position sensor to detect shaft rotation in degrees or radians.
•Controller - Compares reference and feedback position signals to generate correcting
commands.
•Programming inputs - Provides desired commanded position, speed, and torque.
A servo motor consists of three wires– a black wire connected to the ground, a
white/yellow wire connected to the control unit and a red wire connected to the
power supply.

Applications of servo motor


Servomotor used in camera zooms, lift doors, or tools we may have at
home. radio-controlled airplanes to position control. Servo motors are also used in
industrial applications, robotics, in-line manufacturing, pharmaceutics, and food
services.
Some circuit connections of servo motor with Arduino UNO
Auto sweep (without Potentiometer):
1st connection is for rotating in a fixed targeted angle. the shaft of servo goes to that angle
and then returns. If the required angle set in the program is 180° and the start angle is 0º
then start rotation from 0º to 180º and then return automatically to 0º and repeat this
process. If we set the rotation angle is 90º to 160º then rotation starts from the 90º and goes
up to 160º and returns to 90º and repeats this process continuously. The speed of the servo
can be controlled by changing the value of the time delay function. If you use one micro
servo motor then you don’t need to connect an external power source, you can use only USB
for power.
Servo motor control using a potentiometer (Knob):
❑ A potentiometer of any value between 10k to 100k. One side pin of the potentiometer is
connected with the ground, another side pin is connected with 5v supply and the middle
pin is connected with the analog input pin of Arduino (A0).
❑ Analog input gets from the pot and according to this input, the movement of servo
changes. When moving the pot shaft or knob then the servo shaft is also rotating oº to 180º
according to pot movement.
Switching high power devices with transistors

Switching high-power devices with transistors is a common technique


in electronics, allowing control of devices such as motors, lamps, or
other high-current components using low-power control signals.
The Role of the Transistor

Transistors can act as electronic switches. When a small current flows through the
base (for a Bipolar Junction Transistor, BJT), it allows a much larger current to flow
between the collector and emitter (BJT).

Types of Transistors: BJT: Requires a base current to turn on. MOSFET: Requires
a gate voltage to turn on. Typically, N-channel MOSFETs are used for switching as
they have lower on-resistance.

Circuit Design

1. Choosing the Right Transistor: Ensure the transistor can handle the required
load current and voltage. For high-power applications, a MOSFET is often
preferred due to its lower power dissipation.

2. Base Resistor: A resistor is often placed between the control signal and the base
to limit current and protect the transistor.
Bipolar Transistor MOSFET Connection

Base Gate Connects to microcontroller


output

Collector Drain Connects to power through load

Emitter Source Connects to ground


Unipolar and Bipolar Stepper Motors
❑ Unipolar stepper motors have a center-tap on
each coil, allowing the current to flow in one
direction through each half of the coil.

❑ Each coil has a common center tap that is


typically connected to a constant voltage, and
the current flows through one half of the coil at
a time.
❑ They generally have 5, 6, or 8 wires.

❑ They are easier to control because each coil is


energized in one direction, simplifying the
driving circuitry.

❑ This results in simpler driver circuits compared


to bipolar stepper motors. hey typically provide
lower torque compared to bipolar stepper
motors for the same current.
❑ A unipolar stepper motor also
consists of two coils
(electrically) but each coil has a
center tap so there are three
connections on each coil.

❑ This results in six connections,


however many unipolar stepper
motors have only five
connections as the two center
taps are internally connected.

In a unipolar stepper motor only half of each coil is used at one time. In most
configurations, a positive voltage is applied to the center tap and left there. A negative
voltage is then applied to one side of the coil to attract the motor shaft.
❑ Bipolar stepper motors do not have a center tap;
instead, each coil has two ends that are connected to
the driver. The current must flow in both directions
through each coil to produce movement. They
usually have 4 wires.
❑ They require more complex driver circuitry to
reverse the direction of current in the coils.
However, they can achieve higher torque and better
performance because the entire coil is used.
❑ They generally provide higher torque compared to
unipolar stepper motors for the same current due to
the full use of the coil.
❑ Bipolar stepper motors
consist of two coils of wire
(electrically, actually split
into several physical coils)
and generally have four
connections, two per coil.
❑ An advantage of bipolar
stepper motors is that they
make use of the entire coil
winding so they are more
efficient. However, they
require a more complex
controller or driver to
operate as to reverse
direction the polarity of the
voltage applied to the coils
needs to be reversed.
Programming API’s (using Python/Arduino) for Communication

API stands for Application Programming Interface. In the context of APIs, the word
Application refers to any software with a distinct function. Interface can be thought of
as a contract of service between two applications. This contract defines how the two
communicate with each other using requests and responses.
Types: REST (Representational state transfer) is an architectural
1. REST API pattern designed in 2000.
2. WebSocket API
1. It has no official standard at all because it is an architectural
style.
2. Works with multiple formats like : plain text, XML, HTML
and JSON (JavaScript Object Notation).

1. It does not need much bandwidth when requests are sent to


the server because REST deploys multiple standards and its
messages mostly just consist of JSON messages.
2. Implements the standard HTTP/HTTPS transport protocol
only.
3. It inherits security measures from the underlying transport.
4. Error handling occurs manually.
When to use REST ?
1.Limited resources and bandwidth .
2.When no need to keep the state of your data
as HTTP is a stateless protocol.
3.If there is a need to cache a lot of requests ,
By implementing a cache, the most frequent
queries results can be stored in an intermediate
location. So whenever the client requests for a
resource, it will first check the cache. If the
resources exist then, it will not proceed to the
server. So caching can help in minimizing the
amount of trips which are made to the web
server.
4.Easy way of coding.
WebSocket API:
1. Client-side API that allows a web browser to create a bidirectional communication
link with a server without having to change/reload the current page.
2. This protocol was standardized in 2011.
3. It relies on the IP address and portal number.
4. Stateful protocol, which means the connection between client and server will keep
alive until it is terminated by either party (client or server).
5. After closing the connection by either of the client or server, the connection is
terminated from both the end.
How WebSocket works ?

1.Client sends a regular HTTP request to the server , an upgrade header is included in this
request which informs the server that the client wishes to establish a WebSocket connection.

2.If the server supports the WebSocket protocol, it will agree to the upgrade and will
communicate this through the Upgrade header in the response.

3.Once the connection has been established, the initial HTTP connection is replaced by a
WebSocket connection that uses the same underlying TCP/IP connection. At this point, either
party can start sending data as they want until one of them ends the connection .
Python can communicate with external devices through serial communication using libraries
like pyserial, which allows for data exchange over serial ports.

For network communication, Python can use libraries such as socket to establish
connections and exchange data over TCP/IP or UDP protocols.

You might also like