OPEN PLATFORMS(Like Raspberry Pi)
Raspberry-Pi Architecture
Raspberry pi is the name of the “credit card-sized computer board
Raspberry Pi is a small single-board computer (SBC).
It is a credit card-sized computer that can be plugged into a monitor.
It acts as a minicomputer by connecting the keyboard, mouse, and
display.
Raspberry Pi has an ARM processor and 512MB of RAM.
Used:
It also provides a set of general purpose input/output pins allowing you to control
electronic components for physical computing and explore the Internet of Things .
The architecture of Raspberry Pi:
main blocks of Raspberry Pi:
Raspberry Pi mainly consists of the following blocks:
Processor: Raspberry Pi uses Broadcom BCM2835 system on chip which is an ARM
processor and Video core Graphics Processing Unit (GPU). It is the heart of the
Raspberry Pi which controls the operations of all the connected devices and handles
all the required computations.
HDMI: High Definition Multimedia Interface is used for transmitting video or digital
audio data to a computer monitor or to digital TV. This HDMI port helps Raspberry Pi
to connect its signals to any digital device such as a monitor digital TV or display
through an HDMI cable.
GPIO ports: General Purpose Input Output ports are available on Raspberry Pi which
allows the user to interface various I/P devices.
Audio output: An audio connector is available for connecting audio output devices
such as headphones and speakers.
USB ports: This is a common port available for various peripherals such as a mouse,
keyboard, or any other I/P device. With the help of a USB port, the system can be
expanded by connecting more peripherals.
SD card: The SD card slot is available on Raspberry Pi. An SD card with an operating
system installed is required for booting the device.
Ethernet: The ethernet connector allows access to the wired network, it is available
only on the model B of Raspberry Pi.
Power supply: A micro USB power connector is available onto which a 5V power
supply can be connected.
Camera module: Camera Serial Interface (CSI) connects the Broadcom processor to
the Pi camera.
Display: Display Serial Interface (DSI) is used for connecting LCD to Raspberry Pi
using 15 15-pin ribbon cables. DSI provides a high-resolution display interface that is
specifically used for sending video data.
RASPBERRY PI PROGRAMMING
programs can be run on the Raspberry Pi using its Raspbian operating system.
Scratch is a graphical block-based programming environment designed for kids to learn
programming skills without having to type or learn the syntax of a programming language.
The "hello world" for Scratch is simple—and very visual!
1. Open Scratch 2 from the main menu
2. Click Looks.
3.Drag a say Hello! block into the workspace on the right.
4.Change the text to Hello world.
5. Click on the block to run the code
USING PYTHON:
1. Open Thonny Python IDE from the main menu.
2. Enter the following code:
Print(“hello world”)
3. Save the file as hello3.py.
4. Click the Run button
EXAMPLE PROGRAMMING:
import serial
import RPi.GPIO as GPIO
import time
ser=serial.Serial("/dev/ttyACM0",9600) #change ACM number as found from ls /dev/tty/ACM*
ser.baudrate=9600
def blink(pin):
GPIO.output(pin,GPIO.HIGH) time.sleep(1)
GPIO.output(pin,GPIO.LOW) time.sleep(1)
return
GPIO.setmode(GPIO.BOARD) GPIO.setup(11, GPIO.OUT)
while True:
read_ser=ser.readline() print(read_ser)
if(read_ser=="Hello From Arduino!"):
blink(11)
Now open Arduino IDE and upload the following code to your Arduino. String data="Hello From
Arduino!";
void setup()
// put your setup code here, to run once: Serial.begin(9600);
void loop()
{
// put your main code here, to run repeatedly: Serial.println(data);//data that is being Sent
delay(200);
RASPBERRY PI INTERFACES
Raspberry pi has Serial, SPI and I2C interfaces for data transfer.
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. in an SPI connection, there are five
pins on Raspberry Pi for SPI interface :
MISO (Master in slave out) – Master line for sending data to the peripherals.
MOSI (Master out slave in) – Slave line for sending data to the master.
SCK (Serial Clock) – Clock generated by master to synchronize data transmission
CE0 (Chip Enable 0) – To enable or disable devices
CE0 (Chip Enable 1) – To enable or disable 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) an SCL
(Clock Line).
SPI SCHEME:
EXAMPLE: Control LED using Raspberry Pi Interfacing Diagram
RASPBERRY PI 3 MODEL B GPIO PIN MAPPING
SENDING AND RECEIVING SIGNALS USING GPIO PINS:
There are four main kinds of pin:
Power: These provide DC power at 3.3 and 5 volts
Ground (GND): These connect to ground, to close your circuit
DNC: This stands for “do not connect”, so don’t worry about them
GPIO: These can be set to either send, or receive control voltages
Connecting Your GPIO Pins to a Breadboard
GPIO Pins With Special Uses
Serial Bus Pins
Pull Up and Pull Down Resistors
Using Software to Control GPIO Pins
Connecting and Testing the LED
GPIO Pins With Special Uses
Ground pins, Power pins, Reserved pins
The GPIO pins allow the Raspberry Pi to control and monitor the outside world by
being connected to electronic circuits. The Pi is able to control LEDs, turning them on or off,
run motors, and many other things. It's also able to detect whether a switch has been
pressed, the temperature, and light.
GPIO pins in an IoT device:
Gpio namespace to allow apps to set, read, and react to state changes in the General
Purpose Input/Output (GPIO) pins on a Windows IoT (Internet of Things) device. These
pins are often used to access sensors, motors, LEDs, etc
SERIAL BUS PINS
The serial function is available at the following −
TX(GPIO14)
RX(GPIO15)
Serial RX :This pin doubles up as the UART receive pin, RX. It's also commonly known as
"Serial" and, by default, will output a Console from your Pi that, with a suitable Serial cable,
can use to control the Pi via the command-line.
Serial TX :This pin doubles up as the UART transmit pin, TX. It's also commonly known as
"Serial" and, by default, will output a Console from your Pi that, with a suitable Serial cable,
use to control the Pi via the command-line.
PULL UP AND PULL DOWN RESISTORS
Pull-up Resistor: A pull-up resistor connects the GPIO pin to the supply voltage (Vcc
or +5V) through a resistor. ...
Pull-down Resistor: Conversely, a pull-down resistor connects the GPIO pin to
ground (GND) through a resistor.
USING SOFTWARE TO CONTROL GPIO PINS
Once we have configured the GPIO pins, we can start controlling them using Python
code. There are two main functions that we can use to control the GPIO pins:
GPIO.output() and GPIO.input().
The GPIO.output() function is used to set the state of an output GPIO pin. The function
takes two arguments: the GPIO pin number and the state (either GPIO.HIGH or
GPIO.LOW).
Here's an example of how to set GPIO pin 18 to HIGH:
GPIO.output(18, GPIO.HIGH)
The GPIO.input() function is used to read the state of an input GPIO pin. The function takes one
argument: the GPIO pin number.
Here's an example of how to read the state of GPIO pin 17:
state = GPIO.input(17)
CONNECTING AND TESTING THE LED
code to switch the LED on. Turn on your Raspberry Pi and open the terminal
window.
Create a new text file “LED.py” by typing the following:
nano LED.py
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(18,GPIO.OUT)
print "LED on"
GPIO.output(18,GPIO.HIGH)
time.sleep(1)
print "LED off"
GPIO.output(18,GPIO.LOW)