EE 629 �Internet of Things �Lesson 2: Raspberry Pi
Kevin W. Lu
2024-09-28
Lesson 2: Raspberry Pi
2
Lab 2A — GPIO and Serial
On the SSH Terminal, enter "sudo nano /boot/cmdline.txt"
Connect two serial pins (the 4th and 5th pins from the left of the top row) using one jump wire
Optionally, perform serial test between two Raspberry Pi's using three jump wires
3
Lab 2B — SPI
Connect the SPI MOSI and MISO pins (the 10th and 11th pins from the left of the bottom row) using one jump wire, and copy and paste the following three commands from Lesson 2 README.md on an SSH Terminal:
wget https://raw.githubusercontent.com/raspberrypi/linux/rpi-3.10.y/Documentation/spi/spidev_test.c
gcc -o spidev_test spidev_test.c
./spidev_test -D /dev/spidev0.0
4
Lab 2C — Breadboard
5
Lab 2D — LED
pi@raspberypi:~ $ sudo su
root@raspberypi:/home/pi# echo 18 > /sys/class/gpio/export
root@raspberypi:/home/pi# cd /sys/class/gpio/gpio18
root@raspberypi:/sys/class/gpio/gpio18# echo out > direction
root@raspberypi:/sys/class/gpio/gpio18# echo 1 > value
root@raspberypi:/sys/class/gpio/gpio18# echo 0 > value
root@raspberypi:/sys/class/gpio/gpio18# cd /home/pi
root@raspberypi:/home/pi# echo 18 > /sys/class/gpio/unexport
root@raspberypi:/home/pi# exit
exit
pi@raspberypi:~ $
6
Lab 2E — I2C
Connect I2C devices (ADXL345 and BMP180) to 3V3, GND, SDA, and SCL of a Raspberry Pi, install i2c-tools, and test I2C addresses (53 and 77) in use on an SSH Terminal:
sudo apt install i2c-tools python-smbus
sudo i2cdetect -y 1
7
Lab 2F — 1-Wire
Connect DS18B20 to Raspberry Pi as follows:
(1) GND to GND, (2) VDD to 3.3V or 5V, and (3) DQ to GPIO 4 (the 4th pin from the left of the bottom row) and through a 4.7kΩ resistor to VDD
pi@raspberrypi:~ $ sudo modprobe w1-gpio
pi@raspberrypi:~ $ sudo modprobe w1-therm
pi@raspberrypi:~ $ cd /sys/bus/w1/devices
pi@raspberrypi:/sys/bus/w1/devices $ ls
28-031868b2fbff w1_bus_master1
pi@raspberrypi:/sys/bus/w1/devices $ cd 28*
pi@raspberrypi:/sys/bus/w1/devices/28-031868b2fbff $ cat w1_slave
af 01 4b 46 7f ff 0c 10 35 : crc=35 YES
af 01 4b 46 7f ff 0c 10 35 t=26937
pi@raspberrypi:/sys/bus/w1/devices/28-031868b2fbff $ cd
pi@raspberrypi:~ $
8
Lab 2G — USB Webcam
sudo apt update
sudo apt install fswebcam
fswebcam image.jpg
fswebcam -r 1280x720 image2.jpg
fswebcam -r 1280x720 --no-banner image3.jpg
9
Raspberry Pi Foundation
10
Raspberry Pi
First released on February 29, 2012 by Raspberry Pi Foundation
Feature Broadcom system on chip (SOC)
Technical specifications for all models including Compute Modules
11
Computing Mechanisms
12
Charles Babbage 1791—1871
13
Alan Turing 1912—1954
14
John von Neumann 1903—1957
15
Steve Jobs 1955—2011
16
ARMv8 CPU
ARM, originally Acorn RISC Machine, later Advanced RISC Machine, is a family of reduced instruction set computing (RISC) architectures for computer processors
17
BCM2711
18
Raspberry Pi 1B (2012-02)
19
ACT: SD Card Access, PWR: Power
FDX: Full Duplex, LNK: Link, 100: Mbps
ARMv6Z (32-bit) BCM2835 700-MHz Single-Core ARM1176JZF-S
26-Pin GPIO Header
Raspberry Pi 1B+ V1.2 (2014-07)
20
ARMv6Z (32-bit) BCM2835 700-MHz Single-Core ARM1176JZF-S
40-Pin GPIO Header, 512MB SDRAM (synchronous dynamic random-access memory)
PWR
ACT
Raspberry Pi 2B (2015-02)
21
V1.1 (2015-02): ARMv7-A (32-bit) BCM2836 900-MHz 32-bit Quad-Core ARM Cortex-A7
V1.2 (2016-10): ARMv8-A (64/32-bit) BCM2837 900-MHz 64-bit Quad-Core ARM Cortex-A53
1GB SDRAM (synchronous dynamic random-access memory)
PWR
ACT
Raspberry Pi 3B (2016-02)
22
ACT
PWR
Antenna
V1.2 (2016-02): ARMv8-A (64/32-bit) BCM2837 1.2-GHz 64-bit Quad-Core ARM Cortex-A53
1GB SDRAM, Wi-Fi, Bluetooth
Raspberry Pi Zero W (2017-02-28)
23
ARMv6Z (32-bit) BCM2835 1-GHz Single-Core ARM1176JZF-S
V1.2 (2015-11) and V1.3 (2016-05) have no Wi-Fi and Bluetooth
V1.2 has no Camera Serial Interface (CSI)
Only Zero WH (2018-01-12) has pre-soldered 40-Pin GPIO header
512 MB SDRAM
Mini-HDMI, Antenna, Micro-USB, and Power
Raspberry Pi 3B+ (2018-03-14)
24
ACT
PWR
Antenna
ARMv8-A (64/32-bit) BCM2837B0 1.4-GHz 64-bit Quad-Core ARM Cortex-A53
1 GB SDRAM, Wi-Fi, Bluetooth
Raspberry Pi 3A+ (2018-11-15)
25
ARMv8-A (64-bit) BCM2837B0 1.4-GHz 64-bit Quad-Core ARM Cortex-A53
512 MB SDRAM, Wi-Fi, Bluetooth
Raspberry Pi 4B (2019-06-24)
26
ARMv8-A (64-bit) BCM2711B0 1.5-GHz 64-bit Quad-Core ARM Cortex-A72
VideoCore VI GPU (500 MHz), 1GB/2GB/4GB/8GB LPDDR4 SDRAM, Wi-Fi, Bluetooth
Raspberry Pi Zero 2 W (2021-10-28)
27
Mini-HDMI, Antenna, Micro-USB, and Power
Raspberry Pi Pico W (2022-06-30)
28
Pico (2021-01-21)
RP2040, Data Sheet, Getting Started With MicroPython [PDF] and C/C++ Examples
Raspberry Pi 5 (2023-09-28)
29
ARMv8-A (64-bit) BCM2712 2.4-GHz 64-bit Quad-Core ARM Cortex-A76
VideoCore VII GPU (800 MHz), 4GB/8GB LPDDR4X SDRAM, Wi-Fi, Bluetooth
RP1 I/O Controller via 4 PCIe Gen 2.0 Lanes
Raspberry Pi Pico 2 (2024-08-08)
30
More Than 60 Million Sold
31
Raspberry Pi Benchmarks
32
Meltdown, Spectre, and BlueBorne
33
Moore's Law
34
MicroSDHC Memory Cards
35
http://www.pidramble.com/wiki/benchmarks/microsd-cards
https://havecamerawilltravel.com/photographer/fastest-microsd-cards
Raspberry Pi supports Secure Digital (SD)
High Capacity (HC), not Extended Capacity (XC)
Raspberry Pi 3B+ Power Supply
36
Raspberry Pi 4B Power Supply
Raspberry Pi USB-C power supply features:
37
Ferrite Beads
38
Unix, GNU, POSIX, Linux, and Git
39
Gnu
40
Debian and Raspberry Pi OS
41
Debian Swirl
42
Coriolis Force
43
Debian Releases
Debian releases have been named after Toy Story characters because Bruce Perens was involved in the early development of Debian while working at Pixar
Stable, Oldstable, Oldoldstable, and Obsolete distributions are production releases
Testing distribution contains packages that haven't been accepted into a stable release yet, but they are in the queue for the next major release
Unstable distribution is where active development occurs
44
Install Raspberry Pi OS
45
Raspberry Pi OS Release Notes
The Raspberry Pi OS release notes provide updated information including
47
Raspberry Pi Boot Modes
48
First Boot Configuration Wizard
49
Set Country
50
Change Password
51
Skip (or Set) Wi-Fi Network
52
Skip (or Check for) Updates
53
Update Complete
54
Reboot Again
55
Raspberry Pi Configuration
56
Open Applications Menu > Preferences > Raspberry Pi Configuration
Alternatively, click the rc_gui.desktop shortcut
Change System Configuration
57
Required changes in red
Change Display Configuration
58
Hostnames
59
Change Default Credentials
666666, 888888, admin, admin1, administrator, guest, root, service, supervisor, support, tech, user
(none), 00000000, 1111, 1111111, 1234, 12345, 123456, 54321, 888888, admin, admin1234, default, guest, pass, password, root, service, supervisor, system, tech, user
60
Protect Passwords
61
Shell and Terminal
62
Bourne Shell, Bash, and Zsh
63
History and Wildcard Characters
64
Pipeline
ls -l | grep key | less
A; B # Run A and then B, no matter A succeeded or failed
A && B # Run B if and only if A succeeded
A || B # Run B if and only if A failed
A & # Run A in background
65
List of Commands 0/1
$ cd # Change directory to /home/pi
$ cd dirname # Change directory to dirname
$ cd .. # Move up to parent directory
$ cp file1 file2 # Copy file1 and call it file2
$ history # Print the history list
$ history -c # Clear the history list
$ ls # List files and folders
$ mkdir dirname # Make directory dirname
$ mv filename new_filename # Rename file
$ nano filename # Edit file
$ rm filename # Remove file
$ rm -rf dirname # Remove directory and its contents
$ rmdir dirname # Remove empty directory
$ scrot # Take a screenshot
$ sudo apt install _ # Install software _
$ sudo apt update # Update package list index
$ sudo apt full-upgrade # Upgrade software packages
$ sudo apt autoremove # Remove software packages
$ sudo nano filename # Edit a file in root directory
$ sudo pip install _ # Install Python package _
$ sudo reboot # Reboot Raspberry Pi
$ sudo shutdown -h now # Shutdown Raspberry Pi
66
List of Commands 1/1
$ arp -a # Show IP addresses of devices
$ cat filename # Show file contents
$ df -Th # Show disk space usage
$ sudo dmesg # Display kernel ring buffer messages
$ env # List environment variables (PATH)
$ find filename # Find file in current directory
$ hostname -I # Show IP address of Raspberry Pi
$ ifconfig # Show interface configuration
$ ip addr show wlan0 # Show IP address on Wi-Fi
$ iwconfig # Show wireless configuration
$ lsusb # List USB devices
$ man program_name # Show program’s manual pages
$ more filename # Show file one page at a time
$ netstat -lntp # Show network statistics
$ ps # Show running processes
$ pwd # Print working directory
$ sudo raspi-config # Configure Raspberry Pi
$ tar -zxvf file.tar.gz # Extract files
$ uname -a # Information about current kernel
$ vncpasswd # Change VNC server password
$ vncserver :1 # Run VNC server on display 1
$ wget http://example.com/file.tar.gz
67
Disk Space Usage
pi@4B2G:~ $ df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/root ext4 27G 14G 12G 53% /
devtmpfs devtmpfs 779M 0 779M 0% /dev
tmpfs tmpfs 908M 0 908M 0% /dev/shm
tmpfs tmpfs 908M 8.5M 900M 1% /run
tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs tmpfs 908M 0 908M 0% /sys/fs/cgroup
/dev/mmcblk0p6 vfat 253M 54M 199M 22% /boot
tmpfs tmpfs 182M 0 182M 0% /run/user/1000
pi@4B2G:~ $ df -Bm
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/root 27138M 13537M 12200M 53% /
devtmpfs 779M 0M 779M 0% /dev
tmpfs 908M 0M 908M 0% /dev/shm
tmpfs 908M 9M 900M 1% /run
tmpfs 5M 1M 5M 1% /run/lock
tmpfs 908M 0M 908M 0% /sys/fs/cgroup
/dev/mmcblk0p6 253M 54M 199M 22% /boot
tmpfs 182M 0M 182M 0% /run/user/1000
pi@4B2G:~ $
68
Change Hostname or Password
pi@raspberrypi ~ $ sudo nano /etc/hostname
pi@raspberrypi ~ $ sudo nano /etc/hosts
pi@raspberrypi ~ $ sudo reboot
pi@raspberrypi ~ $ passwd
Changing password for pi.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
pi@raspberrypi:~ $
69
Change Interfaces Configuration
70
Required changes in red
Default Performance Configuration
71
Localization
72
Advanced Options by Raspi-Config
pi@raspberrypi:~ $ sudo raspi-config
73
Graphics Library (GL) Driver
Experimental OpenGL Driver for hardware acceleration is not for Pi 1 and Pi Zero
74
Graphics Library (GL) Driver
Select fake kernel mode setting (KMS) to enable GL and play Neverball game
Select legacy to disable GL after game so that Pi can have proper, complete shutdown
75
Point Wi-Fi Icon for IP Address
76
Classless Inter-Domain Routing
77
Click Wi-Fi Icon for Networks
78
Default Network Interfaces
pi@raspberrypi:~ $ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
79
WPA Supplicant
Stevens login or password stored in /etc/wpa_supplicant/wpa_supplicant.conf can be updated by sudo nano:
pi@raspberrypi:~ $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="Stevens"
key_mgmt=WPA-EAP
identity="STEVENS_LOGIN"
password="PASSWORD"
}
A Supplicant, one who supplicates, is a term applied to humble petitioners, and in particular to University of Oxford students who have qualified but not yet been admitted into their degree
80
Hash for Password
The hash for the password can be generated as follows:
pi@raspberrypi:~ $ echo -n 'PASSWORD' | iconv -t utf16le | openssl md4
(stdin)= xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Edit /etc/wpa_supplicant/wpa_supplicant.conf to replace password='PASSWORD' with
password=hash:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
81
Contribution by Connor DePalma, 2019 Spring
Raspberry Pi MAC Address
Raspberry Pi Wi-Fi uses a 48-bit Extended Unique Identifier (EUI-48) for its media access control (MAC) address that includes the 3-octet organizationally unique identifier (OUI) — b8:27:eb or dc:a6:32 purchased from the IEEE Registration Authority, and another specific to the network interface controller (NIC)
82
Stevens-Media
If not getting access to the internet with the Stevens Wi-Fi IP address showing 169.254.9.183/16 or similar, run ifconfig to find the Raspberry Pi MAC address for wlan0, register it at MACTrac Devices for 150 days, click the network icon at the right of the menu bar to select Stevens-Media, enter the PSK password provided by the registration, and they will be automatically appended to /etc/wpa_supplicant/wpa_supplicant.conf :
pi@raspberrypi:~ $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
...
network={
ssid="Stevens-Media"
psk="PASSWORD"
key_mgmt=WPA-PSK
}
83
WPA GUI Graphical User Interface
Alternatively, install and run WPA GUI to manage Stevens Wi-Fi network
pi@raspberrypi:~ $ sudo apt install wpagui
pi@raspberrypi:~ $ wpa_gui
84
Stevens Username
Stevens Password
Contribution by Xiaolong Wang, 2015 Spring
Network Not Connected
85
Home Wi-Fi or Hotspot
pi@raspberrypi:~ $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="SSID"
psk="PRE_SHARED_KEY"
key_mgmt=WPA-PSK
}
86
x
x
* Contribution by Julie McEldoon, 2019 Fall
WPA_Passphrase Utility
For home Wi-Fi or hotspot, the wpa_passphrase utility uses the SSID and the password to generate the encrypted PSK
pi@raspberrypi:~ $ wpa_passphrase testing testingPassword
network={
ssid="testing"
#psk="testingPassword"
psk=131e1e221f6e06e3911a2d11ff2fac9182665c004de85300f9cac208a6a80531
}
pi@raspberrypi:~ $
Copy and paste the encrypted PSK in the wpa_supplicant.conf
87
Connected to Home Wi-Fi or Personal/Portable Wi-Fi Hotspot
88
Fing — Network Scanner
89
Contribution by Joseph Testa, 2016 Spring
Media Access Control (MAC) Address
Unsecured Network
If the network does not use a password, include key_mgmt=NONE in /etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid="Stevens-Guest"
key_mgmt=NONE
}
90
Wi-Fi Access Point and Wi-Fi Direct
91
Add Bluetooth Device
92
Select Bluetooth Device
93
Pair Bluetooth Device
94
Bluetooth Device Connected
95
Advanced Package Tool (APT)
pi@raspberrypi:~ $ sudo apt update
pi@raspberrypi:~ $ sudo apt install PACKAGE
pi@raspberrypi:~ $ sudo apt install PACKAGE_0 PACKAGE_1 PACKAGE_2
pi@raspberrypi:~ $ sudo apt update
pi@raspberrypi:~ $ sudo apt full-upgrade
pi@raspberrypi:~ $ sudo apt autoremove
96
Using apt Instead of apt-get
97
apt command | The command it replaces | Function of command |
apt install | apt-get install | Installs a package |
apt remove | apt-get remove | Remove a package |
apt purge | apt-get purge | Removes package with configuration |
apt update | apt-get update | Refreshes repository index |
apt upgrade | apt-get upgrade | Upgrade all upgradable packages |
apt autoremove | apt-get autoremove | Removes unwanted packages |
apt full-upgrade | apt-get dist-upgrade | Upgrades packages with auto-handling of dependencies |
apt search | apt-cache search | Searches for the program |
apt show | apt-cache show | Shows package details |
New apt Commands
98
New apt command | Function of the command |
apt list | Lists of packages with criteria (installed, upgradeable, etc.) |
apt edit-sources | Edits sources list |
Shutdown or Reboot
pi@raspberrypi ~ $ sudo shutdown -h now
pi@raspberrypi ~ $ sudo halt
pi@raspberrypi ~ $ sudo reboot
pi@raspberrypi ~ $ sudo shutdown -r now
99
Email IP Address at Boot
Raspberry Pi Configuration > System > Network at Boot > ✓ Wait for network
Clone the IoT repository, copy a file to /home/pi, and edit the credentials in bold
pi@raspberrypi:~ $ git clone https://github.com/kevinwlu/iot.git
pi@raspberrypi:~ $ cp ~/iot/lesson1/startup_mailer.py .
pi@raspberrypi:~ $ nano startup_mailer.py
to = 'RECIPIENT_EMAIL' # Email to send to
gmail_user = 'GMAIL USERNAME' # Email to send from (MUST BE GMAIL)
gmail_password = 'GOOGLE_APP_PASSWORD' # ... 16-letter App Password
...
my_ip_a = 'HOSTNAME %s IP address is %s' % (ip_type_a, ipaddr_a)
...
msg['Subject'] = 'IP address for HOSTNAME'
Save file with control-x y enter, then sudo nano /etc/rc.local by adding the line in bold
pi@raspberrypi:~ $ sudo nano /etc/rc.local
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
python3 /home/pi/startup_mailer.py
fi
Make /lib/systemd/system/rc-local.service executable
pi@raspberrypi:~ $ ls -l /lib/systemd/system/rc-local.service
pi@raspberrypi:~ $ sudo chmod +x /lib/systemd/system/rc-local.service
100
Contribution by Aldin Llolla, 2019 Fall
Google App Password
101
Secure Shell (SSH) from Laptop
Run SSH from a Terminal
$ ssh pi@192.168.1.209
The authenticity of host '192.168.1.209 (192.168.1.209)' can't be established.
ECDSA key fingerprint is SHA256:...
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.209' (ECDSA) to the list of known hosts.
pi@192.168.1.209's password:
Linux raspberrypi 5.10.11-v7l+ #1399 SMP Thu Jan 28 12:09:48 GMT 2021 armv7l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Aug 26 12:17:34 2020 from 192.168.1.209
pi@raspberrypi:~ $
102
SSH Client on Windows
103
Catch-22
104
Git for Windows
105
Windows Subsystem for Linux
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
106
Contribution by Touqeer Ahmad, 2016 Fall
Ubuntu
107
Enable SSH on Ubuntu
~$ uname -a
Linux klu-Inspiron-5577 5.3.0-62-generic #56~18.04.1-Ubuntu SMP Wed Jun 24 16:17:03 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
~$ sudo apt update
...
~$ sudo apt install lsb-core
~$ lsb_release -a
LSB Version: core-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 18.04.5 LTS
Release: 18.04
Codename: bionic
~$ sudo do-release-upgrade
Checking for a new Ubuntu release
There is no development version of an LTS available.
To upgrade to the latest non-LTS development release
set Prompt=normal in /etc/update-manager/release-upgrades.
~$ sudo apt install openssh-server
~$ sudo ufw allow ssh
~$ sudo systemctl status ssh
108
Dual Boot Ubuntu with Windows
Steps to dual boot Ubuntu with Windows 10
109
WSL 2 PowerShell
110
Chrome
Press Ctrl+Alt+T anywhere in Chrome OS to open crosh (Chrome Shell) and enter ssh
111
Contribution by Alhussain Almarhabi, 2017 Fall
Delete Old Keys in Known_Hosts
To use a different SD card or Wi-Fi dongle on Raspberry Pi at home, delete the previous ECDSA (or RSA) key in ~/.ssh/known_hosts on a laptop
$ ssh pi@192.168.1.x
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Please contact your system administrator.
Add correct host key in /Users/xxx/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/xxx/.ssh/known_hosts:1
ECDSA host key for 192.168.1.x has changed and you have requested strict checking.
Host key verification failed.
$ sed -i '' '1d' ~/.ssh/known_hosts
$
112
Elliptic-Curve Cryptography
113
Serveo Port Forwarder
On a Raspberry Pi, copy two files and edit sshscript.sh and /etc/rc.local
pi@UNIQUE_NAME:~ $ cp ~/iot/lesson1/startup.cnf .
pi@UNIQUE_NAME:~ $ cp ~/iot/lesson1/sshscript.sh .
pi@UNIQUE_NAME:~ $ sudo nano sshscript.sh
#!/bin/bash
while :
do
ssh -R UNIQUE_NAME:22:localhost:22 serveo.net
sleep 10
done
pi@UNIQUE_NAME:~ $ chmod +x sshscript.sh && sshscript.sh
pi@UNIQUE_NAME:~ $ sudo nano /etc/rc.local
...
if grep -q "RunServeoSSHOnStartup=1" /home/pi/startup.cnf; then
sudo /home/pi/sshscript.sh &
fi
exit 0
On a laptop, run the following command
$ ssh -J serveo.net pi@UNIQUE_NAME
114
Contribution by Pridhvi Myneni, 2019 Fall
Run VNC Server on Raspberry Pi
pi@raspberrypi:~ $ vncserver
VNC(R) Server 6.4.1 (r40826) ARMv6 (Mar 13 2019 16:35:06)
Copyright (C) 2002-2019 RealVNC Ltd.
RealVNC and VNC are trademarks of RealVNC Ltd and are protected by trademark
registrations and/or pending trademark applications in the European Union,
United States of America and other jurisdictions.
Protected by UK patent 2481870; US patent 8760366; EU patent 2652951.
See https://www.realvnc.com for information on VNC.
For third party acknowledgements see:
https://www.realvnc.com/docs/6/foss.html
OS: Raspbian GNU/Linux 10, Linux 4.19.118, armv7l
On some distributions (in particular Red Hat), you may get a better experience
by running vncserver-virtual in conjunction with the system Xorg server, rather
than the old version built-in to Xvnc. More desktop environments and
applications will likely be compatible. For more information on this alternative
implementation, please see: https://www.realvnc.com/doclink/kb-546
Running applications in /etc/vnc/xstartup
VNC Server catchphrase: "xxxxxx xxxxxx xxxxx. xxxxx xxxxxx xxxxxx."
signature: xx-xx-xx-xx-xx-xx-xx-xx
Log file is /home/pi/.vnc/raspberrypi:1.log
New desktop is raspberrypi:1 (155.246.x.x:1)
115
Run VNC Viewer on Laptop
such as 155.246.x.x:1, and click "OK"
116
VNC Viewer
117
VNC Cloud Connectivity
118
Contribution by Xingyuan Guo, 2018 Fall
Warning about Default Password
119
Appearance Settings
120
Select Wallpaper
121
Change Wallpaper
122
Edit Terminal Preferences
123
Increase Font Size
124
Insert USB Flash Disk
125
File Manager
126
Eject USB Flash Disk
127
Select USB Flash Disk
128
Remove USB Flash Disk
129
USB Webcam
No need to enable camera serial interface (CSI) for USB webcam
Install fswebcam
pi@raspberrypi:~ $ sudo apt update
pi@raspberrypi:~ $ sudo apt install fswebcam
pi@raspberrypi:~ $ fswebcam image.jpg
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
Adjusting resolution from 384x288 to 352x288.
--- Capturing frame...
Captured frame in 0.00 seconds.
--- Processing captured image...
Writing JPEG image to 'image.jpg'.
pi@raspberrypi:~ $ fswebcam -r 1280x720 image2.jpg
pi@raspberrypi:~ $ fswebcam -r 1280x720 --no-banner image3.jpg
130
Raspberry Pi Camera Module
Enable camera serial interface (CSI) to use a Raspberry Pi camera module
pi@raspberrypi:~ $ raspistill -o image4.jpg
131
Solderless Breadboards
132
Full Size (830 or 840 Tie Points)
Half Size (400 Tie Points)
Separate Power Rails
Preformed 22 AWG Wires
133
PVC Insulation | Length (Inch) | PVC Insulation | Length (Inch) |
No Insulation | 0.1 | Gray | 0.8 |
Red | 0.2 | White | 0.9 |
Orange | 0.3 | Brown | 1.0 |
Yellow | 0.4 | Red | 2.0 |
Green | 0.5 | Orange | 3.0 |
Blue | 0.6 | Yellow | 4.0 |
Violet | 0.7 | Green | 5.0 |
DuPont Connectors
134
GPIO Extension Board or Cobbler
135
T-Type
U-Type
T-Type Extension Board Widths
136
1.0 cm
1.8 cm
Streamlined GPIO Extension Board
137
Consolidated 3V3, 5V, and GND pins
Ribbon Cable
138
Breadboard for Raspberry Pi
139
Breadboard for Raspberry Pi
140
Hammer-In Solderless Pin Headers
141
Pin Headers
142
Source: Jameco
General-Purpose Input/Output
143
5V0 | 5V0 | G N D | 14 | 15 | 18 | G N D | 23 | 24 | G N D | 25 | 8 | 7 | ID SC | G N D | 12 | G N D | 16 | 20 | 21 |
TX | RX | P1 | P4 | P5 | P6 | CE0 | CE1 | P26 | P27 | P28 | P29 | ||||||||
| | | | | | | | | | | | | | | | | | | |
3V3 | 2 | 3 | 4 | G N D | 17 | 27 | 22 | 3V3 | 10 | 9 | 11 | G N D | ID SD | 5 | 6 | 13 | 19 | 26 | G N D |
SDA | SCL | P7 | P0 | P2 | P3 | CO PI | CI PO | SC LK | P21 | P22 | P23 | P24 | P25 |
Power | Ground | Serial (UART) | SPI | I2C | GPIO | Streamlined Extension Board GPIO | I2C ID EEPROM |
Shorting power pins to any other pin can damage Raspberry Pi
RPi 4B GPIO Alternate Functions
See Figure 3 and Table 5 of the Raspberry Pi 4 Model B Datasheet, Release 1, June 2019
In addition to the standard peripheral options found on legacy Pis, extra I2C, UART and SPI peripherals have been added to the BCM2711 chip and are available as further mux options on the Pi4
pi@raspberrypi:~ $ pinout
...
Revision : a03111
SoC : BCM2711
RAM : 1024Mb
Storage : MicroSD
USB ports : 4 (excluding power)
Ethernet ports : 1
Wi-fi : True
Bluetooth : True
Camera ports (CSI) : 1
Display ports (DSI): 1
...
For further information, please refer to https://pinout.xyz/
144
Serial (UART)
Raspberry Pi serial (UART) has two mutually exclusive uses
145
Serial-to-USB Console Cable
Prolific > SIO (Smart-IO) > USB to UART/Serial/Printer > PL2303HXD
$ screen /dev/cu.usbserial 115200
146
Console Login
Menu>Preferences>Raspberry Pi Configuration>Interfaces>Enable Serial Console (enabled by default)>Shutdown
After connecting GND, TXD, and RXD with a serial-to-USB console cable to a laptop, first run PuTTY or the screen command on laptop then connect Raspberry Pi to 5V
$ screen /dev/cu.usbserial 115200
Uncompressing Linux... done, booting the kernel.
Welcome to the rescue system
recovery login: pi
...
Raspbian GNU/Linux 9 ioto ttyAMA0
ioto login: pi
Password:
...
pi@ioto:~ $ sudo raspi-config
...
pi@ioto:~ $ sudo shutdown -h now
...
control-a k
Really kill this window [y/n]y
[screen is terminating]
147
TTY
pi@4B2G:~ $ cd /dev
pi@4B2G:/dev $ ls
...
ttyAMA0
...
ttyS0
...
pi@4B2G:/dev $
148
AMA is Short for AMBA
149
Disable Console to Use UART
Menu>Preferences>Raspberry Pi Configuration>Interfaces>Enable Serial Port and Disable Serial Console
Alternatively, delete "console=serial0,115200" in /boot/cmdline.txt then reboot
pi@4B2G ~ $ sudo nano /boot/cmdline.txt
console=tty1 console=serial0,115200 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
control-x y enter
pi@4B2G:~ $ sudo reboot
...
pi@4B2G:~ $ cat /boot/config.txt
...
enable_uart=1
pi@4B2G:~ $ cd /dev
pi@4B2G:/dev $ ls
...
ttyAMA0
...
ttyS0
...
150
Serial Loopback Test
151
Connect serial TXD and RXD with a jump wire
Minicom Commands
pi@4B2G:~ $ sudo apt install minicom
+-------------------------------------------------------------------+
| Minicom Command Summary |
| |
| Commands can be called by CTRL-A <key> |
| |
| Main Functions Other Functions |
| |
| Dialing directory..D run script (Go)....G | Clear Screen.......C |
| Send files.........S Receive files......R | cOnfigure Minicom..O |
| comm Parameters....P Add linefeed.......A | Suspend minicom....J |
| Capture on/off.....L Hangup.............H | eXit and reset.....X |
| send break.........F initialize Modem...M | Quit with no reset.Q |
| Terminal settings..T run Kermit.........K | Cursor key mode....I |
| lineWrap on/off....W local Echo on/off..E | Help screen........Z |
| Paste file.........Y Timestamp toggle...N | scroll Back........B |
| Add Carriage Ret...U |
| |
| Select function or press Enter for none. |
+-------------------------------------------------------------------+
152
Serial Loopback Test: 115200 Baud
pi@4B2G:~ $ minicom –b 115200 –o –D /dev/ttyS0
Welcome to minicom 2.7.1
OPTIONS: I18n
Compiled on Aug 13 2017, 15:25:34.
Port /dev/ttyS0
Press CTRL-A Z for help on special keys
control-a a
Hello
control-a e
HHeelllloo
control-a x
+----------------------+
| Leave Minicom? |
| Yes No |
+----------------------+
CTRL-A Z for help | 115200 8N1 | NOR | Minicom 2.7 | VT102 | Offline | ttyS0
153
Serial Loopback Test: 9600 Baud
pi@4B2G:~ $ minicom –b 9600 –o –D /dev/ttyS0
Welcome to minicom 2.7.1
OPTIONS: I18n
Compiled on Aug 13 2017, 15:25:34.
Port /dev/ttyS0, 14:27:48
Press CTRL-A Z for help on special keys
control-a a
Hello
control-a e
HHeelllloo
control-a x
+----------------------+
| Leave Minicom? |
| Yes No |
+----------------------+
CTRL-A Z for help | 9600 8N1 | NOR | Minicom 2.7 | VT102 | Offline | ttyS0
154
Émile Baudot 1845—1903
155
Crystal Oscillator Frequencies
156
KNX — ISO/IEC 14543-3
157
Low-Rate Wireless Personal Area Networks
158
| |||||
Topology | Point-to-point, star, tree, mesh | Point-to-point, star, mesh | Mesh | Mesh | Mesh |
Frequency in US | 2.4 GHz | 2.4 GHz | 2.4 GHz, 915 MHz | 2.4 GHz, 915 MHz | 908.42 MHz |
Max. Data Rate | 60 kb/s | 2 Mb/s | 250 kb/s | 250 kb/s | 100 kb/s |
Max. Range | 30 m | 600 m | 100 m | 100 m | 100 m |
Standards | Garmin | Bluetooth SIG | IETF 6LoWPAN IEEE 802.15.4 | IEEE 802.15.4 | Sigma Designs |
Bluetooth
159
Waggle Dance of Honey Bees
160
Start Point
Hedy Lamarr 1914—2000
161
XBee ZigBee Modules
162
XBee ZB with PCB antenna
ZigBee/IEEE 802.15.4 module
and adapter for breadboard
3.3V
USB to serial adapter
e.g., support Digi XCTU over usbserial-AL0046V6
5V
Breakout board
5V
XBee Pinout
163
1 | VCC (3V3) | AD0/DIO0 | 20 |
2 | DOUT | AD1/DIO1 | 19 |
3 | DIN/CONFIG | AD2/DIO2 | 18 |
4 | DIO12 | AD3/DIO3 | 17 |
5 | RESET | RTS/DIO6 | 16 |
6 | RSSI PWM/DIO10 | Associate/DIO5 | 15 |
7 | DIO11 | VREF | 14 |
8 | [reserved] | ON/SLEEP/DIO9 | 13 |
9 | DTR/SLEEP_RQ/DIO8 | CTS/DIO7 | 12 |
10 | GND | DIO4 | 11 |
Minimum
connections
highlighted
Low-asserted
signals
overlined
RSSI: Received Signal Strength Indicator
PWM: Pulse Width Modulation
DTR: Data Terminal Ready
AD: Analog-to-Digital
DIO: Digital Input/Output
RTS: Request-to-Send
CTS: Clear-to-Send
XBee Setup
164
XBee Configuration 0/1
165
XBee Configuration 1/1
166
XBee M2M Demo
RaspberryPi is COORDINATOR
pi@raspberrypi:~ $ minicom -b 9600 -o -D /dev/ttyS0
control-a a
control-a e
Hello from COORDINATOR
control-a x
4B1G is ROUTER_1
pi@4B1G:~ $ minicom -b 9600 -o -D /dev/ttyS0
control-a a
control-a e
Hello from ROUTER_1
control-a x
4B2G is ROUTER_2
pi@4B2G:~ $ minicom -b 9600 -o -D /dev/ttyS0
control-a a
control-a e
Hello from ROUTER_2
control-a x
167
Analog-to-Digital Converter (ADC)
168
3V3
3V3
GND
SPI/SCLK
SPI/MISO
SPI/MOSI
SPI/CE0
GND
_______
CS/SHDN: Chip Select/Shutdown
Inclusive Terminology
169
SPI Loopback Test
SPI enabled by Menu > Preferences > Raspberry Pi Configuration > Interfaces
pi@4B2G:~ $ cat /boot/config.txt
dtparam=spi=on
pi@4B2G:~ $ wget https://raw.githubusercontent.com/raspberrypi/linux/rpi-3.10.y/Documentation/spi/spidev_test.c
pi@4B2G:~ $ gcc -o spidev_test spidev_test.c
Put a wire between MOSI and MISO for spidev-test
pi@4B2G:~ $ ./spidev_test -D /dev/spidev0.0
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)
FF FF FF FF FF FF
40 00 00 00 00 95
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
DE AD BE EF BA AD
F0 0D
170
1-kΩ 4-Band and 5-Band Resistors
171
Resistor Color Code
172
Color | Band 1, 2, (3) | Multiplier | Tolerance | Temperature | |
| Black | 0 | 100 | | |
| Brown | 1 | 101 | ±1% | 100 ppm/°K |
| Red | 2 | 102 | ±2% | 50 ppm/°K |
| Orange | 3 | 103 | | 15 ppm/°K |
| Yellow | 4 | 104 | | 25 ppm/°K |
| Green | 5 | 105 | ±0.5% | |
| Blue | 6 | 106 | ±0.25% | |
| Violet | 7 | 107 | ±0.1% | |
| Grey | 8 | 108 | ±0.05% | |
| White | 9 | 109 | | |
| Gold | | 10-1 | ±5% | |
| Silver | | 10-2 | ±10% | |
| None | | | ±20% | |
Light-Dependent Resistor (LDR)
173
LDR, ADC, and Lux
v_ldr=(light_level*3.3)/1023
lux=500/r_ldr
v_ldr=3.3*r_ldr/(R+r_ldr)
r_ldr=(R*v_ldr)/(3.3-v_ldr)
lux=500*(3.3-v_ldr)/(R*v_ldr)
174
LDR with or without ADC
175
C=1μF
RLDR
VIN=3.3V
GND
VC
VC=VIN/(1+RLDRC)
RLDR
R=10KΩ
VIN=3.3V
GND
VLDR
VLDR=VINRLDR/(R+RLDR)
LDR with ADC
176
LDR without ADC
177
LDR
Light-Emitting Diodes (LEDs)
178
+-++
or -+--
Switch an LED on/off
pi@4B2G:~ $ sudo su
root@raspberypi:/home/pi# echo 18 > /sys/class/gpio/export
root@raspberypi:/home/pi# cd /sys/class/gpio/gpio18
root@raspberypi:/sys/class/gpio/gpio18# echo out > direction
root@raspberypi:/sys/class/gpio/gpio18# echo 1 > value
root@raspberypi:/sys/class/gpio/gpio18# echo 0 > value
root@raspberypi:/sys/class/gpio/gpio18# cd /home/pi
root@raspberypi:/home/pi# echo 18 > /sys/class/gpio/unexport
root@raspberypi:/home/pi# exit
exit
pi@4B2G:~ $
179
Relay (Songle SRD-05VDC-SL-C)
180
NO: Normally Open
NC: Normally Close
Common
DC Motor Driver (Keyes L298)
181
Connect GND to the Raspberry Pi GND
IoT Sensor Examples
182
| Accelero- meter Orienta- tion | Air Gas Dust Particle | Distance Gesture Motion Proximity | Light | Magnet | Water | Sound | Temp. | Temp. Humidity | Temp. Pressure |
ADC SPI | | MQ-7 MQ-135 | TCRT5000 | LDR | | A930 YL-38/ XD-28 YL-69 | ADMP401 INMP401 LM393 SPW2430 | LM35 MAX6675 TMP36 | | |
I2C | ADXL335 ADXL345 BNO055 GY-521 LSM9DS0 MPU-6050 MPU-9250 | | APDS-9960 | | | | | | SHT31-D | BMP085 BMP180 BMP280 MSP100 |
1-Wire | | | | | | | | DS18B20 | | |
GPIO | | PPD42NS | DYP-ME003 HC-SR04 HC-SR501 | | Door Switch Set | | SparkFun Sound Detector | | AM2302 DHT11 DHT22 | |
Additional Sensors
183
Sensors with 3.3V Supply Voltage
184
DHT11,
DHT22, or
AM2302
(GPIO) Temperature
/Humidity
Sensor
BMP085 or BMP180 (I2C)
BMP280 (I2C)
Pressure/Temperature Sensor
ADXL345 (I2C)
Accelerometer
YL-38 with XD-28 or YL-69 (SPI)
Hygrometer/Moisture Sensor
Sensors with 5V Supply Voltage
185
MQ-7 (SPI)
CO Gas Sensor
HC-SR04 (GPIO)
Ultrasonic Ranging Module
DYP-ME003 or HC-SR501 (GPIO)
Passive Infrared (PIR) Motion Sensor
Canaries in the Coal Mine
186
Batteries for IoT Devices
187
Install i2c-tools
I2C enabled by Menu > Preferences > Raspberry Pi Configuration > Interfaces
pi@4B2G:~ $ cat /boot/config.txt
...
dtparam=i2c_arm=on
...
pi@4B2G:~ $ cat /etc/modules
...
i2c-dev
pi@4B2G:~ $ sudo apt install i2c-tools python-smbus
pi@4B2G:~ $ sudo reboot
188
BMP180 Setup
189
ADXL345 Setup
190
Detect I2C Chips 0/5
Nothing connected with I2C SDA and SCL on Raspberry Pi
pi@4B2G:~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
191
Detect I2C Chips 1/5
MSP100 pressure transducer such as MSJ-00000U-250PG connected with 5V (red), GND (green), SDA (white), and SCL (black) on Raspberry Pi
pi@4B2G:~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- 28 -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
192
Detect I2C Chips 2/5
ADS1115 16-bit (ADS1015 12-bit) 4-channel analog-to-digital converter (ADC) connected with I2C SDA and SCL on Raspberry Pi
pi@4B2G:~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
193
Detect I2C Chips 3/5
ADXL345 3-axis accelerometer connected with I2C SDA and SCL on Raspberry Pi
pi@4B2G:~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- 53 -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
194
Detect I2C Chips 4/5
MLX90614 digital non-contact infrared thermometer connected with 5V, GND, and I2C SDA and SCL on Raspberry Pi
pi@4B2G:~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- 5a -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
195
Detect I2C Chips 5/5
BMP180 and BMP280 barometric pressure sensor connected with I2C SDA (SDI) and SCL (SCK) on Raspberry Pi
pi@4B2G:~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- 77
196
1-Wire Digital Thermometer
197
Testing 1-Wire in Use 0/1
Connect DS18B20 to Raspberry Pi as follows:
(1) GND to GND, (2) VDD to 3.3V or 5V, and (3) DQ to GPIO 4 (the 4th pin from the left of the bottom row) and through a 4.7kΩ resistor to VDD
198
Testing 1-Wire in Use 1/1
pi@4B2G:~ $ sudo modprobe w1-gpio
pi@4B2G:~ $ sudo modprobe w1-therm
pi@4B2G:~ $ cd /sys/bus/w1/devices
pi@4B2G:/sys/bus/w1/devices $ ls
28-031868b2fbff w1_bus_master1
pi@4B2G:/sys/bus/w1/devices $ cd 28*
pi@4B2G:/sys/bus/w1/devices/28-031868b2fbff $ cat w1_slave
af 01 4b 46 7f ff 0c 10 35 : crc=35 YES
af 01 4b 46 7f ff 0c 10 35 t=26937
pi@4B2G:/sys/bus/w1/devices/28-031868b2fbff $ cd
pi@4B2G:~ $
199
HATs and pHATs
200
Lesson 2 Summary
201
Splash Screen
202
Image Screen
203
Click Wi-Fi Network
204
Connect to Stevens Wi-Fi
205
Select Raspberry Pi OS (32-bit)
206
More Operating Systems
207
Select US Language and Keyboard
208
Click OK to Confirm Installation
209
Installation in Progress
210
Click OK to Reboot
211
Raspberry Pi OS Screen
212
Raspberry Pi OS Console
213
PIXEL Screen
214
PIXEL (Pi Improved Xwindows Environment, Lightweight) Desktop
Low-voltage Indicator
215
Low-voltage indicator →
due to inadequate USB cable or power supply
SSH IPQoS Option
Only if SSH doesn’t work because of Raspberry Pi Wi-Fi, add IPQoS option to the end of /etc/ssh/sshd_config
pi@raspberrypi:~ $ sudo nano /etc/ssh/sshd_config
...
IPQoS cs0 cs0
control-x y enter
pi@raspberrypi:~ $ sudo service ssh restart
216
Date/Time Synchronization
Only if the date command shows incorrect date/time, add the following command in /etc/rc.local so that Raspberry Pi can forward ntpd (Network Time Protocol Daemon) packets with ToS (Type of Service) 0xc0 as 0x00
pi@raspberrypi:~ $ date
Tue Sep 6 17:09:10 EDT 2016
pi@raspberrypi:~ $ sudo nano /etc/rc.local
...
/sbin/iptables -t mangle -I POSTROUTING 1 -o wlan0 -p udp --dport 123 -j TOS --set-tos 0x00
...
exit 0
control-x y enter
pi@raspberrypi:~ $ sudo reboot
217