Tuesday, January 24, 2017

BeagleBone Green Wireless IoT Developer Prototyping Kit

Have you noticed that Google Cloud is promoting an IoT Developer Prototyping Kit which features the BeagleBone Green Wireless (BBGW)? I purchased one, because I was hoping for better instructions on using the Grove System w/BBGW.

Sadly, the only documentation included w/the proto kit is a lame brochure w/a cloud solutions URL with unhelpful Arduino examples.  Yaay for Arduino, but I bought the BBGW kit.

Fine.  Challenge accepted.  Here are some notes on using BBGW and Grove System.

There are dedicated images for the BBGW and any Debian reference (within this post) is tied to bone-debian-8.6-seeed-iot-armhf-2016-11-06-4gb.img

"Grove is a modular, standardized connector prototyping system." which is a good single line summary.  The catalog is full of many sensors, switches and shiny, blinky things which plug into standard connectors.  The BBGW exposes two Grove connectors, one for I2C and the other to UART.  Two connections are OK to start, but you most likely will want the Grove Base Cape (included in proto kit) because this offers more connections and access to the ADC.

If you already know the BB, you will not be surprised to learn that the Grove connectors map directly to P8/P9 and there is no added functionality apart from the connectors.  Put another way, anything you can implement w/Grove could also be implemented the usual way via overlays and P8/P9.

There has to be software to control the interfaces and BBGW Grove promotes MRAA as a wrapper to the BBGW devices.  MRAA comes w/the Debian Seeed image and has (yet another) pin encoding scheme.  Look here for pin mapping.  The Debian Seeed image also has example python code in /usr/share/mraa/examples/python

Start easy w/a GPIO demo "blink-io8.py"

import mraa
import time


# Using BBG GPIO_51
x = mraa.Gpio(62)
x.dir(mraa.DIR_OUT)

while True:
  x.write(1)
  time.sleep(0.2)
  x.write(0)
  time.sleep(0.2)


Note the "mraa.Gpio(62)" which maps to P9_16 on BBGW and has a dedicated socket on the Grove Base Cape (look at the middle row, the GPIO are silk screened next to the Grove sockets).

Use the 3 axis accelerometer from the proto kit as an I2C example.  One of the Seeed example worked, scroll to item "03 How to use Grove - 3-Axis digital Accelerometer (16g)" for a python example.

Now for an ADC example, look at this Seeed project (scroll to "02 How to use Grove - Light Sensor & Temperature Sensor").  The wiring diagram is OK (i.e light sensor to AIN0 and temperature to AIN2) but the code is not quite working.  Here is the corrected code:
import time
import pyupm_grove as grove

light = grove.GroveLight(1)
temp = grove.GroveTemp(3)

while True:
 print light.name() + " raw value is %d" % light.raw_value() + ", which is roughly %d" % light.value() + " lux"
 celsius = temp.value()
 fahrenheit = celsius * 9.0/5.0 + 32.0
 print "%d degrees Celsius, or %d degrees Fahrenheit" % (celsius, fahrenheit)
 time.sleep(2)

What about those two Grove connectors on the BBGW?  One is for UART, the other is I2C, both support GPIO.  Here is an example Python script which uses the UART connector w/a button:
import mraa
import time

x = mraa.Gpio(68)
x.dir(mraa.DIR_IN)

while True:
 time.sleep(1)
 if x.read() > 0:
  print 'button press'
 else:
  print 'button not press'


No comments:

Post a Comment