Goggles Guidance
Open ocean swimming is very cool. This is written on Maui and the beauty of swimming without lanes in the sun is amazing. For years I have contemplated designing and building a GPS guidance system for swimming but lets say for a variety of reasons its difficult. I saw the great Kickstarter goggles: http://gizmodo.com/led-guides-in-these-goggles-keep-open-water-swimmers-on-1725601691 with built in compass and decided to build my own--this is the build. It requires a bit of soldering, Arduino knowhow and goofing--in the end I ended up with a small computer module with compass controlled LEDs that you can mount to any swimming goggles or full face snorkel mask or scuba mask. I have tried them out here in the ocean and am not sure if I like them or not. Basically you sight a target and push a button and it gives you three color options--blue LED is +- 15 degrees of target and red and green are left and right of those limits. You can set the target degree drift in the software. The module is waterproofed in an amateur way and the mounting you can adapt to any goggles. Anyway if you have an interest in this--build away, but like all instructables go further than I did with the project and have fun.
Hardware
So this is relatively simple if you have build anything with Arduino engines before. The parts list is above and includes the Flora compass module and the Pro Trinket 3.3 volt board. I used the Adafruit Pro Trinket LiIon/LiPoly Backpack Add-On (not listed on parts list) to power the board and connect the small LiPoly battery to it. I used the smallest battery available--the 150 mAh and it was able to power the thing for hours. It would be better to have some programmable shake to wake feature or other way of controlling on and off but I elected a simple button to do it. You could also elect to just have the thing loose power and then charge it up latter. I had trouble finding a way to waterproof the mini usb output at the back of the Pro Trinket so I elected to use a attachment from Adafruit that terminated the usb micro (MicroUSB to 5.5/2.1mm DC Barrel Jack Adapter) into a simple barrel charge port that I could seal easier. This unfortunately does not allow you to modify software anymore after you seal it up. The Fritzing diagram is above and does look horsey and doesn't include the backpack--could not find it on the Fritzing Adafruit panel but you can get the general idea. For the output I decided a single Neopixel output would be easier to install on any pair of goggles on a long simple tether of three wires rather that having scattered wires and led's festooned all over. The idea is to have a blue output for on target and red for too right and green for too left. In reality it proved easy to follow.
Downloads
Software
Just a simple program to check the heading and then decide if you are within certain degree parameters. There is a slight problem with developing software that is "tilt-compensating" so that when you are wiggling around in the water you don't screw up the readings from the sensitive compass module--trust me this is a problem. So use this software which does this work for you--i use it in the software:https://github.com/pololu/lsm303-arduino. The other thing you must do is use the software on that site to correct your particular board and add the limits found on it for x,y,z magnetometer limits. This is an easy program to run but you have to sample your card on a regular Arduino as the Pro Trinket does not have a serial monitor. This also makes a very big difference. The limits for the blue led for +/- targeting are easily set. The main problem in writing the software was the clock arithmetic that throws a curveball at you. The program takes ten readings of the compass and then does an average to make temporary head twisting and surf wiggles less likely to cause you to go off course. Additional things that you could do would be to modulate brightness or color as you drifted further from the target.
Downloads
Packaging
The components slide together fairly well. You must keep in mind that the compass board should be mounted as flat as possible to your direction of travel that you want to measure--more details about this can be found at the https://github.com/pololu/lsm303-arduino software site. Most of the components can be tacked down together using hot glue. The two buttons--one for on/off and the other--a momentary push button for setting your target direction have to be accessible. My idea was to surround the whole mess with a layer of flexible waterproof silicon which seemed to work fine--see photo of the silicon type stuff I used from Home Depot. After an inordinately long drying time I was able to clearly see and operate the encapsulated buttons. The Neopixel also got a shot of the stuff. I tested multiple iterations of the device in saltwater and only lost one due to incursion. I connected them to a snorkel tube mount which slipped easily on the side of the goggles. The Neopixel I could mount anywhere I found it convenient to stare at. If I continued working on this thing I might just stick it in a plastic conduit tube with sealable ends and tack the buttons on the ends it might work better.
Using It
It was easy to mount to my full face snorkeling mask and I found it more useful for this than open swimming. I could set a course along a long reef and follow it out without the usual disorientation caused by following a fish and then having to surface to find my bearings. For ocean swimming I did not find the lump mounted on the side of my goggles hampered anything. The range for the true bearing of 30 degrees while sounding large really didn't affect the targeting which at 1/2 mile seemed adequate. You can change this to a finer discrimination but it tends to make the Neopixels flash a lot with mild turning in the surf. The tilt compensation in the software seemed to work well enabling head turning for breathing and tilting up for course setting without problems.