The past week I received a BrickPi and connected it to my Raspberry Pi without problems. I connected a Lego ultrasonic sensor to, what on the diagram
is S1. I wrote a very simple python script, assigning BrickPi.SensorType[PORT_1] = TYPE_SENSOR_ULTRASONIC_CONT and ran a 60 sec loop updating result = BrickPiUpdateValues() and print BrickPi.Sensor[PORT_1].
All worked as expected. So I added a Lego touch sensor on S2 and to the python script added BrickPi.SensorType[PORT_2] = TYPE_SENSOR_TOUCH and print BrickPi.Sensor[PORT_2]. Running the script, neither sensor worked.
I modified the script, commenting out the references to the touch sensor and the sonic sensor worked. To shorten the story, after further experimentation, it doesn’t matter whether a sensor is connected to S1 or S2, I have to use PORT_1 to address both S1 & S2 and, as expected, I can only have 1 sensor defined in the python script and it doesn’t matter whether to sensor is connected to S1 or S2 as long as the script uses the value PORT_1.
Any questions, suggestions or comments?
I’m sorry for the confusion here. I think the problem might have been solved a month back with the Ultrasonic sensor; in April we did a push up to Github with the latest code for Python. There was an error with the drivers we corrected.
These errors were in the BrickPi.py module, which we corrected, but needs to be reinstalled.
To update the BrickPi.py module:
I hope that helps. We’re sorry about the extra work this presents!
We were just digging into the firmware again yesterday and sorted out a few more bugs. If you haven’t updated the software yet, I recommend making sure you get the latest version out of github.
You’ll need to uninstall the old version, and re-install the new version.
To uninstall the old version of BrickPi.py:
sudo python setup.py install --record files.txt
cat files.txt | xargs sudo rm -rf
To install the new version of BrickPi.py, make sure you have the latest from github, and run
sudo apt-get install python-setuptools
sudo python setup.py install