Momentary power switch for imp005

I want to add a momentary power switch to my imp005 based project where:

  1. The imp can turn itself (and associated peripherals) off through software
  2. User can turn on by pressing a momentary switch
  3. 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
  4. User can force a turn off by holding momentary switch for a few seconds.
  5. The imp (and associated peripherals) will self shutdown cleanly when signaled by the battery circuit that the battery voltage is low

I found a circuit for the RPi which does this at http://www.mosaic-industries.com/embedded-systems/microcontroller-projects/raspberry-pi/on-off-power-controller

It uses GPIO4 which is pulled high and is an input initially when the Pi turns on.

Will this circuit work with the imp005 or is there a better circuit and/or method to get the result I need to get?

Thanks,

All of those things are possible with the imp. But can you tell us what the imp is actually supposed to do while it is doing things? You mentioned saving data. What will the imp be doing that is collecting data?

And you should also know that the imp has to be in “touch” with your WiFi. It can’t just run alone out in the wild. That means it could be saving data on a website (server database) all the while it is running.

The imp has it’s own sleep mode and wake-up using an input pin (momentary button). It can sleep based on time, command via the internet, or a physical input.

It counts pulses and needs to save its last set of counts before shutting down in the event there is no internet connection at the time.

The imp requires the agent (on the Internet). After a certain amount of time it cannot reach the agent, I’m not sure what happens. The script may stop and execute anew once connection re-occurs. Perhaps the imp is not the best device for your application?

Google: ESP8266
You can program that using Arduino IDE
Does not require a cloud, but you have to program all of the WiFi stuff yourself, using the IDE

My question is peripheral hardware related (controlling the power supply for the imp and it’s connected components, both by human and by the imp itself). Is the solution in the link as used by the RPi workable to meet the requirements mentioned for both the imp and it’s associated components which run of the same 5V supply the imp does. It looks to be, but does the imp have a GPIO pin that has the same as the RPi GPIO4 which is an input pulled high on start via pull-up resistor (ie it doesn’t need code to set it in the correct state).

@mlseim, thanks. The imp005 is the correct device. I’m not looking to change that as it functions very well for quite some time (days) without being able to talk to the agent or have any internet connectivity. To be clear, not using WiFi for this project.

Could you go into a bit more detail here? The imp005 does not have a working low-power sleep mode, and is not generally recommended for battery-powered applications. Other imp types offer a built-in “wakeup from sleep” pin, see DIGITAL_IN_WAKEUP on pin.configure() | Dev Center, as well as other optimisations for low-power usage. (You’d still need to implement “clean shutdown on low battery” yourself, though.)

Peter

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.

Link: http://www.mosaic-industries.com/embedded-systems/microcontroller-projects/raspberry-pi/on-off-power-controller

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:

  1. The imp can turn itself (and associated peripherals) off through software
  2. User can turn on the whole system by pressing a momentary switch
  3. 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
  4. User can force a turn off by holding momentary switch for a few seconds.
  5. 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)

The point Peter was making is that other imps - pretty much ANY other imp aside from 005 - has the ability to go into a deep sleep where it consumes just microamps. This is pretty much “off” - they also have ADCs so can monitor battery voltage, etc.

If you really want to use the 005, then sure, you can use a circuit like the one on that page.

Possible issues:

  • GPIOs are not “fail-safe” (ie should not be powered when the chip is not powered). That’s also a limitation of the Pi - so try it and it may work for you, but don’t go to production with a circuit like this.

  • The pulling up of a 3.3v pin to a 5v supply is not a good thing (as also noted on that page and in your message)

Any of the pulled up GPIOs (as you say XB, XC, XD, XE) should work here, yes.