I’ve been trying to find a solid example on how to access a GrovePI sensor attached to one of 4 ports (analog, digital, serial or I2C).
There are pieces information here and there.
Would someone kindly share
- which firmware, if any, has support for GrovePI sensors?
- a Python example for a sensor, say like a GrovePI temp/humidity sensor?
- what pin # to use when accessing these GoPiGo ports?
The GoPiGo has 4 ports: Serial, I2C, digital and analog. The I2C and serial ports are connected directly to the Pi so any of the Serial or I2C sensor which works with the GrovePi works with the GoPiGo too.
From firmware version 1.3 onward, we added the support to read/write the digital and analog ports too: https://github.com/DexterInd/GoPiGo/blob/master/Software/Python/gopigo.py#L244-L297 . You can make these function calls to control the ports.
We don’t have support for the DHT sensor right now for the GoPiGo since that needs work on the firmware to make it work.
The Analog port is connected to A1 and the digital port to D10.
Thanks for the information.
I’m seeing the analogWrite(pin) in 1.3 firmware is limited to pin 10.
I assume that pin = 10 is the only valid value for the analog port?
def analogWrite(pin, value):
if pin == 10 :
There’s no such check in digitalWrite(pin, value). Instead, digitalRead(pin) is limited to pin 0, 1, 10 or 15 as below
if pin ==10 or pin ==15 or pin ==0 or pin ==1:
Can you elaborate on why pin 0, 1, 10 or 15 is valid for a digitalRead?
The pins on the motor controller are connected to the digital pins too. We didn’t want people to accidentally turn on/off the motors or do something else accidentally so we just added the check condition to makes sure that people only access the pins which are broken out on the Grove connectors. Pin 0,1 are on the serial port, pin 10 on the Digital port and pin 15 on the analog port. You can remove this condition if you want but it might be better to just leave it in.