Download as pdf or txt
Download as pdf or txt
You are on page 1of 71

UNIT III IOT PHYSICAL

DEVICES AND ENDPOINTS


Topics are….
• Introduction to Arduino and Raspberry Pi-

• Installation,

• Interfaces (serial, SPI, I2C),

• Programming –

• Python program with Raspberry PI with focus on interfacing external gadgets,

• controlling output, and

• reading input from pins.


• Arduino
• Arduino UNO is a microcontroller version of ATmega328p, it has 14 digital io
pins, 6 of which can be used for PWM output, 6 analog input pins, 32 kb flash
memory, 2 kb static memory, 1 kb live edge socket RAM, type b USB
connection, icsp connector and reset button.
• Only through the USB data connection, you can power the computer,
download the program and control the hardware by the data communication
software.
• Arduino has its own language based on classic C style, and the hardware
layer is written in high-level languages, so in terms of programming, Arduino
seems to be very simple, just needs to know one language like Java or C.
• When processing analog signals and digital signals, it is often necessary to
perform the proportional conversion, such as the conversion of angle to the
digital sensor.
Arduino UNO Pinout Description

• 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 HC-SR04 sensor is not a distance /


motion detector, but an ultrasonic
sensor.
• Through a small trick it is nevertheless
possible to measure distances.
• By measuring the time elapsed between
transmitting and receiving an ultrasound
signal, you can derive the distance as the
sound velocity in the air is known.
Magnetic Switch / Reed Relay
• By means of magnetic sensors / reed
relay, you can check for binary states.
• The magnetic relay is opened as soon as
a magnet is in the vicinity.
• Otherwise the access is closed. So if
voltage is then passed through, you can
check the condition.
In particular, these magnetic sensors are
suitable for inspecting windows and
doors by mounting them on the frame
and checking whether the door / window
is open or closed.
RFID-RC522 – Inductive RFID card
reader
• The RFID-RC522 is a card reader for
check cards.
• A signal is transmitted via the SPI data
bus as soon as a card approaches on a
few centimeters.
• Each card has a different code, which
you can read out.
• Thus, for example, locks and / or doors
could be realized, which open without
contact
Navigation modules
• GPS NEO-6M Module
• The most common and best known GPS
receiver is the NEO-6M module.
• All GPS position data can be determined
with the help of the orbiting satellites.
• In addition, it is compatible with the
Raspberry Pi packages “minicom” and
“gpsd”which makes reading the coordinates
very easy.
USB GPS Receiver
• As an alternative to GPS modules which
are connected via the GPIOs, USB GPS
receivers can also be used.
• Those have the advantage that (almost) all
are compatible with Windows, Linux and
Mac and no additional connection is
necessary.
• On the other hand, these modules are
usually more expensive, but they are not
inferior in terms of accuracy.
MPU-6050 Gyroscope
• A gyroscope (circular instrument)
is used to detect the rotation
along the three axes.
• The MPU 6050 sensor also
contains an acceleration sensor.
• This module can be used e.g. in
robot arms to determine the angle
of rotation.
HMC5883L / GY-271 Compass
• As with analogue compasses, the
directional display can also be read
digitally.
• The HMC5883L sensor, which is read
out via I2C, which returns an angle in
radians, is suitable for this purpose.
• As with a normal compass, the value
can be confounded by metal objects
nearby
• If the Raspberry Pi is connected to the Internet, it
DS1307 RTC can request the exact time.
• This could be a problem in applications where no
(permanent) Internet connection is given, but the
date and the exact time is important (car PC,
weather station, etc.).
• A so-called Realtime Clock (RTC) module can
help: Once initialized, it saves the current time –
even if the power supply is not present – due to
the small battery.
• On computer mainboards such a module is
installed, which is why the time of the computer
does not have to be re-adjusted every time you
restart.
• Since the Raspberry Pi / Arduino does not carry
an RTC module from within, this can be
retrofitted.
Raspberry Pi Sensors – Wireless / Infrared (IR) / Bluetooth
• 433 MHz Set
• One of the simplest method to
transmit signals via radio are 433
MHz transmitter and receiver.
• Since these sets are very cheap, they
are used in many projects.

• Many other devices work also with


433 MHz radio signals, such as
garage doors or radio controlled
outlets, and these codes can be
recorded and sent for specific tasks.
2.4 GHz NRF24L01+ Module
• A more advanced method for wireless
communication is the use of the 2.4 GHz
frequency.
• The advantages compared to the 433 MHz
transmission rate are mainly that a larger
amount of data can be transferred at once.
• Thus, whole sentences and commands can
be sent with a signal / data package.
• A second Raspberry Pi or an Arduino can
also be equipped with a 2.4 GHz receiver /
transmitter and thus receive commands
from a “base station” and send back data.
Radio controlled outlets / Power sockets
• In the field of home automation, wireless sockets are
almost a standard.
• The vast majority of these devices work with 433
MHz radio signals.
• By reading the codes of the remote control with a
receiver on the Raspberry Pi, one can switch these
radio sockets individually.

• There are different models, usually pure switchable


radio sockets, but also (dimmable) lamp sockets are
offered.
You should pay attention to one criterion: There are
models with a so-called “generic” code, i.e. on these
models the code is randomly generated and changes.
• These frequencies are hard to read out. On the other
hand, those sockets, in which the code is freely
selectable, are very easy to control.
Si4703 Radio receiver
• The Si470x module offers the option to
upgrade the Pi to a radio receiver,
which can be very interesting in Car
PCs or Raspberry Pi Jukeboxes.
• As with conventional radios, the
frequency and certain options can be
adjusted (via software).
• If that is not enough, you can also use
your Pi as a radio station.
Bluetooth Adapter & GSM Surfstick
Infrared diodes
• Most remote controls use infrared LEDs to
transmit signals.
• These codes can be read and stored easily with
an infrared receiver.
• With the program LIRC, it is also possible to
send those codes with an IR transmitter diode.
• For example, a TV can be controlled with the
Raspberry Pi.

In addition, there are also IR LEDs, which can
be used as a light barrier.
Laser Module
• Although standard laser modules do not have
great functionality (can be switched on and
off), they are used in various interesting
projects.
• Thus, for example, there are projects of
distance measuring devices, which are using
a camera and a laser module.
• The laser is switched on and off very quickly
and pictures are recorded.
• The distance can then be calculated by means
of the beam set.
• Due to the exchangeable mirrors at the head
of the laser modules, different patterns such
as grids are possible.
Motors- Servo Motors

• Unlike ordinary motors, servo


motors can be individually
controlled. Only the indication
of the angle of rotation for
moving the motor is necessary.
PWM (pulse width modulation)
signals are sent to the motor.
The Raspberry Pi can use this
method of transmission. Using
the Python GPIO library or
WiringPi is particularly easy.
28BYJ-48 Stepper Motor
• Step motors are motors that can “go”
a certain number of steps in one
revolution. Two electromagnets are
built in, which move the axis through
different poles. How the polarity
looks like is written in the data sheet
of the motor.
One of the most popular stepping
motors (because it has a lot of steps
and is nevertheless cheap) is the
model 28BYJ-48. This motor has 512
steps, each step consisting of 8
sequences. This means that a full
revolution has 4096 steps (or one
step is made per 0.087°).
PCA9685 Servo Board
• Using PWM, servos can be controlled
directly from the Raspberry Pi.
• However, as soon as you want to control
several servo motors, either the GPIOs can
become scarce, or you need more power.
• The PCA9685 servo driver board is ideally
suited for this purpose because you can
control up to 16 motors per board via I2C.
• And not enough. It is even possible to
connect several boards one after the other.
• In addition, an external power supply can
be easily connected.
• If you want to use a robot arm, for
example, this is the optimal board.
A4988

• This IC is another way to control step


motors.
• It is especially designed for motors in 3D
printers and can withstand voltages of
8V to 35V with a current of one amp.
• Since it can get hot very quickly, a
cooling sink is included on the chip of
the breakout board.
Analogous Raspberry Pi Sensors
• MCP3008 Analog-to-digital converter
• Unlike the Arduino, the Raspberry Pi
does not have its own analog IO pins.
• This means that you can not simply read
out analog modules.
• The MCP3008 module helps you: It
makes it possible to use analog modules
with the Raspberry Pi and therefore this
digital converter is required for all analog
modules on the Raspberry Pi.
Joystick
• One of these analog modules is a 2-axis
joystick.
• Two potentiometers (see below) for X
and Y axes are installed, which allow
more or less voltage to pass through the
movement.
• If one converts the analog value into a
digital, one gets numbers between 0 (no
voltage) and 1023 (full voltage).
• In the center, a digital value of approx.
512 is returned on both axes.
Potentiometer / Rotary Switch
• Potentiometers are basically rotatable
resistors.
• You can change the resistor value easily
by rotating the control knob.
• Each module has a maximum resistance
(minimum is zero).
• In addition to joysticks, potentiometers
can also be found e.g. in brightness or
volume controllers.
Raindrop Sensor
• In order to determine whether
it is raining or how much rain is
present, a rainwater sensor can
be used.
• It works analogously and can
be read with the MCP3008.
• Depending on the amount of
water, the capacitance is
increased and a stronger
analog signal is read out.
Heartbeat / Pulse Sensor
• With a pulse sensor, the heart
rate can be read out on the
Raspberry Pi.
• The analogously detected
value changes, depending on
the pulse beat.
• This is again converted with
an ADC and the pulse is
determined on the basis of
the last measured values.
Power / Current Supply
• The GPIOs of the Raspberry Pi work
with 3.3V, although it also has a 5V pin.
• However, many devices require a higher
voltage.
• In order not to combine the circuits, one
can use relays, which are basically
switches.
• This has the advantage that you can also
switch circuits with higher voltages with
the Raspberry Pi, without risking
something.
Interfaces (serial, SPI, I2C)
• In an embedded system, communication plays an important role.
• Peripheral expansion is a high-power-consuming and highly complex system
without knowing the communication protocols.
• All of the embedded systems make use of serial communication interfaces to
communicate with the peripherals.
• Among them, the most common communication protocols in microcontroller
development are SPI, UART, and IC2.
• These protocols have the significant benefits of low data loss and high speed.
Interfaces (serial, SPI, I2C)
• In Serial communication Signals are generated and transmitted on a
single wire by repeatedly shorting two conductors together.
• This short acts like a switch; it turns on (high) and off (low),
providing binary signals.
• How this signal is transmitted and received will depend on the type
of serial communication protocol used.
• serial protocols such as UART, I2C, and SPI.
• these serial protocols are several decades old, they are still preferred
for microcontrollers and bare-metal programming.
• Why Serial Communications Are Here to Stay
• With the rise of parallel and many wireless protocols, serial communications
have never fallen out of popularity. Generally using only two to four wires for
transmitting and receiving data, serial protocols are an essential mode of
communication for electronics that only have a few ports to spare.
• Another reason is its simplicity which translates to reliability. With only a few
wires sending data once at a time, serial has proven its reliability to send the
complete packets of data without any loss or corruption when transmitted.
Even at high frequencies and longer range communication, serial protocols
still beat many modern parallel communications protocols available today.
• Although many might think that serial communications like UART, SPI, and
I2C have the disadvantage of being old and outdated, the fact remains that
they have proven their reliability over several decades. Protocols being this
old without any real replacement only suggests that they are, in fact,
indispensable and will continue to be used in electronics for the foreseeable
future.
• UART (Universal Asynchronous Receiver-Transmitter)
• The UART protocol is one of the oldest yet most reliable serial
communication protocols we still use today.
• This protocol uses two wires known as Tx (transmit) and Rx (Receive)
for both components to communicate.
• To transmit data, both the transmitter and the receiver must agree with
five common configurations, these are:
• Baud Speed: The transmission speed of how fast data is to be transmitted.
• Data Length: The agreed number of bits that the receiver will save into its
registers.
• Start Bit: A low signal that lets the receiver know when data is about to be
transferred.
• Stop Bit: A high signal that lets the receiver know when the last bit (most
significant bit) has been sent.
• Parity Bit: Either a high or low signal used for checking if data sent was correct
or corrupted.
• Since UART is an asynchronous protocol, it doesn’t have its own clock that
regulates data transmission speed.
• As an alternative, it does utilize baud rate for timing when a bit is being
transmitted.
• The usual baud rate used for UART is 9600 baud, meaning a transmission
rate of 9600 bits per second.
• If we do the math and divide one bit by 9600 baud, we can calculate how fast
one bit of data is transmitted to the receiver.
• 1/9600 = 104 microseconds
• This means that our UART devices will start counting 104microseconds to
know when the next bit will transmit.
• When UART devices have been connected, the default signal is always
raised to high.
• When it detects a low-frequency signal, the receiver will start counting
104 microseconds plus another 52 microseconds before it starts
saving the bits into its registers (memory).
• Since it was already agreed upon that eight bits was to be data length,
once it saved eight bits of data, it will start checking for parity to check
if data is odd or even.
• After the parity check, the stop bit will raise a high signal to notify the
devices that the entire eight bits of data was successfully transmitted
to the receiver.
• Being the most minimalist serial protocol utilizing only two wires,
UART is commonly used today in smart cards, SIM cards, and
automobiles.
• SPI (Serial Peripheral Interface)
• SPI is another popular serial protocol used for faster data rates of about
20Mbps.
• It uses a total of four wires, namely SCK (Serial Clock Line), MISO (Master In
Slave Out), MOSI (Master Out Slave In), and SS/CS (Chip Select).
• Unlike UART, SPI uses a master-to-slave format to control multiple slave
devices with only one master.
• MISO and MOSI act like the Tx and Rx of UART being used to transmit and receive data.
• Chip Select is used for selecting which slave the master wants to communicate with.
• Since SPI is a synchronous protocol, it uses a built-in clock from the master to
ensure both the master and slave devices are running on the same frequency.
• This means that the two devices no longer need to negotiate a baud rate.
• The protocol starts with the master selecting the slave device by lowering its
signal to the specific SS/CK connected to the slave device.
• When the slave receives a low signal, it starts to listen to both the SCK and
MOSI.
• The master then sends a start bit before sending the bits that contain data.
• Both MOSI and MISO are full-duplex, meaning they can transmit and receive
data at the same time.
• With its ability to connect to multiple slaves, full-duplex communication, and
lower power consumption than other synchronous protocols like I2C, SPI is
used in memory devices, digital memory cards, ADC to DAC converters, and
crystal memory displays.
• SPI supports two communication interfaces modes; point-to-point and
standard mode.
• In point-to-point mode, a single controller follows the single slave, while in
standards mode, a single master controller can communicate with two slave
devices enabling the select chip lines.
• SPI Working Principle
• Two methods define the SPI working:
• The first method selects each device using the CS, which is the select chip
line.
• Each of these devices needs the unique Chip Select line.
• The second method is daisy chaining.
• In this method, each device is connected to the other via the data out of one
to the data in line or another.
• Pros and Cons
• Pros
• Supports full duplex communication
• Simple and fast data transmission rate
• Offers simple software implications
• No, start and stop bits allow continuous data transmission with no interruptions
• MOSI and MISO allow the simultaneous data send and receive operation
• The use of a master clock doesn't require the precious oscillators
• Cons
• More use of slave devices complicates the wiring.
• It has a single master device
• Limits the number of slave's devices to connect with the Master
• No error check mechanism
• Don't have an acknowledgment line of data receiving a message
• I2C (Inter-Integrated Circuit)
• I2C is yet another synchronous serial protocol like SPI, but with several
advantages over it.
• These include the ability to have multiple masters and slaves, simple
addressing (no need for Chip Select), operating with various voltages, and
using only two wires connected to two pull-up resistors.
• I2C is often used in many IoT devices, industrial equipment, and consumer
electronics.
• The two pins in an I2C protocol are the SDA (Serial Data Line) which transmits
and receives data, and the SCL (Serial Clock Line) pin, which functions as a
clock.
Working Principle of I2C

• 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 –

• Python program with Raspberry PI with focus on interfacing external


gadgets, controlling output, and reading input from pins.
• #This program is used to ON / OFF the RGB LEDs in a regular interval of time.

• #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

• from digitalio import Direction, Pull

• from adafruit_mcp230xx.mcp23017 import MCP23017


import board
• Arduino
• Before compiling in the Arduino IDE, you
select which board you're using.
• That basically tells the compiler
information it needs to compile
specifically for the MCU and configuration
of that specific board.
• OS knows what board it's running on, and it knows what the
capabilities of that board are, and it knows what the pins on
that board are and what they can do.

• 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

You might also like