Documentation of setting up raspberry pi for club use. Conencting and access to the pi works on most computers including chromebooks.
Note: This was originally tested and successfully shipped on the raspberry pi zero w.
- Use the rasbian full desktop image for the operating system of the pi.
- Boot with a monitor, keyboard, and mouse connected and go through the rasbian setup.
- After rebooting, run
sudo apt-get updatethensudo apt-get upgrade --fix-missingto bring developer tools up to date. - Make sure when you run
python3 -Vthe version is 3.6 or above.
- Run
sudo raspi-configand update the tool. - Next, expand the filesystem to make sure the pi can use the maximum amount of storage availble.
- Next, select
Interfacing Optionsand enable ssh and vnc. - Lastly, select
Advanced Optionsand change the resolution to ypur preffered resolution. You might have to test this as different pi's have different amounts of proccessing power and memory. For the raspberry pi zero recommend usingMODE 851280 x 720 60Hz 16:9.
- Signup for a free account on ngrok.com
- Download the linux-arm (The proccessor the pi zero is 32, if using a 64 bit proccessor download the 64 bit version) ngrok zip file and place it in your home directory.
- Run
unzipand file name of the zip you just downloaded. - Next, run
./ngrok authtoken TOKENHEREand replaceTOKENHEREwith your given authtoken - This should generate a configuration file at
/home/USER/.ngrok2/ngrok.yml(replace USER with yout username), open the file and add the following configurations (the tunnels names can be changed, You can't create more then 2 http tunnels, or 1 tcp and 1 http tunnel, if you go over ngrok blocks it from running because it will create too many tunnels on a free account):
tunnels:
flaskhttp:
proto: http
addr: 8000
pissh:
proto: tcp
addr: 22
- Run
mkdir devclubpiandcd devclubpi. - Run
git clone https://github.com/lowell-dev-club/pi-ssh-vnc.gitandcd pi-ssh-vnc. - Create a gmail app password. Instructions here. Create an app password for gmail and no specific device.
- Next create the file
config.pyin thepi-ssh-vncdirectory and write this code and replace the place holders:
emailUser = '[email protected]'
emailPass = 'YOUR APP PASSWORD'
- Lastly edit the rc.local file located at
/etc/rc.local. This can be done withsudo vi /etc/rc.localor with your favorite editor. But it is required to add sudo as the file is under root priviledges. Add these lines above theexit 0, make sure to edit and correct any paths that may be different for your pi:
# HEADLESS vnc server setup
if /usr/bin/pgrep -U pi vncserver >/dev/null ; then
/bin/sh -c '/usr/bin/sudo -u pi /usr/bin/vncserver -kill :1 >/dev/null 2>&;1 || :'
fi
/bin/sh -c '/usr/bin/sudo -u pi /usr/bin/vncserver'
# Portforwarding
sudo -u pi /home/pi/ngrok start --all &
python3 /home/pi/devclubpi/pi-ssh-vnc/pi_ssh_vnc.py &
- Now as long as everything was setup properly and all software is downloaded and up to date your pi is now accessible from anywhere.
- To test this or to use it remotely run
rebootand check the email you used forpi-ssh-vnc. This also works if you unplug everything from the pi except the power cord on restart or on boot.
- Download VNC Viewer
- Make sure your computer can or has an app to allow you to ssh to a device.
For chromebooks or anyone who wants to use or only has access to a browser (google chrome):
- Install VNC Viewer for Chrome
- Install SSH for Chrome
- For normal SSH access run
ssh [email protected] -p PORTNUMBERHEREand your done! - For VNC and SSH access run
ssh -L 5900:localhost:5900 [email protected] -p PORTNUMBERHERE. - Connect to localhost:5900 in VNC Viewer to VNC to the pi.