NXT Color Sensor: Errors, only reads black!

Hey guys,
I’ve been programming the BrickPi3 in Python for a while now and I just got a new cool idea for my project: take the Bobcat NXT project, and put it on the NXT 2.0 test pad and then trace the lines while picking up and dropping off the red and blue balls. The only problem is I have no idea to get the color sensor to work. I’ve read through the forum and stuff, but I can’t find anything that solves anything or helps me. A quick description:

  • When I run the example “NXT-Color_Sensor_Color.py”, it gives me this error: get_sensor error: Invalid sensor data. Then, the program continues and only outputs Black [1, 0, 181, 0, 40] and other numbers of the sort.
  • I have the NXT 2.0 color sensor
  • I’m using BrickPi3 on probably the newest firmware and software (updated it 2-3 months ago, too lazy to do it now)

Is there a quick fix for this or is it currently not possible to run the NXT 2.0 color sensor on the Brick Pi 3.

Thank you very much for any help.

Oh never mind, I was using the wrong port… the cables were all messed up!
But now it displays correct values when running the NXT_Color … example, but it says in the beginning: get_sensor error: Invalid sensor data
See photo:

This is the situation now: the Color example program works fine, with the error in the beginning, then the correct colors, but now, when I run my line follower program, it only turns to the left which means it only sees white and not black, even though has driven over my thick black line on the NXT test pad several times.
This is my program:

import brickpi3
import time

BP = brickpi3.BrickPi3()
#Set sensors
speed = 45
#Color Values:  1-Black; 2-Blue; 3-Green; 4-Yellow; 5-Red; 6-White
#When BrickPi sees Black, go right. When BrickPi sees White, go left
    while True:
            value = BP.get_sensor(BP.PORT_3)
            if value == 1:
                BP.set_motor_power(BP.PORT_B, 0)
                BP.set_motor_power(BP.PORT_C, speed)
                BP.set_motor_power(BP.PORT_C, 0)
                BP.set_motor_power(BP.PORT_B, speed)
        except brickpi3.SensorError as error:
except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
    BP.reset_all()        # Unconfigure the sensors, disable the motors, and restore the LED to the control of the BrickPi3 firmware.


Thanks again.

Ok, now I figured out how to make it follow my line, but I’m still wondering why it does display the invalid sensor data first, but then it works fine…
Same problem now with the ultrasonic sensor, I get invalid_sensor data when I run the NXT example in CM, but I somehow do get the right values, except they take like 30 secs to update.

Yeah, so this is getting quite annoying. I kind of need the BrickPi3 to be working soon because I need it for a project. This is really weird now because I just got it working perfectly, on both ports 3 and 4. Then after trying again in 10 minutes nothing worked on either ports.
Just to specify:

  • Software: 3.2.1

  • Hardware: 1.4.6

  • Using NXT Ultrasonic Sensor. Running examples from the library in the BrickPi3.

“need it for a project.”

1 Like

I didn’t see that. Thank you very much. Sorry for being such a disruption

I can assure you, every question is an opportunity for us all to learn. You are doing great!

1 Like

Ohh this issue has resolved?