[SOLVED] BrickPiSetupSensors() returning -1


#1

I have rasberrypi 3 and a brickpi, just starting and trying to run the LEGO-Motor_Test.py. The terminal gives feedback “Running Forward / Running Backward”; but our LEGO EV3 motors are not working.

Then I tried running the following commands in the python IDLE, but the “BrickPiSetupSensors()” returns -1.

from BrickPi import *
BrickPiSetup()
BrickPi.MotorEnable[PORT_A] = 1
BrickPiSetupSensors()

Help.


#2

The code you’re trying to run is for the BrickPi+ and will not work with the BrickPi3. Please see here to confirm which BrickPi version you have.

BrickPi3 Python examples can be found here.


#3

That was the issue. I pulled the code from github, then I tried to run the following command, but got the following error.

COMMAND:
sudo python LEGO-Motors.py
ERROR:
Traceback (most recent call last):
File “LEGO-Motors.py”, line 22, in
BP = brickpi3.BrickPi3() # Create an instance of the BrickPi3 class. BP will be the BrickPi3 object.
File “/home/pi/Dexter/BrickPi3/Software/Python/Examples/brickpi3.py”, line 293, in init
manufacturer = self.get_manufacturer()
File “/home/pi/Dexter/BrickPi3/Software/Python/Examples/brickpi3.py”, line 409, in get_manufacturer
raise IOError(“No SPI response”)
IOError: No SPI response


#4

Are you sure the BrickPi3 is properly connected to the RPi GPIO header? Did you remove the foam block from the BrickPi3 GPIO header?


#5

I believe so, yes I removed the foam block.

I tried running the following, and got this response:

sudo bash /home/\pi/Dexter/BrickPi3/Firmware/brickpi3samd_flash_firmware.sh

Updating the BrickPi3 SAMD Firmware with '/home/pi/Dexter/BrickPi3/Firmware/brickpi3_firmware.bin’
Traceback (most recent call last):
File “”, line 1, in
ImportError: No module named auto_detect_rpi
Using interface file 'rpi1.cfg’
sudo: openocd: command not found


#6

Did you run the installation as described in the README? Those are errors I would expect to see if you haven’t run the install.sh script using sudo bash /home/pi/Dexter/BrickPi3/Install/install.sh.


#7

I just ran the install, and all seemed to work fine. Rebooted, but I’m still getting same errors above.

I purchased the Dexters SD Card with Raspbian pre-installed expecting this all to ready to go.


#8

I ran the “Test and Troubleshoot” icon on the desktop, and got the following response:

Xlib: extension “RANDR” missing on display “:1.0”.
Must be connected to a terminal.


#9

This is a normal response, should not be a problem.

To @Matt’s point, this should be running if you’re using the SD card that shipped. Everything should be installed correctly.

Can we back up and just confirm which version of the BrickPi you have? Is it a BrickPi3 or a BrickPi+? Until we do that, we won’t know which version of the python software you’re using.


#10

It is a BrickPi3.

So the SD card that I purchased from DI, should be up to date? I was thinking of downloading the lastest version of Raspbian and install that on a new SD card.


#11

If you’re running Raspbian for Robots (our version of Raspbian with the robot software already installed), you can go to the desktop and run the DI Update utility to make sure the SW is fully up to date. During the update, the RPi needs an internet connection, and the update can take several minutes (it will probably take a few minutes before the GUI comes up). If you prefer to run Raspbian instead of our Raspbian for Robots, you can still install/update BrickPi3 (instructions in the README).


#12

Finished running the DI update utility.

What should I do now?


#13

Hi @c-spurgeon,


Now that you’ve updated DI Software, you can do 2 things in the following order:

  1. Flash the firmware onto BrickPi3.

  2. Try one of the example programs for the BrickPi3.
    The example programs are already loaded on your Raspberry Pi, so you only need to type cd ~/Desktop/GoPiGo3/Software/Python/Examples. If everything is a go, then the command should work.


We’ll be here to assist you in case something else (and hopefully not) goes bad.

Thank you!


Brickpi 3 won't boot after editing crontab
#14

That fixed my problem, thanks for your help!!!


#15

This topic was automatically closed after 32 hours. New replies are no longer allowed.