Overview of How to Setup the Pi and GrovePi

The First Step

Step 1: If you run into any problems at all, please start by searching for that issue on Google! You might be amazed at how almost all of the problems you come across were already asked and resolved on the web.

And, failing that, please post in our class forums. When you do post, please do feel free to include screenshots from the raspberry pi to help give details of the issue. Almost all of these hints are garnered from a combination of online forums, class forums, and voodoo programming. :)

Getting the Raspberry Pi Kits

Picking a raspberry pi starter kit: whether you get the Vilros kit or the CanaKit they include the same stuff just with different names (but the Vilros kit SD card has retropie on it which the CanaKit does not but most of the programs are open source so they are free). You can always use Etcher to install the appropriate image, as well, as long as the hardware is functional.

For the GrovePi sensors, you can get either the GrovePi+ Starter Kit or Seeedstudio-GrovePi+ Starter Kit, as well.

Install an Operating System for the Raspberry Pi

The Raspberry Pi (RPi) runs an operating system called raspbian, which is a Debian-derivative designed especially for the raspberry pi. The version of Raspbian it installs will likely come with the Raspberry Pi Desktop (RPD) GUI and be based on the latest version of Debian at the time (the newest version of Debian is currently Stretch but was previously called Jessie). Your RPi likely comes with the default raspbian installer on the SD card called NOOBS ("New Out Of the Box Software"). NOOBS for installing raspbian is available directly from raspberry here: https://www.raspberrypi.org/downloads/noobs/. You can also find out more about using NOOBS here: https://www.raspberrypi.org/magpi/beginners-guide-noobs/

Your options for installing Raspbian are:

Once you've installed Raspbian, you can then go on and install the GrovePi hardware and software separately.

SSH Headless Mode

If you're more advanced, you can even setup your pi in headless mode so you won't need a monitor. You can setup networking by initially using an ethernet cable and then SSH'ing into it to setup wifi, as well. In order to setup SSH, you'll likely need to go into raspi-config and enable the SSH server to allow access in headless mode or follow the directions below to do it when you first make the micro-SD card.

Getting started with the GrovePi

You'll need to do the following:

  1. Setup the GrovePi Software on the RPi by doing one of the following (more details below and in the first module):
  2. Update the Firmware as shown here: https://www.dexterindustries.com/GrovePi/get-started-with-the-grovepi/updating-firmware/
  3. Do this LAST: Power Off the RPi and then Connect the GrovePi hardware to the Raspberry Pi (RPi) as shown here: https://www.dexterindustries.com/grovepi-tutorials-documentation/

You can see a detailed guide on getting started from GrovePi here: https://www.dexterindustries.com/GrovePi/get-started-with-the-grovepi/ 

You can see specific Setting up the Software guide from Dexter Industries that includes very detailed instructions here: https://www.dexterindustries.com/GrovePi/get-started-with-the-grovepi/setting-software/ 

Finally, you can also reference the Dexter Industries GitHub repository and guide here: https://github.com/DexterInd/GrovePi




Detailed Steps for Setting up the Raspberry Pi (RPi)

Here is a simple guide/overview of the RPi setup. You should either install RaspberryPi.ORG's Raspbian Stretch or install Dexter Industries' Raspbian for Robots.

Installing Raspbian Stretch

The following guide is for Raspbian Stretch but the process is similar for Dexter Industries' Raspbian for Robots.

Setting up GrovePi

GrovePi Setup for Raspbian Stretch

For Raspbian Stretch, you can install and run the GrovePi software by doing the following:

  1. First, log into the RPi and update/install the GrovePi software
    curl -kL dexterindustries.com/update_grovepi | bash 
    
    as shown here: https://www.dexterindustries.com/GrovePi/get-started-with-the-grovepi/setting-software/
  2. Next, update the firmware via sudo /home/pi/Desktop/GrovePi/Firmware/firmware_update.sh as shown here: https://www.dexterindustries.com/GrovePi/get-started-with-the-grovepi/updating-firmware/
  3. Then, reboot with the GrovePi hardware attached, add the LED light, and see if the LED light comes on after you run /home/pi/Dexter/GrovePi/Software/Python/grove_led_blink.py as shown here: https://www.dexterindustries.com/GrovePi/get-started-with-the-grovepi/setting-software/

Check the GrovePi: Run the tests!

Run the Tests for your GrovePi system:

ALTERNATIVE: GrovePi Setup for Raspbian for Robots

NOTE: If you're running Raspbian for Robots, it's still on Jessie. In that case, please just click on the following icon to do an update:

This icon refers to this shortcut:

pi@dex:~/Desktop $ more desktop_shortcut_update.desktop

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Exec=lxterminal  --title "Update in Progress - Do not close this window!" --command "sudo" "bash" "/home/pi/di_update/Raspbian_For_Robots/update_master.sh"
Icon=/home/pi/di_update/Raspbian_For_Robots/desktop/DXT_Icon_64x64_Update.png
Terminal=false
Name=DI Software Update
Comment= Programming system and content development tool
Categories=Accessories;

This can be found on the Desktop. After you run this, please update both the Software and the Firmware for GrovePi using the same update tool.

Ports on GrovePi

The GrovePi has Analog input, Digital input/output, and I2C output ports as shown below and detailed http://thinglabs.io/workshop/thingy-4-windows/grovepi/ and https://www.dexterindustries.com/GrovePi/engineering/port-description/

The sensors and actuators included in the GrovePi+ Starter Kit can be classified as follows:

Type Direction Examples GrovePi API Calls
Analog Input Light sensor, Temperature sensor, Rotary Angle sensor, Sound sensor SensorValue()
Digital Input Button, Ultrasonic Range sensor CurrentState(), MeasureInCentimeters()
Digital Output LED, Buzzer, Relay ChangeState(SensorStatus)
I2C Output RGB LCD Display SetBackLightRgb(r,g,b), SetText(string)

This is also shown in the image below:

So if you were to connect the Digital Humidity and Temperature (DHT) sensor and the LCD Output Screen, you'd hook it up to the GrovePi as below, with the DHT on a Digital Port (here, D7) and the LCD on an I2C port (here, I2C-2):

This is also detailed here: https://www.dexterindustries.com/GrovePi/projects-for-the-raspberry-pi/raspberry-pi-temperature-sensor/

The other thing to add in would be an LED bulb (like Red or Green or Blue) on a Digital port like D4 so you can do the default test of grove_led_blink.py (https://github.com/DexterInd/GrovePi/blob/master/Software/Python/grove_led_blink.py)




Additional Miscellaneus Notes

GrovePi API Links

If you're interested in what some would consider lower level programming guides, you can find them here:

https://www.dexterindustries.com/GrovePi/programming/python-library-documentation/

You can also poke around the code base on GitHub here:

https://github.com/DexterInd/GrovePi

Finally, here are some additional links:

Issues with the GrovePi and DHT-11 Temperature/Humidity Sensor

Once you connect the GrovePi and the DHT-11 sensor, you might run into the following issue: if your initial run of the program results in the display showing -1 for both temperature and humidity (-1,-1), you should likely start by upgrading the firmware using the bash script found on the GrovePi board included in the installed software, as discussed here: https://forum.dexterindustries.com/t/raspi-grovepi-temperature-humidity-sensor-showing-1-1/3662/14

You can check your firmware versions as follows:

pi@iot1:~/GrovePi/Software/Python $ pwd
/home/pi/GrovePi/Software/Python
pi@iot1:~/GrovePi/Software/Python $ ls *version*
grove_firmware_version_check.py
pi@iot1:~/GrovePi/Software/Python $ sudo python grove_firmware_version_check.py
GrovePi has firmware version: 1.2.7

This thread seems to explain a little of the why a firmware upgrade with subsequent grovepi reinstallation:

https://forum.dexterindustries.com/t/solved-dht-sensor-responding-1/2815/4

I suspect some of the manufacturers are not up to speed with Raspian/Debian Stretch. Anyway, for those that may still have this problem the following is what I did to reconcile my system:

Note: $DEXTER_HOME on my system is /home/pi/Dexter. Some may have it as /home/pi/Desktop
#update firmware
cd $DEXTER_HOME/GrovePi/Firmware sudo bash firmware_update.sh
sudo bash firmware_update.sh
# re-set up grove pi
cd Desktop/GrovePi/Script
sudo bash install.sh
sudo reboot

And, of course, after you do any such upgrade, you should reboot and try the following steps as needed the basic troubleshooting to verify the hardware:

The data coming from the sensor might also have sporadic NaN (Not a Number) errors, as discussed here: https://forum.dexterindustries.com/t/grove-temperature-and-humidity-sensor-nan-value/408/5

The simplest solution to fix this might be to read the sensor, check the return values for NaN, and if there aren't any NaN values, then update the screen. Reducing the polling time can also help reduce the NaN errors so you can change that to 0.5 seconds or some such using the sleep() function, as in time.sleep(0.5) or time.sleep(5), which should catch them all (or 15 seconds if the 5 second timeout doesn't work!).

You might notice the screen sometimes not blanking upon KeyboardInterrupt even though the comments in the code indicate it should. Usually, the blink led program should turn off the led, so if you compare the two, you should find that blink led uses time.sleep and Home_Weather_Display uses sleep. Switching to time.sleep seems to allow the KeyboardInterrupt to be thrown/caught when in time.sleep whereas the KeyboardInterrupt when in sleep was eaten by sleep and not passed along.

If you think it would make more sense to turn the display off when exiting, you can add a line for that to the except KeyboardInterrupt.

Issues with setup

If you try to run the setup.py as in the directions (in the software → Python), you might get an error like this:

PermissionError: [Errno 13] Permission denied: '.tmp_modules'

You can use the quick install command from https://github.com/DexterInd/GrovePi by using the following:

curl -kL dexterindustries.com/update_grovepi | bash

This should do some updates and a reboot and get it working. If it doesn't, you can try the Raspbian for Robots approach below!

Detailed directions for installing Raspbian for Robots

Another thing that might help is a GrovePi customized version of Raspbian. GrovePi maintains its own version of Raspbian called Raspbian for Robots, as shown here: https://www.dexterindustries.com/raspberry-pi-robot-software/

So you can install Raspbian for Robots directly on an SD Card using the following guide: https://www.dexterindustries.com/howto/install-raspbian-for-robots-image-on-an-sd-card/

To install via an SD card, you can use Etcher to load your IMG image file onto the SD Card, as shown here: https://www.raspberrypi.org/documentation/installation/installing-images/ and here https://www.youtube.com/watch?v=dRvHynxGjJQ

If you subsequently upgrade the Raspbian for Robots installation, it might break the connection to the sensor and give you -1's again. If it does so, please do revert back to the original Raspbian for Robots image.

If you are unable to access the DHT-11 (the blue temp/humidity sensor) that came with the GrovePI+ kit, here is a potential workaround in which you can put the Raspbian for Robots directly on the SD card. Here is what I had to do in order to get this to work. Keep in mind that I have a Raspberry Pi 3+ (the newest edition) so support for this newer hardware with the GrovePI+ will vary.

  1. Wipe the SD card and install raspbian directly to the SD. For some reason the NOOBS installer was causing issues.
  2. Update the Raspi from a terminal using:

    sudo apt-get update && sudo apt-get dist-upgrade -y
  3. Reboot the Raspi
  4. Enable all of the Raspi Interface configuration options (you do not need to do all of them, but it eliminates any possible culprits for error)

  5. Run the GrovePI+ update from a terminal window:

    sudo curl -kL dexterindustries.com/update_grovepi | bash
  6. Reboot the Raspi
  7. Update the Raspi again from the terminal:

    sudo apt-get update && sudo apt-get dist-upgrade -y
  8. Reboot the raspi
  9. Now it's time to run some tests. Open a terminal and navigate to the Dexter directory. In there will be a GrovePI directory and in that will be a Troubleshooting directory

  10. In the Troubleshooting Directory run the "all_tests.sh" script with sudo as follows:

    pi@raspberrypi:~/Dexter/GrovePI/Troubleshooting $ sudo ./all_tests.sh
  11. In my case the "/etc/modules" directory was not finding the correct modules:

    Check for addition in /modules
    ===================
    I2C-dev already there
    i2c-bcm2708 already there
    spi-dev already there

    I had to run the following commands in a terminal in order for the raspi to discover the modules:

    sudo modprobe i2c-dev
    sudo modprobe i2c-bcm2708
  12. If you still do not have any luck, you can check the output of the "all_tests.sh" script that creates a log file on the desktop of the raspi for what might have gone awry
  13. Even after the DHT-11 Temperature/Humidity sensor starts reading real values, you'll still likely get some NaN readings from time to time. Restarting the Raspi might fix this but also chaning the polling interval using time.sleep() will help alleviate these issues.

Issues with disk space on the SD card

As you get to Modules 4 and 5, you have to download new packages and might run into disk space issues. For example, if you're i Module 4 and download Postman, you'll likely see the  'out of disk space' messages, which might be confusing if your SD card is 32gb or so like the default one. 

It turns out that Etcher, the ISO burner, creates two partitions, the primary, which is only 40-something MBs, and the secondary, which gets all the rest of the space. The only problem is that this space might not be recognized by Raspbian for Robots and would not be usable then.

To make use of the rest of the space on the SD, please follow the instructions in this link:

https://www.dexterindustries.com/howto/install-raspbian-for-robots-image-on-an-sd-card/

Select "Your First Time Running the New SD Card"

The more painful way might be to use a Linux desktop and use gparted to fix the SD card by resizing the partition to use the full 32gb disk.

Final Troubleshooting Tips

Finally, as a last-minute tip, if other things don't work (or as a first step), please try the following: unplug the sensor and the LCD, reboot the Raspberry Pi, and plug everything back in to see if that helps.

Also, if running sudo python Home_Weather_Display.py gives you an error on Line 51 where you call setRGB() like an IOError 110 (connection timed out) or 121 (Remote I/O Error), that probably means you need to check the hardware, if it's seated properly, connected properly, soldered properly, etc. The i2cdetect command can also help in these cases. Please do check these links for more info about that:

In general, if you get IO errors, things likely aren't hooked up correctly. You might want to start with the Detailed Instructions here, https://www.dexterindustries.com/GrovePi/get-started-with-the-grovepi/setting-software/.

In particular, you might want to try sudo i2cdetect -y 1, as detailed here, as well: https://forum.dexterindustries.com/t/home-weather-display-error/3580

Using i2c on the Pi

Here is a wonderful guide on how to use i2c on the pi in the context of the compass module and the ultrasonic range module and how you can use i2cdetect -y 0 to see what devices are connected to what addresses:

https://www.instructables.com/id/Raspberry-Pi-I2C-Python/

Start Modifying the Python Script

Once you're ready to modify the program, you'll likely have to first change into the main Projects directory, which is probably something like /Desktop/GrovePi/Projects/Home_Weather_Display

Python Idiosyncracies

You might have issues arise when you change the type of the temperature to a float. E.g., you might have been able to change the LCD color based on temp when the tempF variable was an 'int'. However, if you change it over to a float and it no longer evaluates and changes the screen, you can fix that by converting it to a string instead. Python is a little more stubborn with regards to typecasting. Also I think the include that we are getting setText_norefresh from is eating an error, but I haven't looked yet, it makes this hard to figure out though for sure.

If you convert the floats to strings it works OK though, so instead of:

setText_norefresh("Temp:" + t + "F\n" + "Humidity :" + h + "%")

Try:

setText_norefresh("Temp:" + str(t) + "F\n" + "Humidity :" + str(h) + "%")