BrickPi Colour Sensor

I’ve just been having a similar issue.

The sensor test in python does not work on mine as shipped with the 2014.07.30 Image. I need to add

BrickPi.SensorType[Port_2] = TYPE_SENSOR_COLOR_FULL

for it to work (Like Ostrich suggested back in May), even when plugged into Port_1 and retrieving the value from only Port_1.

Adding the Port_2 declaration seems to be the part that activates the light. Why is this? As this doesn’t seem right to me, especially when it stops me using that port, effectively reducing the number of sensors I have to play with.

Also is there any way of activating it just as a lamp and defining the colour?

Just to put this out there: could it possibly be that a batch of BrickPi boards weren’t flashed properly, and thus have out-of-date or corrupted firmware? As it would explain why D.I. can’t reproduce the problem, while some of us are struggling.

If that’s a possibility, I’d be willing to reflash my BrickPi and see if it helps…

if you’re willing and have the equipment already by all means, I’d try if I had an Arduino Uno or AVR programmer, as in theory if done right it’d either fix things or stay the same.

Did anyone have any luck with reflashing the BrickPi firmware? I can see how this might be why we’re unable to recreate the problem, and I’m really curious to know if there’s been anyone that’s reflashed and seen success.

Well I’d be game if i knew where to find the kit needed to do so. as Amazon doesn’t have that AVR programmer.

I’ll see if my university has an Uno.

another thing does it need to be an Arduino Uno? or will any Arduino board work?

I have an AVR programmer on loan, but someone would have to walk me through the refresh… I’m new to this.

@keithnbrown, you can use any Arduino that can function as an ISP programmer.

There are links on how to reprogram the firmware using either an AVR programmer or an Arduino in this article:

My tutor just got back to me and he says that we also have a USBasp Programmer like this one

Will that work with your AVR guide?

Any idea how I can get my hands on a 6 pin 3x2 header cheaply in the UK? as most places charge a stupid amount for postage

I am now in possession of an AVR programmer and a header. I’ll try both sets of firmware to see what happens and report back.

I do not have Brickpi from dexterindustries.
I builded mine from scratch with two arduino uno based on atmega328P-au.
I tried with both firmware ( 1.7 and 2.0 ) and same result, color sensor do not work.
I had modified the CS_READ_DATA() function in BrickPiCS.cpp ( like said earlier ) and after that reflashed it.
Then it works !

I too have tried reflashing now and got the same result, corrupt firmware doesn’t seem to be the cause. But if the error is in a C++ file shouldn’t that mean that D.I. should have the same issue? But they’re reporting that it works fully.

What on earth could be causing this error for just a subset of people?

@flopsoft67: does that .cpp file need recompiling for the fix to work or not?

I’m looking into trying that myself, or perhaps experimenting with a more robust fix that doesn’t involve another library.

You have to modify the file and recompile the firmware like classical sketch with arduino IDE and that’s all.

Perhaps you can try to use “classic” digitalWrite instead of digitalWriteFast. No need of the extra library.

I think some color sensors are most sensitive to timings perhaps due to a small hardware change ?

You have to modify the file and recompile the firmware like classical sketch with arduino IDE and that’s all.

if you don’t use an Arduino that’s not helpful. I used an AVR programmer to reflash. i thought i might have to run make or something

what i meant by a more robust solution is just finding out why the DI code doesn’t work and fixing it using only what is already used within brickpi’s firmware. unless you mean you added that library help it when an operation wasn’t firing quick enough or something. but i don’t see how ‘timing’ could cause the sensor to only work correctly when it’s declared on two ports, seems like an addressing issue to me.

I REALLY need this sensor to work as it should for my project as I’m only using standard sensors form the 2.0 set, so i can’t use port 5, and I need all four ports so i can’t be assigning the colour sensor two ports.

Hey flopsoft67 maybe you didn’t put your sensors in the correct place?


I have just (20th November 2014) received two BrickPi and they have the same problem with the Lego NXT Color Sensor.

With the Python color sensor test example the sensor is dead (no leds, reports Black) unless I add the bodge workaround as suggested on this thread (then it lights up and reads colors).

BrickPi.SensorType[Port_2] = TYPE_SENSOR_COLOR_FULL

Has any progress been made toward resolving this issue by Dexter Industries?

Hey ! Color sensor still not working for me…Only says black…

I have this one:

others sensors are working great! Need help :wink:

any progress ?

I’ve been talking to John from D.I. by email and he’s sent me a new board he’s tested himself and taken pictures of working. I’ve not gotten around to testing it yet so I’ll post here when I have. If the new one does work, I’ll be sending him mine so they can have a look at where the fault lies.

Any update, Keithnbrown?