Alternative to pull-up for flipping pin 1 wakeup behavior?

When you configure pin 1 for DIGITAL_IN_WAKEUP an internal pull-down is enabled.

However I have a setup where I want the Imp to wakeup when a switch is opened, not when it is closed.

The simplest way to invert/flip the behavior of my switch is to add a pull-up resistor.

I’ve done this and my Imp indeed now wakes up when the switch is opened.

I’ve found that the biggest resistor I can use for the pull-up is about 10KOhm, if I go much above this the Imp will not wakeup.

My external pull-up and the Imp’s internal pull-down are acting at cross purposes.

And my pull-up is rather ruining the whole power efficiency of having the Imp in deep sleep mode, the Imp may draw just 6uA but the connection from pin 1 thru my 10KOhm resistor to 3.3V will, if I understand things correctly, continuously draw 0.33mA.

Is there a more efficient alternative to my pull-up or can I easily reduce the current it draws (by using a transistor?).

Sorry if the solution is obvious to those from an electronics background but I come from a software background and unfortunately take a rather cook-book approach to the electronics side of things. I’ve had a good search around on the Imp forums, but it’s hard to sift out pin 1 wakeup related questions from all the questions mentioning imp.wakeup(…). And via Google I’ve found lots of pages on how to improve power consumption when using batteries that include helpful hints like “eliminate the use of pull-up resistors” but haven’t found one that actually goes into clear examples of how to do so :frowning:

Thanks for reading this far and thanks for your help.

/George

Yep: though it seems a bit counter intuitive to use a chip here, a single inverter - eg http://www.nxp.com/documents/data_sheet/74LVC1G04.pdf - is going to be a lot lower power.

Typical input current for this is 0.1uA, and input leakage is low meaning on the input of the inverter you can likely use a 470k resistor: total power for the entire circuit (with switch closed) would then be: 0.1 + (3.3/470k) = 0.1 + 7 = 7.1uA.

You can use a transistor too. Ideally, you use a PFET: connect source to 3.3v, drain to imp pin 1, and the gate to your switch. When the gate goes low (at least “Vgs” below source, ie 3.3v) the current will flow through the FET and pull pin 1 up.

You need to ensure you get a PFET whose maximum Vgs is less than 3v, but as the input leakage of the gate is pretty much infinite you may be able to get away with a 1M+ resistor on your switch.

The issues with using a PFET vs an inverter are mainly due to the sensitivity of the parts. The inverter is pretty bomb-proof, but directly connecting a discrete FET gate to some long wiring may give you reliability issues (plus, even a little leakage across the switch due to moisture in the air could affect the operation if you use a 1M+ resistor).

Single through-hole FETs are a bit hard to find, but here’s something that looks suitable:

http://www.digikey.com/product-detail/en/ZVP4105A/ZVP4105A-ND/152499

Great thanks @Hugo for a perfect answer. The inverter sounds like the solution to go with - for someone with my background “bulletproof” sounds good and this project actually does involve longish wires as the switch involved is physically separate to the rest of the circuit. It’s a shame the 74LVC1G04 doesn’t come in a through-hole version - it does though seem to come in quite a number of SMT packaging type - I guess the easiest thing is to try hand soldering the TSSOP version. I’ve never tried soldering SMT parts before but I guess one has to start somewhere - I’d better buy some thinner gauge solder :slight_smile:

Forgive me if I’m not understanding your problem. Are you wanting your Imp to wake up when a physical switch is opened? If so, just wire to either the normally open or normally closed terminals as desired. For example:

If your switch needs to be closed most of the time (activated physically) but you want to use DIGITAL_IN_WAKEUP with the internal pull-down, then connect the 3.3v to your input pin through the normally closed contacts. When you un-activate the switch, the connection will be made and the pin will go high and the Imp will wakeup.

Correct?

Sorry - @dheadrick - I guess I’m parsing your answer wrong but I’ve got absolutely no idea what you mean :frowning: I may not come from an electronics background but even then I think I would be able to get my head around anything involving something as simple as a switch.

My switch is the classic SPST, i.e. something like this:

SPST-Switch.svg

Are you assuming that I’m talking about something like an SPDT?

SPDT-Switch.svg

I’d assumed the switch wiring wasn’t changeable, but switches come in two flavours:

SPNO - single pole, normally open (press to make)
SPNC - single pole, normally closed (press to break)

As @dheadrick says, if you have an SPNC and wire it between 3v and pin1, that’ll also work :slight_smile:

OK - thanks @Hugo. Maximising the acronyms - my switch is an SPST SPNO :slight_smile:

And as it is connected by longish wires I’ll stick with your suggestion and try soldering the TSSOP version of the 74LVC1G04.

Yeah… I’m used to switches having both NO and NC contacts on them (SPDT)