I have an arduino and GSM module inside a sealed enclosure. I want to impliment a system where I will have an on off switch on the outide but when i switch it off I want it to first send me a SMS message saying it is switching off and then it can switch off 40 seconds later.
I was thinking the easiest way to do this would be to get a time delay relay? the system is currently running on 12V but I might be switching to lithium ion battery in which case it would be running at 3.7V.
With a bit of thought it should be possible to use the Arduino to control the relay that turns off its own power.
For start up you will need some sort of circuit (perhaps a push-button) that connects power to the Arduino for the few seconds needed for it to boot up and turn on the relay.
Not even a few seconds needed.
Latching relay circuit, the Arduino can then switch it off by e.g. pulling a line low breaking the power to the relay. The relay in turn can probably be replaced by a MOSFET, saving power for battery operation.
I have been assuming the relay (or mosfet) will provide power for the Arduino when it is ON - hence (in my mind, anyway) the need for an alternative route for startup power to the Arduino until such time as the Arduino is able to turn the relay (or mosfet) on.
TomGeorge:
I think the OP wants something like this,
I believe that is the effect he wants but it is not the way I would implement it.
I would use a DPDT toggle switch where one set of contacts parallels the relay contacts and the other set of contacts signals an Arduino I/O pin. When the toggle switch is turned off the Arduino will continue to be powered via the relay but will also be able to detect that the switch is off and will know to send the SMS and then depower the relay and itself.