BeagleBone Green Wireless

Hello Forum Community,

I am a total newb when it comes to all things IoT and have learned a lot in the past couple of months as I have been researching how to go about a project idea. I decided on the BBG Wireless, Grove Cape, and Grove components, primarily because this platform seems to take a lot of the complexity out of things.

Presently I’m attempting to wire up 6 Grove buttons that perform various functions. As I am in need of having other components (and therefore require the other grove ports), I thought I could use a Grove I2c Hub to connect my buttons and code the interactions. I can get the components to work, but I can’t seem to figure out how to code it in a way that allows me to write functionality per button. I’m fairly certain I know why, as my python code is simply going after specific pins, but does anybody have an idea on how I could go about doing this cleanly?

Perhaps there is a better way to handle this type of thing?

I’m under no grand illusion that I understand anything, but thought I’d ask the community for help!

Thanks!

Hi James!

You neither need a Grove Cape nor any other additional hardware. Just configure header pins as GPIO input with pull-up resistor and connect simple buttons to pull the pins down to ground when pressed. Check out the button example in the libpruio project.

BR

On Sat, 12 Nov 2016 09:04:01 -0800 (PST), James Hawes
<james@jameshawes.net> declaimed the following:

Presently I'm attempting to wire up 6 Grove buttons that perform various
functions. As I am in need of having other components (and therefore
require the other grove ports), I thought I could use a Grove I2c Hub to
connect my buttons and code the interactions. I can get the components to
work, but I can't seem to figure out how to code it in a way that allows me
to write functionality per button. I'm fairly certain I know why, as my
python code is simply going after specific pins, but does anybody have an
idea on how I could go about doing this cleanly?

  The buttons are simple GPIO devices; they are not software addressable.

  I2C is a protocol where devices have addresses, but share the same
wiring. When communicating with the devices, the host sends the address as
a bit-stream followed by a command. All the devices on the line are reading
the bit-stream but they only respond if the address is the one assigned to
them.

Perhaps there is a better way to handle this type of thing?

  In direct usage, you'd need 6 GPIO pins to read 6 buttons. You might be
able to reduce that to 5 GPIO if you matrix the buttons and perform
software scanning.

B1 B2 B3 <> GPIO "1out"
B4 B5 B6 <> GPIO "2out"
3 4 5
i i i
n n n

Assume you have pull-up resistors on the three input lines. You'd set 1out
low and 2out high, then read 3in/4in/5in; any pin that comes back low means
the button in that column and 1out row was pressed. Then you set 1out high
and 2out low and reread the pins to find if any in the 2out row are
pressed. Never set both 1out and 2out low at the same time as you can't
tell which button is pressed in the column. You could also put the pull-ups
on the rows, change the rows to input pins, and change the columns to
output pins. You then would cycle LHH, HLH, HHL on the columns, while
reading the row pins to determine which button was pressed.

Using 6 GPIO would let you matrix a 3x3 set of buttons. But at that point
you might want to locate an actual I2C 4x4 keyboard -- or an I2C interface
to a regular 4x4 keyboard
http://bradsduino.blogspot.com/2013/01/i2c-version-of-using-4x4-universal-16.html

(obviously the code is Arduino biased, but the pinout of the chip is
compatible. Though the chip is obsolete at Mouser)