Compatibility with Hitechnic compass sesnor


#1

Hi,

Just got hold of one of these sensors, is it compatible with the BrickPI?

I have had a look in BrickPI.py and can’t see it listed as a TYPE_SENSOR.

The instructions for LEGO Mindstorms mention using it with the ultrasonic block, thought I would ask the question before trying this out.

Cheers
Steve Gale


#2

Steve,

Indeed, we haven’t written any code for HiTechnic’s sensor. But it should be usable. I think off the top of my head that it’s an I2C sensor, and if so, it should be easy to copy either our python or C examples to communicate with the sensor.

I think Botbench has an example in their library for using the HiTechnic compass: http://botbench.com/blog/category/programming/robotc-drivers/

If you’re working in C, it should be doable to adapt Xander’s code for use with the BrickPi.


#3

Thanks for the response, I will check that out, do I connect the sensor into the brick pi. E.g.sensor channel 1, or do I have to connect it to the raspberry pi pins?

Cheers

Steve


#4

Hey Steve,
No need to hook up to individual IO pins. The I2C communications are already setup so that you can communicate directly with sensors on the sensor ports.
Best,
John


#5

Thankss for the response , I checked the schematics after I posted and came to that conclusion.

I have also looked at the code you pointed me at and it looks straight forward , I will try it out in the next couple of days and let you know how I got on!


#6

No problem. If we can help along the way, please let me know. Also, if you get a working example up, it would be awesome to merge it into the existing code base on Github.


#7

I have attached the first version of my program.It obviously compiles and runs. it only outputs 0,0 for several cycles and then 255 for anglelow and 64 for anglehigh.

so in order to check it was talking to the right device i changed the address from 02 to 03 and got exactly the same result, which confused me because I expected an error indicating no device.

i then used i2cdetect -y 0 and did not get any devices detected,
i2cdetect -y 1 displayed UU in address 3b.
There is an ultrasonic sensor connected to sensor 1 on the brickPi, but this is not address 3b.

that is the background, now some questions.
having looked at the firmware design, it states that the raspberry pi and brickpi communicate over serial. Is this serial as in RS232 or I2C?
are there any commands I can use to confirm the address of the sensor connected to sensor 2?

I am wondering whether the sensor needs calibration because it has never been used, that is my next step tp modify the attached program.


#8

Think I have just spotted my mistake, have not set the read address!
Watch this space.


#9

Cracked it, finally reading data from it, I will attach some code when I have tidied it up


#10

Awesome! Can’t wait!


#11

Cracked it.


Shows a video of my robot, apologies for quality, first time I recorded and posted a video on YouTube .
At the moment I have got forwards, backwards, left and right plus turn through 90 degs. Heading and range is displayed on iPad . Robot stops when distance less than 20 cm. software is based on one of the wifi robot projects on the forum.

My software can be found on github at windy54/legoRobot.

I have attached a raspiconnect screen shot.

There is another screen which displays video from the camera but the update rate is slow and needs further investigation.
Calibration of the sensor only works in the C program, can’t get it to work using Python. I think this is because I am constantly calling brickpi.updatevalues while it is calibrating .

Now to improve code and try and get it to navigate a maze.