Aside from being a delicious pastry, a Raspberry Pi can be one of the greatest tools available to a maker! The Raspberry Pi is a fully functional computer that can cost as little as $10. It has an operating system, Wi-Fi, HDMI display, and GPIO pins to connect and control all types of devices. Raspberry Pis have shown great use in teaching programming, hacking fun projects, and even serving as edge computing nodes! This blog will walk you through all of the steps needed to set up a Raspberry Pi. There are also instructions for installing nio once your Pi is up and running so you can easily hack together your own projects or even create your own edge computing node within a distributed network.
Beginner: 45 minutes - 1 hour
Experienced: 30 - 45 minutes
**Note: The examples shown in these instructions are done from Mac OS, however, the process is very similar for Windows and Linux machines
Download a Raspbian Image
There are many Raspberry Pi operating systems available to download. Raspbian is a great choice as it is made specifically for the Raspberry Pi architecture. It comes in a desktop or lite version for working through a GUI or just the terminal. For a lot of nio projects, the lite version is all we need to get started.
Selecting the Download Zip option will download a zip file containing the image. This is the most common way to download the image file but it might be slow. If you have a BitTorrent client, you can select Download Torrent for a faster download.
The image that you obtain for your Raspberry Pi needs to be flashed onto the microSD card. This makes the SD card the main drive for the Raspberry Pi which loads in the operating system. Etcher is an easy and simple tool for this job.
Flash the SD card
With your micro SD card in the adapter, place it into your computer's sd card reader.
Open Etcher and select the Raspbian image (a raspbian file ending in .zip or .img). Your SD card should be autodetected as the drive to flash to. Click the flash button and let Etcher do it’s thing!
Once the SD card is flashed, we will want to access it while it is still in your computer. This configuration step is important because it will tell the Raspberry Pi how to connect to your home Wi-Fi network and how to allow your computer to access it remotely.
Etcher will unmount the SD card after flashing, so you will need to unplug and replug the card back into your computer to remount it.
To find where the SD card mounts on your system run the command
sudo df -h in your terminal to show all of the filesystems mounted on your machine.
It will typically mount at a directory under
/Volumes like the last filesystem shown in the image above. Change directories to that mount location with the command:
Create an empty file at this location named “ssh” with the command
touch ssh. This will enable SSH access to the Pi from an outside machine. This is useful so you don’t need to connect the Pi to a keyboard and monitor each time you need to make a change to it.
The last step to configure Raspbian is to set up the Wi-Fi network for the Pi to connect to on boot. To set this up, we will need to create a wpa_supplicant.conf file with network configuration information. The easiest way to do this would be to use a heredoc to get the file contents into the file. Run the following command but be sure to replace the fields marked with [ ] with the proper information for your wireless network:
cat > wpa_supplicant.conf <<EOL
ssid="[Your Network ssid]"
psk="[Your Network password]"
Boot up the Pi
Plug the micro USB power cable into your Pi to power it on by plugging it into your computer or other power source and let it boot up. The Pi will be ready to use when its green LED stops flashing and the red LED is solid. Login to the Raspberry Pi from your computer through the terminal. '
If this is the only Raspberry Pi on your network, you can login to it with the following command:
If you have multiple Pis on your network and can’t access through raspberrypi.local, you will need to find the IP address of your Pi. The easiest way to do this is with an HDMI display. Plug the display into the Raspberry Pi and boot it up. At the end of its boot sequence, there should be a line that says My IP Address is: XXX.XXX.XXX.XXX. This is an example of what your login should look like:
**Note: If an IP Address still does not show up in the boot sequence, remount the SD card onto your computer and double check your network settings.
If you still cannot determine the IP of the Pi, try plugging in a USB keyboard and HDMI display. Login to the Pi (usr:
raspberry) and run the command
ifconfig to see if an IP has been assigned under
The first time you attempt to ssh into the Pi, a security warning will display in your terminal. Accept this ssh warning by typing
yes. When prompted, enter
raspberry for the password, and you should be brought to the home directory. You’ll know you’re in the pi when you are able to see the Raspberry Pi prompt in your terminal:
You now have a functioning Raspberry Pi that can be interfaced through your own computer. The next step is to install nio and start building awesome things!
This part is made easy thanks to the developers here at nio. Download the nio binary from app.n.io/binaries/download after agreeing to the license agreement. This download will provide a wheel which is the python package that installs nio onto a device. Simply copy your binary .whl file onto the Pi and run the installation command below.
To copy your binary file use the scp command from a terminal on your machine. First logout of the Pi with the command
logout. Run the command:
scp /path/to/binary pi@XXX.XXX.XXX.XXX:~
scp ~/Downloads/nio_lite-20171006-py3-none-any.whl email@example.com:~ )
Replacing above fields with the path to your binary .whl file and the IP address of the Pi. This command will ask you to enter the password of the Pi (raspberry). You will know this command has succeeded when your terminal displays a similar conformation as the one below.
Next ssh back into the Raspberry Pi (ssh pi@XXX.XXX.XXX.XXX) and run the following command:
bash -c "$(curl -s https://raw.githubusercontent.com/niolabs/nio_install/master/rpi_nio_install.sh)"
It will then run through everything required get a basic instance of nio up and running on your Raspberry Pi. The install overall will take roughly 15-20 minutes depending on your Pi.
At the end of this script you should see the below success message notifying you that the nio instance on the Raspberry Pi is up and running. This message will also instruct you to configure your Pubkeeper communication settings for the instance. Instructions on how to configure a Pubkeeper server in the cloud can be found here under the step Create a System.
This script will ask for two things:
- The first is the path to the nio binary you want to install.
- The second is the name that you would like to give to the nio project directory.
Connect to your instance from the System Designer:
- Create a new System or connect to an existing System.
- Click + create new instance.
- Fill out the menu with a name for your instance, the IP Address of the Pi, and the port that the instance is running from (8181 by default).
From here you can create services, configure blocks, and build awesome things! A great reference to start building is the workshops.
When you need to shutdown your Pi. The best practice is to send your Pi a shutdown command. While ssh'd into the Pi, enter
sudo shutdown -h now.
There are plenty of nio blocks available specifically for interacting with the Raspberry Pi. Blocks such as GPIORead, GPIOWrite, HTU21D, AccelerometerChip, and more have specific implementations for running on a Raspberry Pi.