I’m trying to build a data logger that will only store data to an eeprom once an hour, and to conserve energy and have it log data for long periods I would like to turn the power off for everything except the Real Time Clock (DS1337).
So this is my setup.
I have a power source and a voltage regulator (3.3V) that will power the RTC all the time. When the alarm is tripped a digital line on the RTC goes low for 1 second (I think) then I need to power up everything else and keep the power on while I take my readings.
Here I think I need a MOSFET or a transistor or something to feed power to the rest of my circuit, until the ‘Arduino’ (clone) is done and pulls a digital pin low (or high) to go back to sleep.
Any ideas ?
UPDATE:
Could this work? Or if not, what could be done to make it work?
My plan is still to turn everything off until the RTC alarm pin goes low. Then I hoped that I could use a MOSFET to switch the power on for everything else.
So this is a schematic of my idea. The net ‘Main 3.3V’ (circled in red) will always have power and it goes into the source of the MOSFET P-channel (AO3401). With the gate pulled high by the pullup resistor R6 the transistor should be off and no current is flowing through to the microcontroller or other devices.
When the RTC alarm pulls the line low, the transistor should be on and supply power from the ‘Main 3.3V’ net to the ‘3.3V’ net and power everything else up. The very first thing the microcontroller should do is pull the connected pin low to hold the switch in the on position until all logging is done and the microcontroller can ‘kill it self’ by pulling the pin high an losing power until the next logging sequence.
The header U10 (marked in green) is there for programming and testing purposes so we can lock the power to be always on.
I must admit that I really suck at this type of electronics and would appreciate any help to get this working.
Sounds like you need wake up on interrupt code. Maybe this will help? Its written in 3 parts. He uses a switch going low for triggering his wakeup interrupt which you can easily substitute for your low signal from rtc. The arduino board apparently uses 10ma by the regulator even when micro is in sleep mode. So you might want to consider that in your board design if you planned on using a similar regulator. Best way to avoid that is run straight from the battery if the voltage is right.
I’m not so sure about your using the same line to switch the mosfet as the line is waiting for a low signal from the rtc. Maybe somebody else can add more light on doing it that way. I would prefer to use a dedicated pin for switching the mosfet and by the looks of your circuit you still have spare pins for that. I’m not clear on your intentions of joining inta and intb pins on the rtc. I had a speed read of the datasheet and it looks to me inta outputs low on alarm and intb outputs a squarewave at a selected frequency. As it says you can leave intb floating why not just wake the mcu with inta? I couldn’t see where the datasheet spoke how long the low signal from inta was held. But this isn’t important if you only use it to wake the mcu and then switch the mosfet with another pin from mcu.
I had one initial addon board that breaks out the ADC channels but in thinking about it, I’m going to go with a way to turn off the power to those components feeding those adc channels(so as not to waste energy on non readings). I was going to go with a simple 2n3904 or 2n2222 transistor for that instead of a mosfet.
I’m using the WDT(watchdog timer) on the device in an interval mode as an interval timer(so no resets) and just coded this part last night. The function takes 2 params, the timer mode(4 different ones for lengths of time to set the interval)1.9ms, 16ms, 250ms and 1000ms(though this is with a 32khz crystal) and the number of loops to itereate through.
I’ve started posting quite a bit on it and have the code posted on GitHub. The code would be similar in theory to what you would write for the AVR chip…
The one thing about my setup is that it uses a DCO(digitally controlled osc) and auxilary clock which runs at 12khz. Not super accurate, but it would get the job done. I’ve considered designing another board with a higher pincount proc that would allow for a 32khz watch crystal to be used. This would be just as good if not close second to a RTC(and no programming the rtc so less headaches).
Not sure if this helps, but figured I’d mention is as it’s something along a similar vain.