Raspberry Pi Unleashed – Setup the GrovePi+


This is the next post in my series around the Raspberry Pi and the Internet of Things.. To talk about Internet of Things our Raspberry Pi should actually do something and provide some data or service. In this post we will set up the Raspberry Pi with the GrovePi I/O board and sensors. The Raspberry Pi will also be referred to as RPi in the posts.

Related Posts

  1. Raspberry Pi Unleashed – Getting Started with the Internet of Things and the Raspberry Pi
  2. Raspberry Pi Unleashed – Setup the GrovePi+ – this post

Start All Over

I already had setup the GrovePi+ once on a NOOBS based Raspbian Jessie full desktop image for testing. This was just to understand the process a bit and get used to the RPi. To be able to blog about it, I wanted to do this process again. So I decided that I wanted to start with a Raspbian Jessie Lite, a minimal image based on Debian Jessie. Devices in the Internet Of Things are probably usually only set up with the essential software they need to function. So I was curious what I needed to do to get this up and running.

Initial Install

So I started all over again.

After power up, the Raspberry Pi started without any issues and I was able to login using the Keyboard and my monitor. There is only a shell available in the new image.

PIE_With_Peripherals

Install Without a Display and Keyboard

It should be possible to avoid having to use a display and peripherals on the RPI to set it up, only using the network connection. The best approach would be to use an image instead of the NOOBS distribution. It is necessary to connect to the RPi once it is up. This requires to be able to see the IP address. In a local environment, you might have access to the router to be able to determine and even set the RPi’s IP address. In other environments, follow the tips in this blog to find the IP address using special tools such as nmap or Zenmap.

Once you have the IP address, use a SSH shell connection (e.g. using Putty on Windows) to the RPi. This allows copy and paste as well as screenshots to create documentation.

Use a SSH Shell Connection

The big display is more useful as a secondary display to the laptop. I set up my network so that the RPi always gets the same IP address for Ethernet and WLAN. At this point Ethernet was working  which allowed to connect to the RPi with SSH and to login.

Connected_1

This shell is going to be used to setup the system and add all needed packaging.

Install GIT

From my prior experiments I knew that I would need GIT to be able to set up the GrovePi+. The Raspbian Jessie Lite does not have GIT installed – i tried running GIT from the shell, and the program was not found. A quick search on the internet shows that this can be changed easily by running

sudo apt-get install git-core

The image loaded all needed packages and installed GIT. I had to press ‘y’ to  perform the install process.

Install the GrovePi software

Shutdown and Switch Off

It is necessary to shutdown the system before switching it off. By running

sudo shutdown

The shutdown is initiated. The connection will be lost after some time and it is safe to switch power off.

Connect GrovePi+ Board

Make sure the Raspberry Pi is shutdown and power is off.  Unfold the first section Connect the GrovePi+ to the Raspberry Pi in the description to connect your GrovePi+ to the Raspberry Pi.

Setting Up The Software for the GrovePi+

Make sure everything is nicely connected and start the RPi again. Connect to the RPi and log in.

To run the GrovePi+ it is necessary to install some additional software. The manufacturer provides this Getting Started description for the steps. I found this a bit confusing, as some of the steps refer to a special Raspbian image I don’t have here. The following steps worked for me.

Follow this link to set up the software for the GrovePi+. The link can be found on the right side of the Getting Started description.

The original description uses sub folders in the folder /home/pi/Desktop to install this software. Since there is no UI and thus no desktop the following steps install the necessary software into sub folders of the folder /home/pi/.

The first step is to download the software and drivers using GIT.

cd /home/pi/
sudo git clone https://github.com/DexterInd/GrovePi.git

It will take a short while to download the software. Once the data is available locally in the folder GrovePi, it can be installed by running

cd /home/pi/GrovePi/Script
sudo chmod +x install.sh
sudo ./install.sh

Please note, all the executable and shell scripts in the folder tree cloned by GIT are missing the executable permission, so running a script always requires to set the executable permission, this is a common pattern.

After the install was performed the system will automatically reboot, if this is not prevented. In any case, if you haven’t already connected the  GrovePi+ board, shut down the Raspberry Pi, switch off the power and install the GrovePi+ board.

To test if the GrovePi+ board is available you can run

sudo i2cdetect -y 1

The result should look like the image below:

Test_GrovePi

If you can see a “04” in the output, this means the Raspberry Pi is able to detect the GrovePi+ board. What it does is to check for I2C ports. I2C is a connection standard that is often used as interface for sensors and devices. You can find the technical details and tutorial for the GrovePi here. This includes the information about the available connection ports here.

If you followed my advice to go for option 2 in the last post and bought a LED for the GrovePi+,   you can test that now as described in step 10 in this link to set up the software for the GrovePi.

If you followed Tim’s shopping list you can use the Grove Barometer for testing.

If you haven’t connected your sensor or device to your GrovePi+, you should shutdown and power down the RPi. It is always a good idea to power off if connecting something to a hardware, if not stated otherwise.

Look up the connection method for your sensor or device. Connect the device to the port required.

Example The Grove Barometer sensor details for the RPi are described here in the Wiki. Look at the GrovePi+ port description and look up an I2C port. Connect the Grove Barometer Sensor to the chosen port.

Power up the RPi, open a connection and log in.

Example the Grove Barometer Sensor. Make the sensor Python scripts executable.

# Make the high accuracy barometer sensor example script executable
cd /home/pi/GrovePi/Software/Python/grove_barometer_sensors/high_accuracy_hp206c_barometer 
sudo chmod +x high_accuracy_barometer_example.py

Once this has been performed successfully, run the sensor example script to read the sensor like below

# Read high accuracy barometer sensor using the example script
cd /home/pi/GrovePi/Software/Python/grove_barometer_sensors/high_accuracy_hp206c_barometer 
sudo ./high_accuracy_barometer_example.py

You should see something similar to the image below.

Barometer_Sensor_Test

The sensor was successfully read and you can now go ahead and use the GrovePi+ board and the I/O devices you purchased for it. If you run into issues, you might wnat to upgrade the firmware for the GrovePi+ if you have not already done so.

Firmware Update for the GrovePi+

It is always a good idea to make sure your peripherals have the latest firmware. The procedure to upgrade the firmware for the Grove PI+ is described here.

Essentially you perform the steps below

# Firmware update 
cd /home/pi/GrovePi/Firmware
sudo chmod +x firmware_update.sh
sudo ./firmware_update.sh

I ended up having problems with the first NOOBS Raspbian image I used and the described procedure was unable to locate the GrovePi+ board. The sensor board was not recognized and the update never started. A blog entry hinted to use the Raspbian_For_Robots update scrips instead which worked.

# Firmware update Raspbian_For_Robots
cd /home/pi/
sudo git clone https://github.com/DexterInd/Raspbian_For_Robots.git

cd /home/pi/Raspbian_For_Robots/upd_script
sudo chmod +x update_GrovePi.sh
sudo ./update_GrovePi.sh

sudo chmod +x update_GrovePi_Firmware.sh
sudo ./update_GrovePi_Firmware.sh

Enable the Wireless Connection

After getting rid of the dedicated monitor, keyboard and mouse for the Raspberry Pi it was time to see how to enable the wireless connection with this image. A search in the internet provides with this Wiki page how to set up WIFI in Raspbian using the command line.

The steps are simple, assuming there is a Edimax Wi-Fi USB Adapter Nano Size or another supported WIFI USB adapter connected to the RPi. Start a detection run to find the available networks like this.

# Detect networks
sudo iwlist wlan0 scan

You should get a list of networks with details such as the ESSID and the authentication used, similar to below:

Wireless

As described in p WIFI in Raspbian using the command line edit the configuration file and add the required information.

# Edit WIFI configuration file
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Modify the file as described. My result was like beow. I changed the country code and added the network that should be chosen.

Wireless_Config

After saving the configuration changes and rebooting (the other suggested measures did not work for me) my Raspberry Pi was connected to the wireless network.

Please note, Like for the Ethernet connection I configured my VDSL router/wireless network to provide the same IP address to the Raspberry Pi. This allows to use a remote connection reliably in my network. Otherwise I would have needed some DSL or other name resolution to be able to reliably find the IP address for my Raspberry Pi to open the wireless SSH connection.

Up and Running

All the important parts are now up and running on the device and most of the periphery that made it look like a desktop commuter is gone. Now it is ready to join the Internet of Things.

PiWireless

Summary

Now the Raspberry Pi is configured to use the GrovePi+ I/O board and the sensors. The driver software is available.

This was actually really easy to do and the documentation I found was really good enough to get me going really quickly. This is no comparison to bringing up a custom RTOS on a custom board where you might even have to create your own device drivers to get the system working. I am not sure if python scripts can be debugged. I am not yet sure if it is possible to set up a cross development and debugging environment on my laptop to develop and deploy on the RPi, that remains to be seen.

I will now have a look at how to connect to Bluemix to provide some data/service and try to get my thing into the internet…… Hmmmm, that does not sound right.

Advertisements

About rsjazz

Hi, my name is Ralph. I work for IBM and help colleagues and customers with adopting the Jazz technologies.
This entry was posted in Internet Of Things and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s