0% found this document useful (0 votes)
11 views66 pages

Lab 06 - RPi and Building LoRa Gateway

The document provides an overview of the Raspberry Pi, a series of small single-board computers designed to promote computer science education. It details the development history, various models, features, hardware specifications, performance, operating systems, and community engagement surrounding the Raspberry Pi. Additionally, it includes information on installation, user interface, networking, and peripheral compatibility.

Uploaded by

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

Lab 06 - RPi and Building LoRa Gateway

The document provides an overview of the Raspberry Pi, a series of small single-board computers designed to promote computer science education. It details the development history, various models, features, hardware specifications, performance, operating systems, and community engagement surrounding the Raspberry Pi. Additionally, it includes information on installation, user interface, networking, and peripheral compatibility.

Uploaded by

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

Introduction to Raspberry Pi

Tushar B. Kute,
Edited Tran The Son
https://www.researchgate.net/profile/Tran-
The-Son
What is Raspberry Pi?
• The Raspberry Pi is a series of small single-board
computers developed in the United Kingdom by the
Raspberry Pi Foundation to promote the teaching
of basic computer science in schools and in
developing countries.
• The original model became far more popular than
anticipated, selling outside of its target market for
uses such as robotics.
• Over 5 million Raspberry Pis have been sold before
February 2015, making it the best-selling British
computer. By November 2016 they had sold 11
million units.
Raspberry Pi Sale
Raspberry Pi 3 Model B
Raspberry Pi 4 Model B

CPU mạnh hơn


Hỗ trợ chuẩn USB 3.0.
RAM DDR4 thay vì DDR2 như cũ.
Cổng mạng Ethernet Gigabit
Có 2 cổng ra màn hình với độ phân
giải 4K.
Nguồn điện yêu cầu 5V – 3A thay vì
5V 2.5A như cũ
Bluetooth nâng cấp từ phiên bản 4.0
lên 5.0
The Timeline
• The first generation (Raspberry Pi 1 Model B) was released
in February 2012. It was followed by a simpler and
inexpensive model Model A.
• In 2014, the foundation released a board with an
improved design in Raspberry Pi 1 Model B+. These
boards are approximately credit-card sized and represent
the standard mainline form-factor.
• Improved A+ and B+ models were released a year later. A
"compute module" was released in April 2014 for embedded
applications, and a Raspberry Pi Zero with smaller size and
reduced input/output (I/O) and general-purpose
input/output (GPIO) capabilities was released in November
2015 for US$5.
The Timeline
• The Raspberry Pi 2 which added more RAM was released
in February 2015.
• Raspberry Pi 3 Model B released in February 2016,
is bundled with on-board WiFi, Bluetooth and USB
boot capabilities.
• As of January 2017, Raspberry Pi 3 Model B is the
newest mainline Raspberry Pi.
• Raspberry Pi boards are priced between US$5–35.
• As of 28 February 2017, the Raspberry Pi Zero W was
launched, which is identical to the Raspberry Pi Zero, but
has the Wi-Fi and Bluetooth functionality of the
Raspberry Pi 3 for US$10.
Features

• All models feature a Broadcom system on a


chip (SoC), which includes an ARM compatible
central processing unit (CPU) and an on-chip
graphics processing unit (GPU, a VideoCore IV).
• CPU speed ranges from 700 MHz to 1.2 GHz
for the Pi 3 and on board memory range from
256 MB to 1 GB RAM.
• Secure Digital (SD) cards are used to store the
operating system and program memory in
either the SDHC or MicroSDHC sizes.
Features

• Most boards have between one and four


USB slots, HDMI and composite video
output, and a 3.5 mm phono jack for
audio.
• Lower level output is provided by a
number of GPIO pins which support
common protocols like I²C.
• The B-models have an 8P8C Ethernet
port and the Pi 3 and Pi Zero W have on
board Wi-Fi 802.11n and Bluetooth.
Hardware
Hardware

• This block diagram depicts Models A, B, A+, and B+.


Model A, A+, and the Pi Zero lack the Ethernet and USB
hub components.
• The Ethernet adapter is internally connected to
an additional USB port.
• In Model A, A+, and the Pi Zero, the USB port is
connected directly to the system on a chip (SoC). On the
Pi 1 Model B+ and later models the USB/Ethernet chip
contains a five- point USB hub, of which four ports are
available, while the Pi 1 Model B only provides two.
• On the Pi Zero, the USB port is also connected directly
to the SoC, but it uses a micro USB (OTG) port.
Processor
• The Broadcom BCM2835 SoC used in the first generation
Raspberry Pi is somewhat equivalent to the chip used in first
modern generation smartphones (its CPU is an older ARMv6
architecture), which includes a 700 MHz ARM1176JZF-S processor,
VideoCore IV graphics processing unit (GPU), and RAM.
• It has a level 1 (L1) cache of 16 KB and a level 2 (L2) cache of 128
KB. The level 2 cache is used primarily by the GPU. The SoC is
stacked underneath the RAM chip, so only its edge is visible.
• The Raspberry Pi 2 uses a Broadcom BCM2836 SoC with a 900
MHz 32-bit quad-core ARM Cortex-A7 processor, with 256 KB
shared L2 cache.
• The Raspberry Pi 3 uses a Broadcom BCM2837 SoC with a 1.2 GHz
64-bit quad-core ARM Cortex-A53 processor, with 512 KB shared
L2 cache
Performance
• The Raspberry Pi 3, with a quad-core Cortex-A53
processor, is described as 10 times the performance of a
Raspberry Pi
1.This was suggested to be highly dependent upon task
threading and instruction set use. Benchmarks showed
the Raspberry Pi 3 to be approximately 80% faster than
the Raspberry Pi 2 in parallelized tasks.
• Raspberry Pi 2 includes a quad-core Cortex-A7 CPU
running at 900 MHz and 1 GB RAM. It is described as 4–6
times more powerful than its predecessor. The GPU is
identical to the original. In parallelized benchmarks, the
Raspberry Pi 2 could be up to 14 times faster than a
Raspberry Pi 1 Model B+.
Operating Systems
Operating System

• The Foundation provides Raspbian, a Debian-


based Linux distribution for download, as
well as third party Ubuntu, Windows 10 IOT
Core, RISC OS, and specialised media center
distributions.
• It promotes Python and Scratch as the main
programming language, with support for
many other languages.
• The default firmware is closed source, while
an unofficial open source is available.
Operating Systems

• The Raspberry Pi Foundation


recommends the use of Raspbian, a
Debian-based Linux operating system.
• Other third party operating systems
available via the official website include
Ubuntu MATE, Snappy Ubuntu Core,
Windows 10 IoT Core, RISC OS and
specialised distributions for the Kodi
media center and classroom
management.
Linux Based Operating Systems

• Android Things
• Arch Linux
• OpenSuse
• Raspberry Pi Fedora
Remix
• Pidora
• Gentoo Linux
• CentOS Raspberry Pi
• Kali Linux
• Slackware ARM
• Puppy Linux
Other Operating Systems

• RISC OS Pi
• FreeBSD
• NetBSD
• Windows 10 IOT
Core
• Haiku
• HelenOS
Community

• The Raspberry Pi community was described by Jamie


Ayre of FLOSS software company AdaCore as one of the
most exciting parts of the project.
• Community blogger Russell Davis said that the
community strength allows the Foundation to
concentrate on documentation and teaching.
• The community developed a fanzine around the platform
called The MagPi which in 2015, was handed over to the
Raspberry Pi Foundation by its volunteers to be
continued in-house.
• A series of community Raspberry Jam events have
been held across the UK and around the world
The MagPi
• The MagPi is a free fanzine for users of the
Raspberry Pi computer.
• It was created by the community as an unofficial
volunteer produced Raspberry Pi publication and in
2015 was handed over to the Raspberry Pi
Foundation to be run in-house as the official
Raspberry Pi magazine.
• It was launched in May 2012 and contains news,
projects and tutorials.
History
• In 2006, early concepts of the Raspberry Pi were based on
the Atmel ATmega644 microcontroller. Its schematics and
PCB layout are publicly available.
• Foundation trustee Eben Upton assembled a group of
teachers, academics and computer enthusiasts to devise a
computer to inspire children.
• The computer is inspired by Acorn's BBC Micro of 1981.
• The Model A, Model B and Model B+ names are references
to the original models of the British educational BBC Micro
computer, developed by Acorn Computers.
• The first ARM prototype version of the computer was
mounted in a package the same size as a USB memory stick.
It had a USB port on one end and an HDMI port on the other.
History

• The Foundation's goal was to offer


two versions, priced at US$25 and
$35.
• They started accepting orders for the higher
priced Model B on 29 February 2012, the
lower cost Model A on 4 February 2013. and
the even lower cost (US$20) A+ on 10
November 2014.
• On 26 November 2015, the cheapest
Raspberry Pi yet, the Raspberry Pi Zero,
was launched at US$5 or £4.
Raspberry Pi Zero
Raspberry Pi Model A
Raspberry Pi Model B
Raspberry Pi Model B+ and 2B
Raspberry Pi Model 3 B
Install and Update

sudo apt-get update


sudo apt-get upgrade

sudo apt-get install <package>

raspi-config
User interface

Command-line GUI
ot@devuan:~# nmap -sP 192.168.1.0/24
ot@devuan:~# ifconfig $ sudo -i
oot@devuan:~# ssh [email protected] root@pi3bplus:~# startx
oot@devuan:~# useradd newuser –m –G [pi]

clear ls exit shutdown


mkdir/rmdir pwd whoami
rm chown chmod cp/mv man
cat more nano vi
CPU info

$ cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 4 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls
vfpv4 \ idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
………………

$ uname -m
armv7l
RAM

• The Raspberry Pi 2 and the Raspberry Pi


3 have 1 GB of RAM.
• The Raspberry Pi Zero and Zero W
have 512 MB of RAM.
$ cat /proc/meminfo
MemTotal: 949452 kB
MemFree: 631676 kB
MemAvailable: 756320 kB
Buffers: 20532 kB
Cached: 158004 kB
SwapCached: 0 kB
Active: 170108 kB
Inactive: 107020 kB
……………………..
Networking

• The Model A, A+ and Pi Zero have no Ethernet


circuitry and are commonly connected to a network
using an external user-supplied USB Ethernet or Wi-
Fi adapter.
• On the Model B and B+ the Ethernet port is provided by
a built-in USB Ethernet adapter using the SMSC
LAN9514 chip.
• The Raspberry Pi 3 and Pi Zero W (wireless) are
equipped with 2.4 GHz WiFi 802.11n (150 Mbit/s) and
Bluetooth 4.1 (24 Mbit/s) based on Broadcom
BCM43438 FullMAC chip with no official support for
Monitor mode but implemented through unofficial
firmware patching and the Pi 3 also has a 10/100
Ethernet port.
Ethernet

sudo nano /etc/dhcpcd.conf:

nterface eth0
nform 192.168.1.177
tatic routers=192.168.1.1
tatic domain_name_servers=192.168.1.1
Wireless

sudo nano /etc/dhcpcd.conf:

SID xxxx
nterface eth0
nform 192.168.1.177
tatic routers=192.168.1.1
tatic domain_name_servers=192.168.1.1

n SSD: sudo nano /etc/wpa_supplicant/wpa_supplicant.conf


ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
ssid="YOUR_SSID"
psk="YOUR_WIFI_PASSWORD"
key_mgmt=WPA-PSK
}
Pi Direct

Point-to-point
Pi Direct

Node B Node B+

# nano /etc/dhcpcd.conf # nano /etc/dhcpcd.conf


interface eth0 auto eth0
inform 192.168.2.86 interface eth0
static ip_address=192.168.2.86/24 inform 192.168.2.87
static domain_name_servers=192.168.1.1 static ip_address=192.168.2.87/24
static routers=192.168.2.87 nogateway

# ifconfig
# sysctl -w net.ipv4.ip_forward=1
# route -n
net.ipv4.ip_forward = 1

# iptables -L -t nat
# iptables -F -t nat
# iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERA
Peripherals

• The Raspberry Pi may be operated with


any generic USB computer keyboard
and mouse.
• It may also be used with USB storage,
USB to MIDI converters, and virtually any
other device/component with USB
capabilities.
• Other peripherals can be attached
through the various pins and connectors
on the surface of the Raspberry Pi.
USB

$ lsusb
Bus 001 Device 008: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 007: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 004: ID 045e:00d1 Microsoft Corp. Optical Mouse
with Tilt Wheel
……………..
SD Card Storage

mount
v/mmcblk0p2 on / type ext4 (rw,noatime,data=ordered)

v/mmcblk0p1 on /boot type vfat (rw,relatime,fmask=0022,dma


=0022, codepage=437,iocharset=ascii,shortname=mixed,
ors=remount-ro)

$ cat
/sys/block/mmcblk0/queue/physical_block_size
512
$ cat
/sys/block/mmcblk0/queue/logical_block_size
$ 512
ls -l /dev/mmcblk0p?
Direct File System Mounts

# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 149.1G 0 disk
├─sda1 8:1 0 147.3G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 1.8G 0 part [SWAP]
sdb 8:16 1 14.5G 0 disk
├─sdb1 8:17 1 41.8M 0 part
└─sdb2 8:18 1 14.5G 0 part
sr0 11:0 1 1024M 0 rom
# blkid
/dev/sda1: UUID="51d355c1-2fe1-4f0e-aaae-01d526bb27b5"
TYPE="ext4" PARTUUID="61c63d91-01"
/dev/sda5: UUID="83a322e3-11fe-4a25-bd6c-b877ab0321f9"
TYPE="swap" PARTUUID="61c63d91-05"
/dev/sdb1: LABEL="boot" UUID="A75B-DC79" TYPE="vfat"
PARTUUID="2e37b5e0-01"
…….
Video Capabilities

• The video controller can emit standard modern


TV resolutions, such as HD and Full HD, and
higher or lower monitor resolutions and older
standard CRT TV resolutions.
• As shipped, it can emit these: 640×350 EGA;
640×480 VGA; 800×600 SVGA; 1024×768 XGA;
1280×720 720p HDTV; 1280×768 WXGA variant;
1280×800 WXGA variant; 1280×1024 SXGA;
1366×768 WXGA variant; 1400×1050 SXGA+;
1600×1200 UXGA; 1680×1050 WXGA+;
1920×1080 1080p HDTV; 1920×1200 WUXGA.
Summary
Accessories
• Camera – On 14 May 2013, the foundation and the distributors RS
Components & Premier Farnell/Element 14 launched the Raspberry Pi
camera board alongside a firmware update to accommodate it. The camera
board is shipped with a flexible flat cable that plugs into the CSI connector
which is located between the Ethernet and HDMI ports.
• Gertboard – A Raspberry Pi Foundation sanctioned device, designed for
educational purposes, that expands the Raspberry Pi's GPIO pins to allow
interface with and control of LEDs, switches, analog signals, sensors and
other devices. It also includes an optional Arduino compatible controller to
interface with the Pi.
• Infrared Camera – In October 2013, the foundation announced that
they would begin producing a camera module without an infrared filter,
called the Pi NoIR.
• HAT (Hardware Attached on Top) expansion boards – Together
with the Model B+, inspired by the Arduino shield boards, the interface for
HAT boards was devised by the Raspberry Pi Foundation.
Other Development Boards

• Asus TinkerBoard
• BeagleBone
• Banana Pi
• Orange Pi
• Ordroid
Asus TinkerBoard
Raspberry Pi vs TinkerBoard
Raspberry Pi vs TinkerBoard
BeagleBone Black
BeagleBone Black vs. Raspberry Pi
Power

P=VxI Using Adapter


= 5 x1.13 = 5.65 W

 Choose a power
Psupply = P * 1.5 = 8.475 W

Isupply = 1.13 x 1.5 = 1.695 A


Using LM7805 Regulation
LEDs and Header Strips

Command line

$ pinout
Building the gateway using RAK831&Rasp Pi
RAK831

Key Features
• Based on Semtech SX1301
• Supports 8 channels
• LoRaWAN® Stack 1.0.2
• Rx Sensitivity down to -139 dBm
(@293bps)
• Tx Power up to 23 dBm
• Full band support: 433MHz,
470MHz, 865MHz, 868MHz,
915MHz, 920MHz, 923MHz
• Range up to 15km Line of Sight,
2km+ in Dense Urban
• SPI interface
Installation

1. Install Raspbian on SD Card Raspberry pi


• Download Raspbian Stretch LITE
https://www.raspberrypi.com/software/operating-systems/

• Format the SD card using SD Card Formatter


https://www.sdcard.org/downloads/formatter_4/index.html

• Writing Raspbian Stretch LITE to the SD Card (using Etcher)

• Adding Wi-Fi Network Details (edit: wpa_supplicant.conf)


ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
ssid="YOUR_SSID"
psk="YOUR_WIFI_PASSWORD"
key_mgmt=WPA-PSK
}

• Enable SSH: creat file ssh in the root of the SD card


• Insert SD card into Raspberry Pi and run
Installation

2. Enable SPI sudo raspi-config

3. Update, Upgrade, install Git


sudo apt-get update && sudo apt-get upgrade && sudo apt-get install git -y

4. Clone app from repos.


git clone https://github.com/ttn-zh/ic880a-gateway.git ~/ic880a-gateway
cd ic880a-gateway
5. Modify RESET pin to 17 (instead of 25) nano start.sh
SX1301_RESET_BCM_PIN=17

6. Install : sudo ./install.sh spi (Tip: remote configuration -> No)

cd /opt/ttn-gateway/bin/
7. Run start shell script: sudo ./start.sh
Registration TTN

1. https://account.thethingsnetwork.org/register
2. Console -> Gateway -> registergateway
Gateway EUI: VKU gateway already registered
Cấu hình lại server

- Cấu hình lại địa chỉ TTN server:


- Router.eu.thethings.network (port 1700)
- Eu1.cloud.thethings.network (port 1700)

- Cấu hình tại /opt/ttn-gateway/bin


- local_conf.json
- global_conf.json
Xử lý lỗi gói tin không đúng định dạng
Phiên bản mới của Gatewway đã xử lý – không cần thực thiện slide này

Giao thức định tuyến


/opt/ttn-gateway/packet_forwarder/poly_packet_forwarder/src
File: poly_packet_fwd.c
bổ sung thêm lệnh: continue;
ngay dưới hàng thông báo “unknown packet with
datarate” hoặc “unknown packet with status 0”

Build lại giao thức, gõ lệnh: make


Tạo TTN account
Thêm mới gateway
Thêm mới device
Activation by Personalization(ABP)
Activation by Personalization(ABP)
Over the Air Activation (OTAA)
Message Format:Cayenne Low Power Payload

The Cayenne LPP is compliant with the payload size restriction,


which can be lowered down to 11 bytes, and allows the device to
send multiple sensor data at one time.
Application Server: View data

Webhook: ThinkSpeak, Cayenne

You might also like