Started it as first project with Netduino, that was chewing power. Found out that the Netduino board does not support power saver mode of the ARM processor, moved to Fio based Arduino board, and optimized power consumption over time. Now, the device can remain about two months without recharging battery. Still, in the future I will move to a different, more power conservative processor (probably the MSP430 from TI or by its name LaunchPad).
- Battery powered
- Requires charging only once in 60 days or more
- Low cost
- Easy to assemble
- 4 LEDs indicating distance
- Support single or multiple LEDs lights together
Step 1: Components Required
The following are the components you will need:
1. Arduino, better take the Fio based board or another one that does not have on-board FTDI
2. A 2,000 mAH LiPo battery that fits the Fio (the connector matches the Fio battery connector)
3. 4x Bright LEDs, 2xGreen, 1xYellow, 1xRed
4. 4x Resistors of 270 Ohm
5. small bread-board to solder the resistors and LEDs
6. LV-MaxSonar EZ1 MB1010 distance sensor
7, Some cables to connect LED board and the sensor
If you are using the Fio (recommended), you would also need a 3.3V FTDI board to program it.
If you do have power nearby the device, then you can buy any Arduino board instead of the battery and see some notes in next steps for power considerations.
Where to buy?
All goods can be purchased at your favorite electronics shop. None of those are very special components. One of the places is obviously Sparkfun (http://www,sparkfun.com)
Step 2: How It Works
When you are far from hitting the wall, the first green LED will turn on, then when getting closer, the 2nd one, then the yellow LED and finally the red LED will light up. You should stop when the red LED is on.
When no change in distance for some time (5 seconds), the device will turn off all LEDs and go to sleep. This fits the scenario of car parking in the garage or no car at the garage (where did you go :-)?).
The program is fairly simple, read analog input from the sensor, test the value against some thresholds and based on the result, set the number of LEDs to light up. Testing amount of time with no change in status and if that is for 5 seconds, the processor is put to sleep to preserve power. The processor wakes up every second to see if anything changed. If not, back to sleep. When in sleep, the entire device will consume 0.4mA and when working (without LEDs) it consumes several mA. When only one LED is lightening at a time, consumption is about 15mA. I tried 2 seconds of sleep as well, but it gave an awkward feeling when driving in as sometimes it took 2 seconds really before you saw some light... obviously not a good thing for people on the rush.
If you operate the device in the mode of single LED lightening at a time, expect about 2 months between recharging. If all LEDs that fit the distance will light up simultaneously, expect about a month between recharging.
To shorten the time the processor is up, I used 115,200 baud rate for the serial (only used for debugging). This reduced the awake time substantially. Removing serial output can further reduce awake time, but not dramatically I think.
Step 3: Assembly Instructions
Solder long cables to the sensor Vcc, GND and AN holes.
Connect Vcc to Arduino 3.3V
Connect Gnd to Arduino GND
Connect AN from Sensor to Analog 0 input of Arduino
Solder the 4 LEDs in the order of Green/Green/Yellow/Red. Note the polarity and see diagram attached
Set a resistor in series of each LED positive leg.
Connect the LEDs to Arduino as following:
Digital pin 5 of Arduino to left most Green LED
Digital pin 6 of Arduino to 2nd Green LED
Digital pin 11 of Arduino to Yellow LED
Digital pin 12 of Arduino to Red LED
Connect the FTDI (note the polarity) to the Arduino board and connect the FTDI to your USB.
Download the program to the Arduino board. If you want to see some debug output, make sure to change the Arduino terminal to 115,200 baud rate.
Connect the battery and let it charge (Fio has an on-board charger and LED indicator for the charging status).
When complete, put the thing in a box and you are done.
If your parking space is outdoor, please ensure good sealing for the device and put the sensor in a shielded place (shield from rain). I have the sensor in outdoor shielded by window sill which is good enough. I placed some rubber between the two parts of the box and closed firmly. There is a flavor of the sensor that is designed for outdoor... but it cost much more and I am not sure there is good reason to spend that money. It works at my home for 7 months with no issues.
Step 4: Configuration and Parameters
You can change some parameters of configuration to the device in the program, Code has enough comments to tell you what to do. Basically you can:
1. Set the time to turn display off to anything you want. The code now uses 5 seconds (line 73).
2. If you want all LEDs that indicates a distance to light up together (much easier to read), then change the variable runningLeds to false (line 70). This will cost you in time between recharging on one hand, but is not that important if you are using an external power.
3. If you want to change the wiring from described, all you need is to modify the Leds array (line 65).
4. If you want more LEDs or less, you will need to change: NUM_LEDS (line 64), assign the new LED pin to Leds array (line 65) and add level threshold for it in ReadDistanceSensor() function
5. If you are using external power, you can disable the sleep code of the ARM, as there is no need for it. It is also possible to change the variable wdtTime code from 6 to 3 or less (line 79 ). That will be good enough.
The picture of the code is from AVR IDE, I simply hate to use Arduino IDE for editing code and the Visual Studio plugin works so-so.