Setting Up a Raspberry Pi (2020)
Posted on 28 December, 2020
Ever wished that there was a simple set of instructions for setting up a new Raspberry Pi for development? Or for messing around with code? Below is the guide you’ve been waiting for …
1. Start with a new SD card (max 32GB). I recommend using Samsung Evo Plus or Samsung Evo Select cards. (The Select is a Plus branded for Amazon).
2. Use the Raspberry Pi Foundation’s Raspberry Pi Imager software to install the latest version of Raspbian.
3. Plug in screen, keyboard, mouse and power. If you intend using a Bluetooth mouse you still need a wired mouse to get set up. (Or one that works with a dongle like the Logitech Unified Receiver). If that's the case click on the Bluetooth icon and select Add Device once the initial setup is complete.
4. The Pi will take circa 30-60 seconds to power up fully, depending on the model.
5. Follow the instructions, to add network, update software to the latest version and so on ...
6. If you hit a time sync problem with the update, wait for it to time out and then use
sudo timedatectl set-ntp true
This should fix the sync error. Then use
sudo apt update && sudo apt full-upgrade
which will check for, and install, any software updates.
7. The system will ask you to change the password. Do it. Otherwise you’ll keep seeing reminders about your bad password habits!
8. Use the Raspberry Pi Configuration tool to rename the Pi for local network purposes. This has the benefit that if you use SSH, you won’t see errors because access keys don’t align with the (same) device name.
9. And a good idea at the same time to enable SSH, since it’s very useful ...
10. Since we're using the Pi for coding, it’d be great to install VSCode (other IDEs are available). The simplest way is to download in a browser — follow these instructions from Adafruit. Otherwise you can install using these instructions from headmelted.
Note that if you use the headmelted instructions you will need to add their public GPG key. Copy the link provided within the instructions, and use it in the following code:
wget -qO - GPG_KEY_ADDRESS | sudo apt-key add -
11. Set up VSCode how you like it – I like the Light+ theme and the Material Icon Theme pack.
12. Since we’re going to use this machine for coding we would like to get it set up for GitHub (other services are available). Follow these instructions to set up a new SSH key on the device, add it to GitHub and authenticate.
The instructions include installing xclip (they use apt-get, which I changed to apt). xclip
is a command line tool that copies something to the system pasteboard, very useful.
NB: when copying the key using xclip, ensure you add .pub to the end of the file path — you’re trying to copy the public key. Anything else will just generate errors when trying to save to GitHub!
And that's it -- you now have a working Pi with the best code editor, linked to your GitHub account, ready to get coding!
13. One bonus tip for Mac users, you may want to try changing the keyboard layout to US.
- Menu ...
- Preferences
- Mouse & Keyboard Settings
- Keyboard tab
- Keyboard Layout button
- Set Layout to "English (US)"
- Set Variant to "English (Macintosh)
Posted in code, raspberry-pi