Introduction: Battery Operated IOT
If your battery operated IOT project operates intermittently this circuit uses only 250nA (that's 0.00000025 amps!) when idle. Normally most battery power is wasted between activity. For example, a project that operates 30 seconds every 10 minutes wastes 95% of the battery capacity!
Most micro controllers have a low power standby mode but they still need power to keep the processor alive, also any peripherals will consume power. It takes a lot of effort to get standby current below 20-30mA. This project was developed to report temperature and humidity in bee hives. Because of the remote location battery power and a cell shield for reporting data where the only choice.
This circuit will work with any controller and 12, 5 or 3V power. Most electronic stores will have the components which only costs a few dollars.
Resistors: 2x1K, 3x10K, 1x470K, 2x1M, 5x10M
Diodes: 2x1N4148, 1xLED
Clock: PCF8563 or equivqlent for microcontroller
Relay: EC2-12TNU for 12V supply
EC2-5TNU for 5V
EC2-3TNU for 3V
Power: OKI-78SR-5/1.5-W36-C 12V to 5V Converter or as required by microcontroller
Switch: Momentary press for reset, SPDT for test
Step 1: How the Circuit Works
The circuit is quite simple:
- A battery operated alarm goes off and throws a switch
- Power flows from the battery to the controller which starts up and does its thing
-The controller resets the alarm
- Then throws the switch to power off.
Step 2: The Clock
Most real time clocks should work provided they are compatible with your controller and have an interrupt (Int) line that tells when the alarm goes off.
Depending on the particular controller and clock you will need to install a software library.
PLEASE set up your Controller and clock on a prototype board and make certain you can program it to set the time, when the next interrupt should occur and how to clear an interrupt after the alarm has gone off. Its much easier to get this working now before building the final board. See the last step for programming notes.
Step 3: The Switch
For the switch we use a latching relay with 2 coils.
Putting a current through the set coil turns the relay on. The current only needs to flow for about 12ms and then can be shut off leaving the relay on.
Put a similar pulse through the reset coil to turn the relay off.
We want a latching relay so we don't use battery power to keep the relay closed. Also, we power the relay "on" from this circuit and power it "off" from the controller when it has finished.
The project was built for a 12V SLA battery. These are cheap (zero as I already had one!) and will do well in the Canadian winter with a small solar charger.
The circuit could be built with a 3V relay using a couple of AA batteries. Since the relay will handle 2A at mains voltage it could switch a small wall power unit (or a second larger capacity relay) for mains powered equipment. Just be sure everything over 12V is in a properly grounded box and well insulated.
Step 4: 2N7000 MOSFET
This circuit uses 3 2N7000 enhanced mode N channel MOSFETs (Metal Oxide Semiconductor Field Effect Transistor) used as switches.
Costing only a couple of dollars these are quite remarkable devices. Current flows between Drain (+) and source (-) when gate voltages exceeds about 2V. When "on" the Source-Drain resistance is an ohm or so. When off many megohmes. These are capacitive devices so the gate current is just enough to "charge" the device.
A resistor is needed between Gate and Source to allow the gate to discharge when the Gate voltage is low, otherwise the device will not turn off.
Step 5: The Circuit
The interrupt line from the clock (INT) normally floats and is connected (inside the clock) to ground when the alarm goes off. The 1M resistor pulls this line high when waiting for the alarm.
U1 acts as an inverter as we need an active high to turn on the relay when the alarm goes off. The opposite of the clock output. This means U1 is always conducting on standby and puts a constant drain on the battery. Fortunately, we can use a very large resistor R1 to limit this current. Simulations showed this could be up to several Gohms! My local store only had 10M resistors so I used 5 in series. 250na is low enough in my book.
U2 is a simple switch to power the relay's set coil.
The 2 diodes are necessary to protect the circuit when the power to the relay coils is turned off. The magnetic field will collapse and induce a current spike that could damage something.
The raw 12V from the battery is taken to a voltage divider R6 and R7. The center point goes to one of the controller's analogue pins so the battery voltage can be monitored and reported.
U4 is a highly efficient DC to DC converter to produce the 5V for the controller.
When the controller has finished it raises the Poff line high which turns on U3 that turns off the relay. The resistor R4 provides a ground path for the gate of U3. The MOSFET is a capacitive device and R4 allows the charge to flow to ground so the switch can turn off.
The test switch directs power away from the micro controller and to an LED. This is useful for testing this circuit but crucial when the controller is attached to a computer for programming and testing the code. Sorry, but I did not test with power from 2 sources!
The reset push button was a necessary afterthought. Without it there is no way to set the alarm the first time the system is powered up!!!
Step 6: Circuit Simulation
The simulation on the left shows values while the system is idle. On the right is a simulation when the alarm is active and the interrupt line is pulled low.
Actual voltages agreed reasonably well with the simulation but I have no way to confirm the actual current draw.
Step 7: Construction and Programming
The circuit was built in a narrow strip to roughly follow the circuit diagram. Nothing complicated.
As soon as the program starts it should reset the alarm. This will stop current flow through the set coil of the relay. The program can do its thing and on completion set the alarm and turn everything off by turning Poff high.
Depending on the particular controller and clock you will need to install a software library. This library will include sample code.
The interface and programming the clock should be tested on a prototype board before wiring the circuit. For the Arduino and H2-8563 clock SCL goes to A5 and SDA to A4. The Interrupt goes to the INT shown in the circuit.
For the Arduino the test code will include something like:
#include <Wire.h> #include <Rtc_Pcf8563.h>
//set date and time to get started. Not necessary if you only want alarms on the hour or minute. rtc.setDate(day, weekday, month, century, year); rtc.setTime(hr, min, sec);
//Set alarm rtc.setAlarm(mm, hh, 99, 99); // Min, hour, day, weekday, 99 = ignore
//Clear alarm rtc.clearAlarm(); }