Bike Sensors


For my final project, I want to have a proximity sensor for vehicles approching from the rear. Along those lines, I tried one of the cheap ultrasonic sensors in an Arduino. It has a theoretical range of up to several meters. However, I quickly found that this range was only in perfect conditions.

After refactoring some quick Arduino code to time the sound return and display it to an LCD, the limitations of the ultrasonic sensors quickly emerged. The sensor was relatively stable against perpendicular planes up to about a meter. However, the accuracy quickly fell off and extraneous readings started showing up.

Even with sensor averaging, the errors above 1m were too great to get any useful data. In particular, the sensor seemed to default to 1m in the readings, resulting in a "dead zone" where readings were completely useless. Furthermore, any slanted surface had almost no return.

For next time, I'm looking into LIDAR/ToF sensors that have a range of 3-8m. There are a few like the LIDAR Lite which might work but will require some more research as they are substantially more expensive.

Hall Effect


The main feature of most bike computers is a speedometer which uses the angular frequency of a magnet on a wheel to determine speed. Since there was a hall effect sensor in the list of input devices, I thought it would be very useful to replicate that functionality.


The board was designed around minimal size and minimal part count. I used an Attiny45 using the class design. However, I decided to eschew the UART/FTDI port in exchange for an I2c/power port which is only 4 pins and could be connected to a larger network of devices. The board was once again laid out in CircuitMaker and then translated to png using Gerbv.

Magic Smoke

Unfortunately, because I had replaced the FTDI connector I had to wire the pins manually until I actually make a cable harness, I managed to reverse bias the microcontroller and let all the magic smoke out. When I had desoldered and resoldered a new chip, a solder whisker fried yet another chip.

Final Success

I modified Neil's Hall Effect program to its basic averaging and conversion. I then used the modified USI I2c interface. to write bytes to the I2c bus. I then wrote a method to calculate the bike speed based on the wheel momentum.

I had some struggles with getting the code to respond to queries so I got rid of the speed calculation and thresholding function which dumped the contents of the I2c bus to serial using a second board. However, I didn't get too far as working on electronics while watching the election led me to fry a third chip. I finally broke down and used an Arduino to read the I2c bus and I successfully got the Hall Effect board to respond to commands and send back data that changed based on the presence of a magnet.

I still need to get the thresholding function to work but I'm pretty happy with my results this week.