27/01/2020 : 09:42:41
Use VisualStudio code to run application code on the Pi, from the PC. Using the following resources:
Use a router to connect the Pi to the mac
-
Mac Book Pro
- WiFi interface connected to ISP
- Ethernet connected to LinkSys WRT1900 ACS out-of-the box.
-
MacBook, Network Preferences, set service order, so Wifi is above Ethernet. This this way, the MBP retains its internet connection.
-
Mac Book
ifconfig
shows I have connection to local DHCP and external.- en0:
inet 192.168.1.179
- en1:
inet 10.xxx.xxx.xxx
- en0:
-
Raspberry Pi:
- Fresh install of Raspbian
- Connect Raspberry Pi to router via Ethernet
- Boot into PIXEL UI
- 'Welcome to Raspberry Pi', and helpful notice of IP address, supplied by router's DHCP.
-
LinkSys Router
- Connect MBP via ethernet
- Find the router dashboard withbrowser at 192.168.1.1.
- Manually log-in, bypassing commercial cruft to set-up account.
- Out-of-the-box password is 'admin'.
- In router dashboard, find the connected devices
- Note the IP address of the PI. (192.168.1.163)
- Router gives me the option of reserving the IP address so I do. RPi will now get this address whenever it is connected.
-
Raspberry Pi: Enable SSH
- See: https://www.raspberrypi.org/documentation/remote-access/ssh/
- Go to Preferences > Raspberry Pi Configuration
- Go to Interfaces Tab: Enable SSH
- Click OK
-
MBP: Connect via SSH
adanac:dev coops$ ssh pi@192.168.1.163 The authenticity of host '192.168.1.163 (192.168.1.163)' can't be established. ECDSA key fingerprint is SHA256:Qam4uV0TyvfaX00pfwkan6ITjsrVxjFqOL1H5/3l3cs. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.1.163' (ECDSA) to the list of known hosts. pi@192.168.1.163's password: Linux raspberrypi 4.19.93-v7+ #1290 SMP Fri Jan 10 16:39:50 GMT 2020 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: Sun Jan 26 15:31:16 2020 SSH is enabled and the default password for the 'pi' user has not been changed. This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.
-
Make sure we can connect MBP to RPi, passwordless
-
See: https://www.raspberrypi.org/documentation/remote-access/ssh/passwordless.md
-
On MBP:
ssh-keygen
-
Generated public / private key pair without passphrase in the default location.
-
Check:
ls ~/.ssh
Should getid_rsa
id_rsa.pub
-
Transfer the public key to the RPi:
adanac:dev coops$ ssh-copy-id pi@192.168.1.163 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/Users/coops/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys pi@192.168.1.163's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'pi@192.168.1.163'" and check to make sure that only the key(s) you wanted were added. adanac:dev coops$ ssh pi@192.168.1.163 Linux raspberrypi 4.19.93-v7+ #1290 SMP Fri Jan 10 16:39:50 GMT 2020 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: Sun Jan 26 15:45:52 2020 from 192.168.1.179 SSH is enabled and the default password for the 'pi' user has not been changed. This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.
-
-
MBP install VS Code
- Standard VS Code installation will support remote extension to RPi
-
MBP add extension
- Remote - SSH
-
Connect to RPi
- https://code.visualstudio.com/docs/remote/ssh#_connect-to-a-remote-host
- Use F1 key, then choose 'connect to to host'
- pi@192.168.1.163
-
Enable remote desktop, on the Pi
- We use this in emergencies - for when it's a bit tricky connecting the Pi to WiFi for internet access (to GitHub)
- Pi: Preferences > Raspberry Pi configuration
- VNC: Enable
-
Enable VNC Viewer on the MBP
- Install VNC Viewer for Google Chrome
- Connect to pi@192.168.1.163
- authenticate using default raspberry pi username and password.
-
Prioritise internet access for WiFi, before Ethernet (VERY important!)
-
Pi: Open
/etc/dhcpcd.conf
-
at the end of the file, add this. The lower the metric, the higher the priority.
-
interface eth0 metric 300 interface wlan0 metric 200
-
restart the RPi.
-
-
Git, from VS Code
- See: https://code.visualstudio.com/docs/editor/versioncontrol#_git-support
- In VS Code you can now go to View : Terminal
- This brings up a terminal window, pointing to the current working directory on the Pi (I am really impressed by all this, btw. It's incredible.)
- Use
git --version
to get the current version. Should be something like2.20.1
- Now use this, to clone this repo onto the RPi: https://code.visualstudio.com/docs/editor/versioncontrol#_cloning-a-repository
- SHIFT-CMD-P to bring up command palette
Git: Clone
- VS Code prompts for the URL of the Repo.
https://github.com/aliceliveprojects/little_blue_pi.git
- VSCode prompts for the location of the local repo, on the Pi
/home/pi/Documents/github/little_blue_pi/little_blue_pi
- Can now access the local repo on the Pi from VS Code on the MBP.
- To check-in any mods to your repo on github, you will need to set your github user and email address. This attaches your details to any commits you do. If you don't do this, git will error when you try to commit.
- GitHub protects your identity, by giving you a no-reply email address you can use, if you're uncomfortable using your own. You can find it, by:
- use a browser to login to your GitHub account
- go to your profile picture in the top right of any GitHub page
- choose 'settings'
- in the 'settings' page, click on 'emails' in the left hand side-bar
- in the 'emails' page, there is a check-box; 'keep my emails private'. You should always keep your emails private, so make sure this is checked.
- underneath the option is the no-replay email address. Alice's is
32162302+AliceDigitalLabs@users.noreply.github.com
- copy your no-reply email to the clipboard
- Back in VS Code, in your terminal window (making commands to your Pi), you can use the following, to give git information which goes with each commit. The information is local to the repository. If you have another repository, you will need to do this for that one too (or alter the global settings)
- git config user.name "YOUR GITHUB USERNAME"
- git config user.email "YOUR GITHUB NO-REPLY EMAIL ADDRESS"
- GitHub protects your identity, by giving you a no-reply email address you can use, if you're uncomfortable using your own. You can find it, by: