2. Configure Raspbian

After Etcher is complete we'll want to access the SD card while still mounted to your computer. If the SD card was ejected after Etcher completed then unplug/replug the SD card and make sure it is mounted.

Create and edit wpa_supplicant.conf
to pre-configure WiFi. Configuring this will allow the Pi to automatically join a network at boot if available. The Pi only has a 2.4Ghz antenna and not compatible with 5Ghz routers. Run the following to configure WiFi:

sudo nano wpa_supplicant.conf

Note 1: Adding sudo to the beginning of a command will give you root (super user) rights. This topic gets a little hairy, if you follow these instruction verbatim you'll be ok.

Note 2: What is nano? Nano is a lightweight text editor that works inside the terminal. Calling nano followed by a file will open that file for editing.

With nano open to a blank file, paste the following snippet in - modifying it with your own network credentials.

Press CRTL+X to exit, Y to save, ENTER to confirm and exit the Nano editor. Eject the SD card from your computer and insert it into the Raspberry Pi.

3. Connect to the Pi over WiFi SSH

Apply power to the Raspberry Pi through its micro USB power port and wait one minute for the device to startup and connect. You do not need to plug in the Nova yet. Please ensure you use the supplied power adaptor, it's important your Pi gets the recommended 5V 2.4A.

On your main computer (not the Pi) open a terminal, you may even still have the terminal open from the last few steps. We're going to use SSH (Secure Shell) to access the Pi's terminal remotely from your main computer. Think of it like remote desktop, but instead of a desktop it's a terminal.

In the terminal run:

ssh pi@raspberrypi.local

Password is raspberry.

Troubleshooting:

What if the device is not found? The Pi probably is not on the network. Put the SD card back into your main computer and redo the last step, ensuring the wifi credentials are correct and you're connecting to a 2.4Ghz network.

What if there are multiple Raspberry Pi's on my network sharing the same hostname? You'll need to access the Pi by local IP address instead of the hostname.local. Identify the device's IP by logging into your router's admin backend or using an app like Bonjour Browser. Find the IP address access the device through SSH > ssh pi@xxx.xxx.x.xx

Further Pi configuration.

Now you should remotely be inside your Pi's terminal. We're going to finish up configuring the Pi. From the SSH command line run:

Verify Hologram's CLI (Command Line Interface) was installed. It should return a version greater than 0.6.0.

hologram version

Congrats! You completed setting up your Raspberry Pi and you never hooked up a monitor! You're now a pro!

Lesson 1 - Blink an LED

We'll be interacting with General Purpose Input/Output Pins (GPIO for short). For a quick refresher on the major nuances of Pi GPIO pins, check out this StackOverflow. For this project we'll be using BCM numbering.

For lesson 1 we'll set one of our Pi pins as an output, controlling electricity to light an LED on demand.

Wiring Diagram

Below is how you should connect everything. Use a 220ohm resistor. The color of the wires to not matter but generally RED represents power and BLACK represents ground.

Note: ALWAYS make sure to remove power to the Pi before wiring.

Reconnect power, wait a minute, and re-establish an SSH connection.

Run the Code 🏃💨

I've already created the code needed to blink the light and stored it on GitHub for anyone to access. We're going to clone (fancy word for copying) code from my GitHub repo to your Pi by running the following command.

git clone https://github.com/benstr/nova-starter-kit.git

Now you should have a new folder on our Pi filled with goodies!

ls nova-starter-kit/

Run the code by issuing the following command.

sudo python nova-starter-kit/01_blink/main.py

The terminal will ask you how many times you'd like to blink the LED. Enter a number and watch the light turn on and off. YAY we are controlling electric!

There are two files controlling the LED. Look at the code for each file by sending each one of these commands.

cat nova-starter-kit/01_blink/main.py

Main.py references another file for its LED commands, myLED.py
. Let's look at this file too.

cat nova-starter-kit/01_blink/myLED.py

Be Ambitious!

I've added some additional functions in myLED.py which you can access in main.py. Go ahead, edit main.py and call some more functions from myLED.py. Run your modified code and see what happens:

sudo nano pi-starter-kit/01_blink/main.py

Lesson 2 - Read a Digital Sensor

In this lesson we'll add a digital sensor and read it's value. The DHT11 senses humidity and temperature, sending the results through a digital signal. The Pi's pins can read digital sensors out of the box.

In this lessons code folder we add a new file called myDHT.py
. In this file we set a pin as an input and create some functions for common uses. Adafruit's DHT python library is the real star, making it super simple to read the DHT sensor.

After verifying the DHT library is installed, we're ready to run my lesson script. Run the code by issuing the following command.

sudo python nova-starter-kit/02_digital_sensor/main.py

The terminal will not ask you any questions, instead the LED will blink 3 times and display the current Temperature and Humidity in the terminal. Check out the changes I made to main.py

cat nova-starter-kit/02_digital_sensor/main.py

main.py
imported a new file, myDHT.py
. Let's look at this file too. Like myLED in the previous lesson, I added a few extra functions.

cat nova-starter-kit/02_digital_sensor/myDHT.py

Your skills are heating up!

Lesson 3 - Read an Analog Sensor

In the last lesson we read from a digital sensor, a sensor sending 1's and 0's. There is another way some sensors communicate called analog. Analog sensors can send any value.

Some boards, like the Arduino UNO, can read from both types of sensors. Unfortunately the Raspberry Pi can only read digital sensors. In order to read analog sensors we'll need an Analog-2-Digital Converter between the analog sensor and the Pi. This chip will convert the analog signal into a digital output and send it to the Pi.

In this lesson we're setting up an MCP-3008, which converts the value we get from a light sensor (called a photoresistor) and sends it to the Pi. We're adding another Adafruit python library, this time for the MCP chip.

One more note on the MCP-3008. It provides 8 ports, meaning it can read up to 8 analog sensors. We're sending data to port 0. In main.py
you'll notice we set which port the photoresistor is using as a global variable.

Wiring Diagram

Below is how you should connect everything. It's important the MCP3008 is facing the correct way. Make sure the notched end is on the left. There are a lot of wires required for the MCP3008 so take your time and double check everything.

Note: Remember to remove power down the Pi before wiring.

Reconnect power, wait a minute, and re-establish an SSH connection.

Run the Code 🏃💨

The coded needed for this lesson is already on your Pi, found in the folder you cloned from GitHub.

ls nova-starter-kit/03_analog_sensor/

Before we can run the code I've created you'll need to install Adafruit's MCP library. Clone the new library.

git clone https://github.com/adafruit/Adafruit_Python_MCP3008.git

Run the install script Adafruit provides.

sudo python Adafruit_Python_MCP3008/setup.py install

After the MCP install is complete it's time to run the lesson script. Run the code by issuing the following command.

sudo python nova-starter-kit/03_analog_sensor/main.py

The terminal will not ask you any questions, instead the LED will blink 4 times and display the current Temperature, Humidity, and now Luminosity in the terminal.

Check out the changes I made to main.py

cat nova-starter-kit/03_analog_sensor/main.py

main.py
imported a new file, myMCP.py
. Let's look at this file too. Like myDHT in the previous lesson, I added a few extra functions.

cat nova-starter-kit/03_analog_sensor/myMCP.py

The future's looking brighter than ever!

Lesson 4 - Trigger with a Button

Ok, we have a fully functioning set of sensors! But, triggering the script through a terminal in a SSH session is not ideal. In this lesson we setup a button to trigger a reading and set the script to continuously loop after the pi boots.

Wiring Diagram

Wiring this button should be a cinch for you now:

Reconnect power, wait a minute, and re-establish an SSH connection.

Run the Code 🏃💨

The coded needed for this lesson is already on your Pi, found in the folder you cloned from GitHub.

ls nova-starter-kit/04_button/

Run the code by issuing the following command.

sudo python nova-starter-kit/04_button/main.py

The terminal will not do anything while it waits for you to press the button. You'll get a reading every time you press the button.

What is happening is called an infinite loop. The script will not stop until you manually stop it. What is the script doing? Listening for a button press. Exit the loop by pressing CTRL + C. Check out the changes I made to main.py

cat nova-starter-kit/04_button/main.py

Run the Code ... at Startup! 🔌 🏃💨

We have a button and sensors, yay! but we still need the terminal to start the Python script. Let's set the Pi to automatically run this script at startup.

To do this we'll need to edit a system file using the NANO terminal editor again.

sudo nano /etc/rc.local

This will open a file with important contents already in it. Uses arrows to scroll to the bottom of the document. Move the cursor before the exit0
and add the following line:

sudo python /home/pi/nova-starter-kit/04_button/main.py &

Press CRTL+X to exit, Y to save, ENTER to confirm and exit the Nano editor. Back in the normal terminal we'll reboot the Pi.

sudo reboot

After a few minutes press the button and if the light flashes 4 times then it worked! Now every time you power the Pi this script will be running in the background.

Lesson 5 - Send Data through WiFi

Our script is running at startup, great! But we still need to SSH into the terminal to see the data. Instead let's send the data through WiFi to Hologram's Data Engine.

Lesson 6 - Send Data through Cellular

Imagine you want to stick this environment sensor array somewhere with no WiFi, like a storage shed or vacation home.

In this lesson we'll add cellular to the script. Steps in this lesson is very similar to the previous.

First, follow the Nova's assembly instructions included with the packaging. Make sure the SIM is inserted correctly and plug the Nova into the Pi. Wait for a solid LED to show on the Nova, followed by a second LED blinking. This means you have an available cell network to connect to.

Connect to your Pi through SSH and edit the startup rules to use the main.py
file in lesson 6.

sudo nano /etc/rc.local

Change the second to last line from:

sudo python /home/pi/nova-starter-kit/05_cloud/main.py &

to

sudo python /home/pi/nova-starter-kit/06_cellular/main.py &

Remember this needs to go before exit0
.

Press CRTL+X to exit, Y to save, ENTER to confirm and exit the Nano editor.

Back in the normal terminal we'll reboot the Pi.

sudo reboot

After a few minutes press the button and if the light flashes 4 times then it worked!