Errors running LEGO - Motor Test.c


I got my BrickPi yesterday and have managed to get it setup with my WIPI WIFI dongle. Connecting with putty works well though I can’t seem to connect with VNC Viewer (connect: Connection Refused (10061)). But I can get by with putty for now.

I have successfully downloaded the github C files and have successfully compiled “LEGO - Motor Test.c” (suggestion for next time: skip the spaces in the filenames).

I hooked up my 2 LEGO motors to my BrickPi motor ports A and B. It is tricky to get the motor cables to click in (harder than with an NXT brick, and the BrickPi board does wiggle a bunch when I do this, but with care they can be clicked in).

I see three different results depending on how I’m powering the BrickPi.

  1. If I power it only from a 9V battery, I get the messages
    BrickPiSetup: 0
    BrickPiSetupSensors: -1
    and the program exits without any movement from the motors.

  2. If I power it only from the Pi’s external miniUSB connector with an external wall power source, I get the error messages shown in the attachment and the motors don’t move.

  3. If I power it with BOTH the 9V battery AND the Pi’s external miniUSB connector power source, I get the errors messages but the motors do move (yeah!).

So, what are the error messages? Do I need to use 6 high current AA batteries instead of a 9V battery to get it to work better? I couldn’t find any information online regarding powering the BrickPi with different options and what the advantages and disadvantages might be. The BrickPi needs to be able to run off a battery with WIFI for it to be useful (and I want to add a webcam too). I’m guessing I’m doing something wrong?

Thanks for any advice anybody else can provide.

Hey Bill,
Sorry to hear about the troubles here.

First, I assume you’re using the BrickPi image from our website? Or did you do a custom setup of your own image?

Power seems like a good place to start. Do you have a way to replace the 9V battery with a 6XAA adapter? If so, is there a way you could try that out?

What may be happening is that the BrickPi and the WIFI dongle are taking a lot of power up, maybe more than your 9V battery can handle.

If you use the miniUSB adapter to power the RPi, enough power is sent through the 5V rail to power the two microcontrollers on the BrickPi and low-power sensors that you connect. However, with powering by USB, the motors will not run (there’s no power sent to those power rails).

The reason I think it might be overwhelming the 9V in this case is that you’re getting good results with the 9V / microUSB combination. So the USB is taking care of the 5V requirements, and the 9V is running the motors.

Is there a way you can try to use a 6XAA battery, or a fresh 9V, and see if this helps?

Thanks for the reply. I’ll try to head out to RadioShack soon to find a 6AA adapter and I’ll report back any info I discover after I try that.

But even with the miniUSB adapter AND the fresh 9V battery I’m still seeing the error messages even though the motors are moving. What exactly do the error messages signify?

Have you guys tried the BrickPI with WIPI/WIFI and a normal 9V battery? Is this an officially supported power supply configuration (if there is such a thing) or no? Do you do all of your experiments/work with the 6AA adapter? I’d love to hear exactly what configuration you run things with and what you find works so I can try to duplicate that.

Oh, and yes, I’m using the image downloaded from your website.

Bill, we typically use a 6XAA battery adapter for all of our tests and work. If we’re just working with sensors and doing a lot of coding, we’ll use the microUSB with a wall wort.

A very bad description of how the BrickPi firmware works is that the RPi will try and retry to send a message (and get a verified response) from the firmware. The errors in communication are printed out for debugging purposes.

If you don’t want to see debug errors and messages, you should be able to turn it off. If you go into BrickPi.h, and on line 16, comment out “#define DEBUG”. I believe that should do the trick.

I had my BrickPi + Pi lock up several times today, probably due to power issues. Like Bill I’ve only had success powering it simulataneously with a 9V pattery and a micro USB power source.

If it’s not actually possible to use the BrickPi with a 9V battery…do you have any plans to ship 6XAA adapters to your Kickstarter supporters? Because otherwise what we’ve got isn’t terribly useful.


I got an 8AA battery pack. I know that I should only need 6AAs for 9V but my local RadioShack only had an 8AA holder and I didn’t feel like wiring a bypass around 2 of the batteries. It looks like the datasheet for the linear regulator said that, for a 5V output, the maximum input voltage was something like 35V so I figured 8AAs=12V would be OK. I put in 8 fresh AA Energizer Advanced Lithium batteries.

I hooked it up and everything booted and ran over WIPI/WIFI only off the battery pack! Yeah! I still get the error messages, though!? I know I can comment out the #define DEBUG, but is this symptomatic of an underlying problem? Do you guys see these error messages when you run the code off your 6AA pack?


After running it for a while off the 8AAs, I noticed it was getting pretty warm. I’m guessing that the regulator has a lot more heat to dissipate at the higher voltage and this might not be a good idea to do long term?

So I added a bypass wire around 2 of the 8 AA slots in the holder so it only took 6 AAs. This seemed to work OK, but then I started running into similar problems (error messages) when I added a Logitech Webcam (which I would have thought would be pretty low power?).

My final conclusion is that I’m going to (unfortunately) plan on powering the RPi separately from power to the BrickPi, which I will power with 6AAs.

I may also try 6Ds which should provide more current?

Hey Bill,

Really interesting to hear about the 8XAA batery pack. Do you have a part number you can share with everyone?

I think 8XAA’s should work fine. Was the only issue that you saw some heat buildup? This is expected, I see this a lot on my boards as well and so far haven’t had any damage. The regulator, as you point out, is suited for a much higher voltage than 9V.

The logitech cam shouldn’t be more than 500mA. If you’re also using a wifi device, that could be drawing up to 500 mA as well; you could be adding another 1A to the load on the board. However, I don’t think that should increase your transmission errors. Were you seeing the same errors (-2)?

Links to the 8 AA holders

But I tried running it off 6 D batteries and that was the best result I got. I could run the entire BrickPi + RPi + WIPI + webcam off the 6 D batteries with cam working, motors running forward and backward, and no reboots. I was STILL getting the debug error messages on the terminal when running the C program, but everything seemed to work fine in spite of these messages.

So my recommendation to somebody starting out and wanting the best chance of everything working with just battery power is to rig up a 6 D battery pack and run it off that. I wired together the following 4D and 2D battery holders.

6 C batteries might work too, but I didn’t try that.

Thanks wgarnder for this advice.

Yes, thanks for doing the leg work for us, much appreciated! I had a feeling that a 9V was not going to power everything I wanted to run. I want to run the same as you except it will be the RasPi Camera instead of the webcam.

Hey, you mention you got the wipi working with the Dexter version of wheezy? What did you have to do to get it working? I have the same dongle but mine does not light up.

I’ve checked lsusb, lsmod, watched dmesg…it all looks good and seems responsive. It just never provides power to it (this using the rpi wall adapter) and the light doesn’t come on.

Any tips would be greatly appreciated thanks!

Turns out I had simple typo - an underscore where a hyphen should’ve been! All’s well now in terms of flashing lights. Still can’t get the wipi to stay connected but I think that’s a wipi issue, not anything to do with the BrickPi.

I’ll get it sorted soon enough.

Thanks for updating us!

I also have no problem compiling “LEGO – Motor Test.c” or other Sensor_Examples, but when starting the compiled programs, I get the message
BrickPiSetup: 0
BrickPiSetupSensors: -1
and nothing happens with the connected motors.

Python programs work without any problems. Motors can be moved, sensor values can be read.

The BrickPi is powered by 6xAA battery pack.
The Raspberry Pi B+ is powered by the micro usb connector with an external wall power source.
The Problem ID is 15007, the Error logs are sent successfully to dexterindustries.

Please help!

Now it works fine after I’ve installed a fresh Raspbian image with brickpi modifications. I don’t know what went wrong in my previous image.

We think we have a solution to the the BrickPi C code problem.
The way to make it work is to update the packages and the run the BrickPi setup script again. Also make sure that you have the latest C code too.

We have put together an install script that should help you with this. Here’s the link: .

Download it and follow the Readme and the C code should work for you.