Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Although the Econotag is USB powered, it can also be connected to an up to 16 volt external power supply or battery through the JP13 connector. The blocking diode D1 allows both to feed the low dropout regulator, so USB can be disconnected without resetting the board; in addition with suitable circuitry the battery could be charged via the 5 volt USB line (Note: this is a direct connection with no current limiting or voltage cutoff when the battery is charged).
Another option is to connect a battery to JP12; there is no regulation in that case and the battery must not go above the 3v6 limit of the MCU. To reduce current consumption JP4 allows the FT2232 chip to be disconnected (no USB) and JP10 disconnects the regulator output (eliminates the back leakage). A battery connected here would charge up to the regulator voltage, through its current limit of 150 milliamps.
For mobile operation the MCU could be flashed via USB, disconnected, and then connected to a battery. However, to reduce flash wear a program can also be loaded into RAM, and it will continue to operate as long as the battery takes over when USB is disconnected. This page describes how to make such a connection using a lithium-iron-phosphate battery.
LiFePO4 is a relatively safe chemistry; overcharge just increases cell leakage and an overdischarge does not result in a potential thermal runaway on the next charge. The effective voltage range of a cell is 2v5 to 3v65, with most of the energy stored in the range above 3v3. Other lithium chemistries require permanent disconnection if the voltage ever drops below 2.5 volts or rises above 4.2 volts. Either of those conditions will, sooner or later, result in a fire. Cell life is reduced if the extremes are used. The longest life is at half-charge, and 3v3 is the optimum storage voltage.
A123 cells are available in capacities ranging from 1.1 amp-hours to 20 amp-hours. A board running contikimac would draw around 0.7 - 6.0 milliamps depending on RF traffic, and would last a month with the smallest battery. However I happened to have some 10 amp hour Headway cells leftover from an electric bicycle battery pack, so this page describes how to connect them. 10 amp-hours at 3v3 is over 100 kilojoules, equivalent to 200 rounds from a .45 caliber pistol. Some extra care is appropriate when using such a battery. I enclosed it in a PET mayonaise jar with two levels of protection. Without such protection hundreds of amps can flow if a Vcc trace on the Econotag is shorted to ground (e.g. USB housing, ground of a connected oscilloscope) and when plugged into a computer the case, metal desk, water pipes, etc. become sources of accidental shorts. The primary protection is a polyfuse on the battery anode to limit the shorting current to a few amps. The secondary protection is a 10 ohm resistor in series to the econotag battery input to limit trace shorts to a few hundred milliamps.
The battery can not overcharge because of the 3v55 output of the regulator. The battery *can* overdischarge since the MCU will operate down to 2 volts. There is a hardware battery low interrupt that could be used to prevent this, but it uses less power to just sample the battery every few seconds and sleep the CPU when it falls below 2.8 volts or so.
On 3v3 battery power through the 10 ohm resistor, the Econotag current draws are as follows. Note pushing the reset button will increase power consumption if the CPU was sleeping (holding it down pulls RESETB low, but the MCU starts up when it is released unless the FT2232 chip is also holding it in reset via R10, however that chip draws 19 milliamps). For storage disconnect the battery if you can not sleep the CPU. The 10 ohm resistor limits the battery charge rate to ~25 milliamps. For faster charge jumper across it with alligator clips. BE CAREFUL: if one clip is connected to the battery side and the other shorts to ground, only the polyfuse stands between a mild spark and a pyrotechnic display!
CPU in reset: 410 ua neither jumper CPU awake: 47500 ua both jumpers 30400 ua no JP4 29300 ua neither jumper Contikimac on at 8Hz: 480-6200 ua neither jumper, depends on RF traffic and amount of CPU sleeping
Here are the parts I used. The 9 amp polyfuse is the smallest I have; a 200 milliamp version would be better. The 10 ohm resistor would then not be essential but besides the extra protection, it allows easy measurements of charge and discharge currents (with an oscilloscope you can see the radio cycling). The polarized connector for JP12 is useful unless you never make mistakes with polarity. center
The first step is to cut the two traces that short JP4 and JP10. Verify the cut with an ohmmeter.
Populate the headers, black tape them on, turn the board over and solder-tack the easy pins (i.e. not the ground connections). Remove tape, reheat the tack and align connectors as necessary, and solder all the pins. Install the jumpers. JP10 will be the most frequently used, so that is a good spot for a taller jumper with a thumbnail groove (blue in picture). Red selects 3v55, black connects the battery to the voltage regulator for USB charging.
Lift one end of R10, if you want to be able to replug USB without resetting the MCU. The only downside is bbmc will no longer work, and you will have to push the reset button each time you reprogram. With R10 in the circuit the MCU will reset every time you install JP4 or plug into USB. Lift R10
Make holes for the econotag mounting and tie it onto the lid. Now would be a good time to check if it still works, with and without the 3v55 jumper. The webserver status page will show Vcc.
Punch holes for the resistor and power leads. Note one end of the resistor will be a potential source for high current, limited only by the polyfuse.
Attach the polyfuse to a length of red wire. Note the consideration here is not to allow maximum current flow, but rather to vaporize the wires on a short instead of setting your house on fire. Insulate the connection well, if the protected side touches the anode there will be no protection. Black tape around the entire polyfuse and connection would be a wise precaution.
Attach the other end of the polyfuse to the cell anode, insert the cell into the jar (note positioning to minimize the possibility of the anode wire shorting to the cathode). Solder the anode lead to one end of the resistor, and the output power lead to the other end. Connect the ground wire to the cathode.
All done! Pad with some more bubble wrap, screw on the lid, and plug in the power connector. Plug in USB and verify the charging current across the 10 ohm resistor. 100 millivolts = 10 millamps. You can also measure the battery voltage between it and ground (e.g. the USB connector housing). While on battery an oscilloscope can be connected across the resistor, but if USB is connected the scope ground will short Vcc. Depending on which side is grounded, the current would be limited by the resistor and/or (hopefully) the polyfuse.
Here is a USB powered scope with ground connected to the Econotag Vcc, channel 1 on the battery side of the 10 ohm resistor. The 2 CCA's on a contikimac channel check cycle are easily seen, also the CPU sleeping after no channel activity in seen.
Of course the modified Econotags can be used with 2 alkaline batteries as well. In this case don't jumper for 3v55, and if these are not rechargeable then write the program to flash and disconnect from USB before connecting the battery (alhough it seems you can get by with a brief overlap to preserve a program in RAM).
For some tips on keeping track of several Econotags when they are all USB-connected to the same host see Managing Multiple Econotags.