Looks like I wasn’t clear enough in my original question so will try again.
“I want to add a momentary power switch to my imp005 based project”
I design in blocks. The imp005 is the brain and comms block. It has a 1wire interface hanging of it’s I2C. It has an ADC hanging off it’s SPI. It uses a number of it’s GPIO’s for measuring other things. A couple of GPIO’s for led indicators. This all already exists and is working well including the code. It takes readings from sensors, packages them up and sends them to a server. The code to run all of this is already written and tested. It works well on the imp005 which provides all the excellent features of the imp architecture and does it via ethernet as WiFi is not available (it operates in what is essentially a Faraday cage). This paragraph is FYI only and not part of the question.
Power is via a plug pack from the mains which connects to a battery circuit that if the mains turns off, the battery will continue providing 5V to the imp and other parts that need 5V. This mains power / battery circuit has has an output pin that drops low when the battery gets to about the 3.2V that is connected to one of the imp’s GPIO’s so the imp knows it’s time to shutdown because the battery is almost depleted. This is in place and working except it doesn’t cut the power between the power/battery circuit and the rest of the system. At the moment it’s just the imp that we can turn off via it’s code.
I am looking for the right circuit that the imp can control as a peripheral circuit to the imp that turns on/off the power between the power/battery circuit and the imp and it’s associated sensors.
I found the writeup on a solution used for raspberry pi that does what I am looking for with a RPi. On the RPi, GPIO4 (according to the article). NB, GPIO4 is the Raspberry Pi GPIO, not the imp.
The article mentions “By default GPIO 4 is initialized as an input, but idles high because it is pulled up by an internal resistor. While we don’t know the precise value of the pull-up resistor, it’s probably in the range of 40 KΩ - 100 KΩ. Being pulled high doesn’t affect the circuit much during startup, as the internal pull-up resistor is effectively across the 100K resistor of the circuit. As soon as the circuit powers up, in response to a button press, the GPIO 4 input is pulled up internally. It actually acts as a very weak output pin, helping to pull up the gate of the N-MOSFET, and keeping the circuit ON.”
Are the imp005’s XB, XC, XD, XE pins the same as described above about the RPi’s GPIO4 pin?
The article goes on to say: “The circuit’s 100 KΩ does pull the input towards 5V, and in general you shouldn’t connect an input to anything greater than 3.3V as that will forward bias the input substrate diode and inject current into the RPi’s 3.3V internal supply rail. However, in this case, the current injected is very small, only about (5-3.3-0.5)/100 KΩ = 17 μA, and poses no harm of burn-out or distortion of internal signals. The RPi’s input pin limits the voltage applied to the N-MOSFET gate to about 3.9 V, but that is still more than sufficient to keep the MOSFET fully turned ON.”
Is this the same for the imp005?
Is there another HARDWARE CIRCUIT solution that:
- The imp can turn itself (and associated peripherals) off through software
- User can turn on the whole system by pressing a momentary switch
- User can turn off by pressing momentary switch which tells the imp to clean up what it’s doing and save any data then turn off the whole system
- User can force a turn off by holding momentary switch for a few seconds.
- The imp (and associated peripherals) will self shutdown cleanly when the imp software is signaled by the battery circuit that the battery voltage is low (the imp is the brain so it controls the systems shutdown)