Tank Day 23: Range and Bearing

Step 1: Choose Sensors

Two sensors were chosen for the Raspberry Tank’s first foray into detecting its environment: An ultrasound rangefinder (SRF02) and a 3-axis compass (CMPS10), both ordered from robot-electronics.co.uk. Beyond their I2C interface, these devices were chosen largely for cost reasons, though they should both be fine for the job they will have to do on the tank.

Tank Day 23 Range and Bearing

Step 2: GPIO Breakout!

Way back on day 7, we attached a simple connector to the Raspberry Pi’s GPIO pins in order to extract GPIO 7 and Ground to feed into the tank’s motor control board. Now we need three more connections onto the GPIO header – for 5V, I2C Data (SDA) and I2C Clock (SCL). Several of these pins must now be connected to more than one device, to to avoid some very messy connections, I constructed a simple break-out board for the GPIO connector.

Step 3: Testing

Handily, the guys at robot-electronics.co.uk have already produced sample programs to read the data from their devices on a Raspberry Pi, which work perfectly under Occidentalis. These had to be run as root to have access to the virtual I2C device,

Tank Day 23 Range and Bearing schematic

These were loaded onto the Raspberry Pi, compiled, and run. The results were… pretty good!

The compass module’s “forward” direction was determined to be towards the header pins, meaning that if this edge was pointing north, the compass module returned a bearing of roughly zero degrees. This was compared against the compass reading provided by a nearby iPhone, and was found to be accurate to around 10 degrees – not perfect, but acceptable.


For more detail: Tank Day 23: Range and Bearing

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top