Professional Documents
Culture Documents
IOT UNIT 2 Part 2
IOT UNIT 2 Part 2
1. Sensing: Sensors can be either on-board the IoT device or attached to the
device.
2. Actuation: IoT devices can have various types of actuators attached that
allow taking actions upon the physical entities in the vicinity of the device
3. Communication: Communication modules are responsible for sending
collected data to other devices or cloud-based servers/storage and
receiving data from other devices and commands from remote
applications
4. Analysis & Processing: Analysis and processing modules are responsible
for making sense of the collected data.
Introduction to raspberry pi
• Raspberry pi is developed in UK by Raspberry pi foundation to promote
the teaching of basic computer science inschools and developing
countries.
• Raspberry pi is micro processor that can be plugged into a computer.
• It is also called as SOC(System on chip)
• It is similar to general purpose computer.
• It can perform all operations from browsing the internet ,playing high-
definition video, to making spreadsheets, word-processing, and playing
games like compter.
• It runs on its own operating system(Raspbian).
• It supports all operatin systems(windows,ubuntu,firefox os,pidora etc).
• An SD card inserted into the slot on the board to host the operating system.
• Rpi has no internal storage and it does not have hard drive or inbuilt memory
card.we need to insert SD card or memory card.
• The Raspberry Pi is a low cost, credit-card sized computer.
• It is a capable little device that enables people of all ages to explore
computing, and to learn how to program in languages like Scratch and Python.
• Raspberry Pi has the ability to interact with the outside world.
• It consumes very less power(less than 5W)
How does Raspberry Pi work?
• Serial(UART)
• I2C
• SPI
Parallel and serial communication(01000011)
• Raspberry pi has Serial, SPI and I2C interfaces for data transfer.
• Serial(UART) :
• Universal Asynchronous receiver/transmitter
• It is a serial communication protocol in which data is transferred serially i.e
bit by bit.
• Asynchronous communication is widely used for byte oriented transmission
• The Serial interface on Raspberry Pi has receive (Rx) and transmit (Tx) pins
for communication with serial peripherals.
• Data flows from the Tx pin of the transmitting UART to the Rx pin of the
receiving UART:
• In asynchronous serial communication byte of data is ransferred at a time.
UART Data frame
• SS/CS (Slave Select/Chip Select) – Line for the master to select which slave to send data to.
• Chip enable 0(ch0)
• Chip enable 1(ch1)
SPI
SPI
• One unique benefit of SPI is the fact that data can be
transferred without interruption. Any number of bits can be sent or
received in a continuous stream.
• With I2C and UART, data is sent in packets, limited to a specific
number of bits. Start and stop conditions define the beginning and
end of each packet, so the data is interrupted during transmission.
I2C
• With I2C, data is transferred in messages. Messages are broken up into frames of data. Each message has
an address frame that contains the binary address of the slave, and one or more data frames that contain
the data being transmitted. The message also includes start and stop conditions, read/write bits, and
ACK/NACK bits between each data frame:
• Start Condition: The SDA line switches from a high voltage level to a low voltage level before the SCL line
switches from high to low.
• Stop Condition: The SDA line switches from a low voltage level to a high voltage level after the SCL line
switches from low to high.
• Address Frame: A 7 or 10 bit sequence unique to each slave that identifies the slave when the master
wants to talk to it.
• Read/Write Bit: A single bit specifying whether the master is sending data to the slave (low voltage level)
or requesting data from it (high voltage level).
• ACK/NACK Bit: Each frame in a message is followed by an acknowledge/no-acknowledge bit. If an address
frame or data frame was successfully received, an ACK bit is returned to the sender from the receiving
device.
I2C message format
Controllin LED
Requirement:s
Raspberry pi
LED
100 ohm resistor
Bread board
Jumper cables
Blinking LED (contd..)
Installing GPIO library:
Open terminal
Enter the command “sudo apt-get install python-dev” to install
python development
Enter the command “sudo apt-get install python-rpi.gpio” to install
GPIO library.
Blinking LED (contd..)
Connection:
Connect the negative terminal
of the LED to the ground pin of
Pi
Connect the positive terminal
of the LED to the output pin of
Pi
Blinking LED (contd..)
Basic python coding: