I did a first ride with the glove and tested it on a 30km Vestby round. While riding, I can’t see if everything works as it should. I have to wait until I am back home at the computer to check what I got.
The Vestby round consists mostly of pretty remote cross-country roads. More dense traffic is only around the villages Ås and Vestby and on Drøbaksveien. There, I went on the road instead of using the bike road as usual and realized that the cars are really annoying here. Seams that they want to teach you a lesson when you ride on the road by passing extra close. It will be very interesting to see if this subjective impression is true.
But back to the measurement. A first look at the distance data was promising. The data were logged consistently and the distance measurement seemed to work very well. A problem occured with the glove. From the second half of the ride, I got a lot of false positive flags in the data. Seems that the sweat was causing a conducting of power between the non-insulated cables. So I will have to improve the glove before the next test ride.
I guess it would be boring if everything works from the first try, right?! But in total, I think I am on a good way.

I thought about a problem: When logging the distance, it would be very difficult to distinguish a passing car from a car driving in the opposite direction or any other object on the street when I have the distance only. So I thought about marking when a car passes me directly in the data. The principle is pretty easy. I would just need to press a button and a flag would appear in the data. A practical problem was to get a convenient connection from the backpack to the handle bar. While thinking about that on a long bike ride, I realized that the best solution would be a glove, which sets flags when I press my fingers and thumb together. Each finger could set a different flag so that I have some more options.
So I had a plan. I bought a cheap pair of work gloves and made a four-wire cable from duct tape and copper wire. I sewed this to the glove and added aluminum foil contacts to the finger tips. It is very improvised but works pretty well (for now at least).

On the arduino, I had to add three wires plus pullup resistors (another lesson learned!) and one more cable to the ground. It was getting pretty full on the shield, but no problem still:

It was time to get the software running. I used some code from the SD card examples and mixed it with the sketch I used with the old version. It was easier than expected and after testing and adjusting here and there, it worked very well. Now the arduino saved the exact time, date, distance from both sensors and the three flags from the glove conveniently in a csv file. It still takes almost 20 measurements per second.
So far so good. I attached it back to the camelbag and was ready for another test ride.

The shield arrived and I directly assembled it. The data pins needed to be soldered on but this was really easy. It is a genius little thing because it comes with a built-in clock. This will make the data synchronization so much easier. Another plus are the numerous soldering holes on top.
OK, to get it running properly took a while. I forgot that some of the pins are occupied by the SD card writer. So when I connected some of the sensor pins by accident to these, I got really weird error which caused some headache. But after a couple of evenings with a lot of cursing, I think it is running properly now.
This is how the arduino with shield on top and connected to the sensors looked like:

The setup is so much easier now without the Pi. It will log data constantly as soon as it gets power.

The first test ride was not too successful. The range metering worked pretty well; however, the connection between phone and raspberry pi was crashing very often. And when this happened, the data logging stopped as well. It would be great to simplify the setup. When the arduino could log the data directly, a lot of problems would be solved.
So I started looking for a solution and found a nice data logging shield from adafruit. It uses a SD card to write the data. With this, I could skip the raspberry pi completely.
Now I will have to wait a bit until the shield arrives.

It began by reading an article from from Dr. Ian Walker (http://www.sciencedirect.com/science/article/pii/S0001457506001540) about the passing distance of cars when overtaking bicycles. He found out that when he was wearing a helmet, cars passed closer and when wearing a wig (to appear as a woman) cars kept more distance. I found this very interesting and thought about testing something similar. I didn’t plan to test the helmet effect (or the wig!). I was more interested in passing distances due to different bike types. But first I needed a distance metering setup with the following characteristics:

portable: The device should be small enough to fit on a backpack, so that it is easy to use on different bikes

autonomous: Of course it would help to run on battery for a fairly long time. But even more important is that it runs by itself without trouble.

good measurement accuracy: This is very important of course. The more the better.

as invisible as possible: Of course the specimens shouldn’t be distracted by a strange device and act normal.

I started to play around with a Raspberry Pi and its GPIO controls about a year ago so I was not totally new to electronics. But for this project, an Arduino micro controller had some advantages over the Raspberry Pi. Really nice about simple micro controllers is that they don’t need to boot as long as micro computers and are much simpler to use with sensors. So I decided to start with an Arduino. I had a cheap (SainSmart) range meter already but the measurements were not very consistent. So I searched for something more advanced. I learned that MaxBotix produce very reliable devices so I ordered a LV-MaxSonar-EZ1 from the UK (it is extremely difficult to find special parts like that in Norway). It arrived quickly and I was surprised how small it was. But testing it with the Arduino gave very stable result. So a good choice I guess.

But then there is another problem: The Arduino alone can not save data. However, the Raspberry Pi can.. So I hooked up the Arduino to the Pi and copy-paste-wrote a terrible Python script (I am new to this funny language) to save the data to the SD card. It worked pretty well after some adjustments. Then I attached the whole setup to a piece of wood and build a little holder from some IKEA spare parts to hold the distance meters. So it looked like this:

The battery is a 12k mAh power bank and can power the full setup for a full day probably. I used an old phone to connect to the Pi via USB and SSH. The phone was used to start the recording script and actually displayed the measured distances an the screen.

So next challenge was to get it portable. I chose a quick and easy version for now: an ice cream box covers most of the electronics and the whole thing was attached to an old CamelBag backpack:

There is definitely room for improvement. Especially when it comes to point 4. But this is just a first try. Ready to go for a first test ride!