IoT on Your Raspberry Pi

Building the SunIOT

With the use of Grove connectors, you can put this project together easily by following these steps (Figure 9):

Figure 9: The completed SunIOT project. The Pi2Grover piggybacks on the RPi3, the Grove LED plugs in to the D4/5 connector, and the Grove sunlight sensor plugs in to an I2C connector.
  1. Remove power from the Raspberry Pi. Be sure to shut it down before you remove power! (See the "Break Off" box.)
  2. Take the Pi2Grover and align the pins on the RPi3 GPIO header accurately; then, carefully push down on the Pi2Grover board. Note that the end of the Pi2Grover board hangs over the USB and Network plugs on the RPi3; however, the Pi2Grover board has no pins on the bottom, so it can't short out.
  3. Take your Grove Sunlight Sensor, plug in a Grove cable to the device, and then plug in the other end of the cable to any of the I2C plugs on the Pi2Grover board. Any of the I2C connections work because I2C is a bus and not an individually addressable plug like the digital Grove connectors.
  4. Now take you Grove LED and plug in one end of a Grove cable to the Grove LED device and the other end to the Pi2Grover digital Grove connector marked D4/5.

That's it! Now power up your Raspberry Pi, and if all is well, you will see a blue LED on the Pi2Grover board, and, most of the time, you will see the Grove LED turn on (the GPIOs on the Raspberry Pi wake up as inputs, so the pull-ups in the voltage translation circuitry will either resolve the input as a 1 or as a 0 – usually a 1.

Before you are ready to run the SunIOT.py program, you have a bit of setup to do on your RPi3.

Break Off

Warning! Always turn off the power before you remove or replace any Grove devices on your Raspberry Pi. You could damage your devices or your Raspberry Pi!

Set Up the I2C Bus

The Raspberry Pi operating system does not enable the I2C bus by default. To enable it, open a terminal, run

sudo raspi-config

and go to the Advanced Options. Now Select I2C, say Yes when asked whether you want to enable the interface, then OK. After tabbing to Finish, make sure to reboot before continuing. You can also enable I2C from the Raspbian "jessie" desktop in the Interfaces tab of Preferences | Raspberry Pi Configuration.

Now that I2C is enabled, type the following into a terminal:

sudo i2cdetect -y 1

If everything is good, you will see the output in Listing 1 (0x60 is the Sunlight sensor).

Listing 1

i2cdetect Output

pi@RPi3-62:~/SunIOT $ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Buy this article as PDF

Express-Checkout as PDF

Pages: 6

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content