Raspberry Pi supports SDHC (High Capacity up to 32 GB) cards with the FAT (File Allocation Table) file system only (cannot use SDXC cards with exFAT)
Insert an SD card to the laptop computer
Click "CHOOSE OS" and select "Raspberry Pi OS (32-bit)" or "Erase (Format card as FAT32)"
Click "CHOOSE SD CARD" and select the SD card
Click "WRITE"
Eject the SD card properly
Insert the SD card to the Raspberry Pi SD card slot
Connect the Raspberry Pi with a display, keyboard, and mouse
Connect power to the Raspberry Pi
Alternatively, set up Raspberry Pi without a display, keyboard, and mouse
Avram Piltch, How to Set Up a Headless Raspberry Pi, Without Ever Attaching a Monitor, June 25, 2020
Set country, language, and timezone
Select "Use English language" and "Use US keyboard" if applicable
Change password (default: raspberry)
Select if "this screen shows a black border around the desktop"
Select wireless network and enter wireless network password
Check and update software if necessary (this may involve a large download)
Click "Restart" to reboot
Point (not click) the curser to the Wi-Fi icon at the right of the menu bar to see and write down the IP address such as 192.168.x.xxx excluding the CIDR (Classless Inter-Domain Routing) notation of /24 suffix that indicates the number of bits of the prefix
Change Hostname (default: raspberrypi)
Disable "Auto login"
Enable "Network at Boot" to "Wait for network"
Enable "Splash Screen" (default)
Disable "Overscan" if the screen shows a black border around the desktop
Disable "Pixel Doubling" (default)
Enable "Screen Blanking" (default)
Enable Camera to use J3 Camera Serial Interface (CSI)
Enable SSH, VNC, SPI, I2C, Serial Port, 1-Wire, and Remote GPIO
Disable Serial Console
The following steps that require the internet access are necessary only if the IP address of Raspberry Pi is unknown
My Account > Sign-in & security > Signing in to Google >
2-Step Verification > TURN ON > Select a second verification step > Authenticator app (Default)
App passwords > Select the app (Mail) and device (Raspberry Pi) > GENERATE
Clone the IoT repository on a Raspberry Pi
pi@raspberrypi:~ $ git clone https://github.com/kevinwlu/iot.git
Update the IoT repository on a Raspberry Pi afterwards
pi@raspberrypi:~ $ cd iot
pi@raspberrypi:~/iot $ git pull
Copy any file out of the IoT repository to edit
$ cp ~/iot/lesson1/startup_mailer.py .
"~" represents the directory /home/pi
"." represents the current directory
".." represents the parent directory
$ nano startup_mailer.py
Change RECIPIENT_EMAIL, GMAIL_USERNAME, and GOOGLE_APP_PASSWORD
Replace HOSTNAME with the new Hostname in two instances
Save the file by typing "control-x y enter"
$ sudo nano /etc/rc.local
Add the following line with two-space indent above fi at the end as follows
python3 /home/pi/startup_mailer.py
fi
Save the file by typing "control-x y enter"
$ sudo reboot
If not receiving an email from the Raspberry Pi, make sure startup_mailer.py is working
$ python3 ~/startup_mailer.py
$ ssh pi@192.168.x.xxx
pi@raspberrypi:~ $ vncserver
$ sudo shutdown -h now
VNC Connect is included with the latest NOOBS for non-commercial use
Sign up for a free RealVNC account (need to be over 16) by an email address
On the Raspberry Pi desktop, click the VNC Server icon at the right of the menu bar and sign in to enable cloud connectivity
On a laptop, sign in to VNC Viewer
On a Raspberry Pi, copy two files
pi@UNIQUE_NAME:~ $ cp ~/iot/lesson1/startup.cnf .
pi@UNIQUE_NAME:~ $ cp ~/iot/lesson1/sshscript.sh .
Edit sshscript.sh with a unique hostname
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
Edit /etc/rc.local
$ 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