Unit III Iot Physical Devices and Endpoints
Unit III Iot Physical Devices and Endpoints
• Installation,
• Programming –
• The Arduino UNO board is divided into digital pins, analog pins
and power pins. There are pins with secondary functions as
listed below. Secondary pins are mostly communications pins
such as I2C and SPI.
Digital Pins
Pin Name Description Secondary Function Description
D0 Digital Pin 0 RX Receive pin for Serial UART
D1 Digital Pin 1 TX Transmit pin for Serial UART
D2 Digital Pin 2 INT0 Interrupt Pin 0
D3 Digital Pin 3 INT1 Interrupt Pin 1
D4 Digital Pin 4
D5 Digital Pin 5
D6 Digital Pin 6
D7 Digital Pin 7
D8 Digital Pin 8
D9 Digital Pin 9
D10 Digital Pin 10 SS SPI Slave Select Pin
D11 Digital Pin 11 MOSI SPI Master Out-Slave In
D12 Digital Pin 12 MISO SPI Master In-Slave Out
D13 Digital Pin 13 SCK SPI Clock
Analog Pins
Pin Name Description Secondary Function Description
A0 Analog Pin 0
A1 Analog Pin 1
A2 Analog Pin 2
A3 Analog Pin 3
A4 Analog Pin 4 SDA I2C Data Out
A5 Analog Pin 5 SCL I2C Clock
Power Pins
Pin Name Description
5V 5V (Regulated) Source
3.3V 3.3V Source
GND Ground
RESET Reset
Vin DC Jack Input Voltage
IOREF I/O Reference Voltage. This pin is connected to 5V for the UNO
AREF ADC Reference Voltage. Insert other voltage (0-5V only) to use as
reference for analog conversions
• Raspberry Pi
• Raspberry Pi is a small but complete mini processing system that generally has the
following configuration.
1.1.5G Hz 4-core
2.64-bit
3.ARMCortex A72 CPU
4.Wifi Bluetooth communication module
5.4 USB ports
6.Two 2.0 and two 3.0 ports
7.A network card interface
8.An audio interface
9.A camera interface
10.2 HDMI display interface
11.Memory card
12.Microcontroller of course
• Raspberry Pi operating system based on Linux Debian system. The 40 GPIO pins of
the device are used to connect with various peripheral sensors and hardware. The
memory configuration ranges from 2g, 4g, and 8g.
most important Sensors and Components of
Raspberry Pi & Arduino boards
• modules and components are divided into the following categories:
• Temperature / Humidity / Air Pressure / Gas
• Motion Sensors
• Navigation Modules
• Wireless / Infrared (IR) / Bluetooth
• Motors
• Analogue Sensors
• Current Supply
• Displays
• Other Modules, Components and Sensors
Temperature / Humidity / Air Pressure / Gas
The DHT11 and DHT22 sensors can measure
humidity as well as temperature.
Only one GPIO is used.
The difference between the two is mainly the
measuring range and accuracy.
The white DHT22 can measure all humidity
ranges from 0-100% with an accuracy of 2%.
By comparison, the DHT11 (blue) is only able to
measure areas of 20-90% humidity
DS18B20 and DS18S20
• The DS18B20 and DS18S20 represents a very
simple sensor.
• These Raspberry Pi sensors are addressed via the
so-called 1-wire bus.
• An advantage is that many different 1-wire
components can be connected in series and read out
by a single GPIO.
• However, these modules can not measure additional
information such as humidity and / or air pressure.
• The DS18B20 is particularly suitable for outdoor
use, as there are also water resistant versions
available.
• With a measuring range of -55°C to +125°C
BMP180 Barometer
• The determination of the air pressure can be
meaningful in weather stations and similar
projects.
• This is best done using the BMP180, which is
controlled via I2C on the Raspberry Pi.
• In addition to the air pressure, the temperature
can be read out as well as the altitude.
• However, the last value is not very accurate.
• If you need the height, you should read the values
with a GPS receiver.
Moisture Sensor
• This analogue humidity sensor finds an
excellent place in automatic irrigation systems.
• It is placed in the ground and measures the
humidity by current flowing between the
strands.
• The more humid the earth in between, the
higher the (analog) signal.
• In order to read the value with the Raspberry
Pi, the MCP3008 is needed (Arduinos can
recognize analog signals directly).
MQ-2 Gas Sensor
• The MQ gas sensors can detect different
gases at room temperature.
• Depending on the model, other gases are
supported.
• The MQ-2 can recognize methane, butane,
LPG and smoke, the MQ3 detects, for
example, alcohol, ethanol and smoke, etc.
• You should take care that these sensors can
be very hot and they should not be touched
directly.
• Since these modules also work analogically
with 5V, you need also a MCP3008 as well as
a 3.3V-5V TTL to read the signals.
• There are many different sensors for the • MQ-138 (Benzene, Toluene, Alcohol,
Raspberry Pi, which are already available Acetone, Propane, Formaldehyde
for a few bucks and are suitable for gas): US* / UK*
different gases: • MQ-214 (Methane, Natural gas): US* / UK*
• MQ-2 (Methane, Butane, LPG, • MQ-216 (Natural gas, Coal gas): US* / UK*
smoke): US* / UK*
• MQ-3 (Alcohol, Ethanol, smoke): US* / UK* • MQ-303A (Alcohol, Ethanol,
smoke): US* / UK*
• MQ-4 (Methane, CNG Gas): US* / UK* • MQ-306A (LPG, butane gas): US* / UK*
• MQ-5 (Natural gas, LPG): US* / UK* • MQ-307A (Carbon Monoxide): US* / UK*
• MQ-6 (LPG, butane gas): US* / UK* • MQ-309A (Carbon Monoxide, flammable
• MQ-7 (Carbon Monoxide): US* / UK* gasses): US* / UK*
• MQ-8 (Hydrogen Gas): US* / UK* • MG811 (Carbon Dioxide (CO2)): US* / UK*
• MQ-9 (Carbon Monoxide, flammable • AQ-104 (air quality): US* / UK*
gasses): US* / UK* • AQ-2 (Flamable gasses, smoke): US* / UK*
• MQ-131 (Ozone): US* / UK* • AQ-3 (Alcohol, Benzine): US* / UK*
• MQ-135 (Benzene, Alcohol, • AQ-7 (Carbon Monoxide): US* / UK*
smoke): US* / UK*
• MQ-136 (Hydrogen Sulfide gas): US* / UK*
• MQ-137 (Ammonia): US* / UK*
Motion Sensor
• These Raspberry Pi sensors can be used to detect
motion
• PIR Motion Sensor
• The PIR motion sensor has some advantages over
other similar products: besides the low price, a
signal is sent only if something moves.
• This allows you to wait for signal flanks using the
GPIOs. In addition, a resistance can be varied so
that a signal is only sent when the movement is
close, or changes that are already far away are
perceived.
In addition to outdoor projects, the PIR can also be
used in buildings – whether to activate the lighting
HC-SR04 ultrasonic sensor
• The master device transmits the data and thus generates the clock signal.
• This clock signal opens the transferred device, and any address devices are considered
slave devices.
• On the bus, master and slave devices, transmission and reception, do not always
follow the same relationship.
• Data transfer direction depends on the time.
• The Master must address the slave before sending data to the slave if it wants to send
data to the slave.
• This will stop the data transfer. At the same time, the Master should address the slave
if it wants to receive the data from the slave devices.
• Finally, the receiver terminates the receiving process by receiving the data sent by the
slave.
1.The protocol starts with the master sending a start bit (low) from its SDA pin,
followed by a seven-bit address that selects the slave, and one bit to for selecting
read or write.
2.After receiving the start bit and address, the slave then sends an acknowledge bit to
the master and starts listening to the SCL and SDA for incoming transmissions.
3.Once the master receives this, it knows the connection has been made to the
correct slave. The master will now select which specific register (memory) from the
slave it wants to access. It does so by sending another eight bits specifying which
register is to be used.
4.Upon receiving the address, the slave now readies the select register before
sending another acknowledge to the master.
5.Having selected which specific slave and which of its registers to use, the master
finally sends the data bit to the slave.
6.After the data is sent, a final Acknowledge bit is sent to the master before the
master ends with a stop bit (high).
• Pros and Cons
• Pros
• It supports various master devices.
• It offers multi-slave and multi-master communication.
• This protocol is flexible and adaptable too.
• Cons
• I2C is a bit slower protocol because of the need for pull-up resistors.
• It takes more space
• The architecture is more complex with the increasing number of devices.
• This protocol is half-duplex, which is quite problematic and requires different devices for
complete communication.
• Programming –
• #Here the RGB LEDs are connected to MCP23017 IC in the ETS IoT KIT
• import sys # used to show, how the python script is interacting with host system?
• sys.path.append('/home/pi/Adafruit-Raspberry-Pi-Python-Code-legacy/Adafruit_CircuitPython_MCP230xx-
main') # LIBRARY
• import time # module allows you to work with all time-related functions
• import board
• import busio
• To make this available, there is the board module that you can
import. This module contains constants for the pins on the
specific board.
• import busio # module contains classes to support a variety of
serial protocols.
• The board knows how to ‘speak’ the serial protocols and control
the connected hardware.
direction:Direction
• The direction of the pin.
• Setting this will use the defaults from the corresponding
switch_to_input or switch_to_output method.
• If you want to set pull, value or drive mode prior to switching,
then use those methods instead.
Web References
• https://www.engineersgarage.com/comparison-between-serial-
communication-protocols-spi-i2c-usart/
• https://tutorials-raspberrypi.com/raspberry-pi-measure-humidity-
temperature-dht11-dht22/
• 50 of the most important Raspberry Pi Sensors and Components
(tutorials-raspberrypi.com)
• https://www.raspberrypi.com/documentation/computers/getting-
started.html#installing-the-operating-system
• https://gpiozero.readthedocs.io/en/stable/
• gpiozero — GPIO Zero 1.6.2 Documentation
• https://www.circuitbasics.com/introduction-to-the-raspberry-pi/
• https://seascf.seas.gwu.edu/sites/g/files/zaxdzs1506/f/downloads/George
%20Hacks%20Medical%20Devices%20Presentation.pdf
• https://tutorials-raspberrypi.com/esp32-cam-livestream-tutorial-camera-
module-for-the-esp8266/
• https://tutorials-raspberrypi.com/raspberry-pi-traffic-light-circuit-gpio-
part-1/
• https://tutorials-raspberrypi.com/raspberry-pi-traffic-light-circuit-gpio-
part-2/
• https://gpiozero.readthedocs.io/en/stable/recipes.html
• 2. Basic Recipes — GPIO Zero 1.6.2 Documentation