[SOLVED] HiTechnic Color Sensor

I’m testing this sensor with the program C on the BrickPi, and it returns me all times black, and random colours (or 7(null)). I try in all sensors ports and have the same results. My sensor is Hitechnic NXT Color Sensor v2.0. Do it works with the BrickPi? or am I doing something wrong?

The only color sensor supported nativly is the Lego NXT color sensor. You can use the HiTechnic color sensor with the I2C drivers. Go to here and then expand and read the section “Using I2C devices on sensor ports 1-4”. It tells how to setup a sensor port to use I2C, and explains all the options available.

I’ve attached an example program. I don’t have the HT Color sensor V2, but I tested it with the HT Color sensor V1.

Thank you for reply. I tried your example program, but get an error. I read your page of BrickPî, but I dont get if I have problems with my BrickPi.h, need I2C drivers or something. Temporally I haven’t internet on my brickpi.

pi@raspberrypi ~/Desktop/comenius/Practicas $ gcc -o program "Test-BrickPi-HT-Color-sensor.c" -lrt -lm -L/usr/local/lib -lwiringPi
In file included from Test-BrickPi-HT-Color-sensor.c:16:0:
BrickPi.h: In function 'show_val':
BrickPi.h:231:2: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default]
BrickPi.h: In function 'BrickPiUpdateValues':
BrickPi.h:479:7: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default]
Test-BrickPi-HT-Color-sensor.c: In function 'main':
Test-BrickPi-HT-Color-sensor.c:41:3: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default]

The program works fine by the way. Thank you.

pd: the code of the last post its only warnings.

Sorry, that example program does not have all the #includes for the libraries used.

If you update to the latest BrickPi.h file (just pushed a couple minutes ago) from https://github.com/mattallen37/BrickPiDev, it #includes all the libraries used (and now has drivers for hardware I2C on sensor port 5).

Hi @Matt could you please send the sourceforge link or a similar again? It is broken and I have already searched almost everywhere. Please, I really need to learn about that as soon as possible.
Thanks

I updated the link to this.

This is an old thread (5 years old), and the content applies specifically to the BrickPi and BrickPi+, not the newer BrickPi3.

Unfortunately it seems my example program got lost during transition to the new forums.

If you need a general I2C example for the old BrickPi, you can find several here (such as dTIR and dGPS).

If you need drivers for the HiTechnic color sensor, you could take a look at the ROBOTC drivers for reference, or refer to the “Sensor Register Layout” here.

@Matt YOU ARE AWESOME!!!
Thank you very much!!

2 Likes

This topic was automatically closed after 3 days. New replies are no longer allowed.