2

I am working on a project where I use an esp8266 and a reed switch sensor (NO), this is powered by a battery so I need a low power circuit that can turn on the esp8266 when the state of the reed switch is changing.

I have been looking at monostable multivibrator (One-shot monostable) circuits and soft latching power circuits, but I haven't found any that fulfills my requirements.
I have also read through some other peoples questions about something very similar, but there is some information missing and other things that causes me to ask again.

Ref1: Circuit to turn microcontroller on when reed switch state changes (to monitor door lock state)
The answer here states that one should use another low-powered MCU to check the state. This is a good solution since there are many low-powered MCU's available, but this causes more complexity to the circuit and the process of programming the extra MCU. (The esp8266 is "easy" to program, but a PIC or ATTINY needs extra programmers and software)
It is ok to pass current through the reed-switch as long as it is a small current.
I want this to be as simple as possible so I can share it with the DIY community.

Ref2: I need a switch that not only detects open/close, but also sends a pulse to wake up an ESP8266 whenever the (debounced) state changes
This answer gives a "simple" way to solve this problem, and with a discrete circuit. The only problem is that when the reed-switch is in closed state it draws to much power. Also it should been controlling a mosfet instead of the esp8266 directly. (Since the esp8266 draws a bit power during deep-sleep)
This is the circuit I have made out of the answer from Russell McMahon. schematic

So my question(s) is:

  • What can be done with the schematic so it uses less than ~20uA during a idle state? (If possible even lower)
  • How could a mosfet or transistor be implemented so I don't have to worry about using deep-sleep on the esp8266? (So the mosfet will power another circuit with a LDO so I can use more of the battery)
  • Maybe there is a IC or MCU that can be used without any extra programming? If so, witch might be used?
  • Is there another solution that would be better fitted for my problem that I haven't encountered?

(The last two questions are not meant as a discussion, just to show that I am open to other solutions)

Another thing that is important is that the activation time after a state change should not be more than 500ms. How long the signal will be on after activation depends on the solution.

Let me know if something is unclear or not making sense.

John-Arvid
  • 135
  • 9
  • Totally unclear: *I am working on a project where I need a circuitry that allows for a low or high signal out when a sensor is on the rising and falling edge.* – Andy aka Nov 11 '19 at 10:48
  • @Andyaka, better? – John-Arvid Nov 11 '19 at 11:22
  • Are you looking for a circuit that will use the momentary closure of a Reed switch to initiate powering of an MCU and also that the period of that powering should have a configurable time? And that when idle, power usage should be near zero? Seems easy and I've already posted such a circuit here more than once. – jonk Nov 11 '19 at 11:55
  • @jonk, thank you for your reply. Not just the momentary closure of a Reed switch, on the state change of the Reed switch, both when it is opening and when it is closing. – John-Arvid Nov 11 '19 at 12:12
  • Okay. So on any transition of the Reed switch, it's opening or closing. Sound like you'll need a differentiator. But I'll let things percolate for a little bit before saying much more. – jonk Nov 11 '19 at 12:17
  • It could also be a two state toggle. Either way, I see a capacitor being used to hold state or else differentiate. – jonk Nov 11 '19 at 12:20
  • @John-Arvid I'm not clear. In effect you want the equivalent of a 74121 IC where you wire the reed switch to the A1 and B inputs, simultaneously? Something like that, except lower power consumption? – jonk Nov 11 '19 at 18:40
  • @jonk, thanks for your input. Yes, if I understood the datasheet of the 74121 correctly it does the same (and more) as the schematic I added to my question. But looking at the function table it looks like it needs B to be High when A1 is falling, and A1 to be Low when B is rising. This might be a problem? Also what you say about power consumption, as well as the supply voltage since this will be powered by a battery. (Li-ion or LiFePO4) – John-Arvid Nov 11 '19 at 21:33
  • @John-Arvid It's been 40 years and my memory is fading. But I think you can do this one of two ways. One would be to use a single 74121/74LS123 and just use low pass filtering. The other is to use both sections of the 74LS123. This last one should be very robust, as I recall. I think I settled on that pair, now that memory is coming somewhat back as I write. The problem you will have is that these chips want more power than you want to give them. And doing this as a discrete circuit, while doable, involves more than a few parts. Do you hate MCUs? Cheap, small, easy, and just a few microamps. – jonk Nov 11 '19 at 21:50
  • @jonk, No worries. Yeah the power draw is too big, even the circuit I have the schematic for is 320uA and does almost what I want. No I would love to use a MCU, the problem is just that I wanted to share this solution to the DIY community, and by adding a MCU that needs a separate programmer and more complex code it would be to difficult for most people to build. – John-Arvid Nov 11 '19 at 22:06
  • @John-Arvid I think a 7555 can be wrapped with some BJTs to get this done, too. The BJTs would withhold Vcc from the 7555 until an edge is detected. Then power and also trigger the 7555 for a given pulse width, after which the 7555 is shut back down. I also can see something like 3 or 4 BJTs and a MOSFET (or two) that would be entirely discrete. But I'd have to sit down and think a bit for something solid. – jonk Nov 11 '19 at 22:10
  • @John-Arvid Do you have any information on the duty cycle and cycle time range of the reed switch? Obviously, you are expecting duty cycles that aren't near 0% or near 100% or else you'd do something else. So where in between is this likely to be? And how often cycle-to-cycle? – jonk Nov 11 '19 at 22:19
  • @jonk The duty cycle and time range will be very different from time to time. But a typical behavior would be: open 2 hours, closed 1 hour, open 5 seconds, closed 2 days, open 10 minutes, closed 30 days, open 1 day, closed 2 minutes etc. But as stated in the question, a minimum of 500ms activation time after a state change, so it would detect all application relevant state changes. – John-Arvid Nov 12 '19 at 07:06
  • @John-Arvid I kind of like your schematic (it's easy to follow that an RC delays a signal to the XOR, so this is kind of nice for what you want.) Have you considered a 74AHC86? At 20 C, it says 2 uA (when inactive.) Over a wide range of temps from below freezing to "pretty hot" it says 20 uA. The AHC parts have a "pseudo-hysteresis" of sorts at their input (they have to handle slower parts driving them.) So this might be a good option, and fitting to the RC. (Obviously, change the external resistor values very substantially.) Just curious. – jonk Nov 12 '19 at 20:18
  • Just an FYI: http://www.ti.com/product/DRV5032 – sstobbe Nov 13 '19 at 19:23
  • 1
    @sstobbe Thank you for your input, I will keep these in mind if I need a smaller footprint than the reed-switch I already have. – John-Arvid Nov 13 '19 at 20:08
  • There are dedicated IC's for this, such as MAX16054, LTC2950, or STM660x – Luke Jun 22 '20 at 16:47
  • @Luke Thanks for your input. It looks like these won't trigger on both rising and falling edge. ref max16054 description: "the output remains unchanged on the rising edge of the input" – John-Arvid Jun 23 '20 at 17:47

2 Answers2

0

Context

My first thoughts about doing this with discrete parts means breaking the problem up into sections and then connecting the sections together. These ideas would include mosfets for the obvious reasons -- given your time scales, which are long when compared to device speeds, large-valued resistors are a goal to reduce idle currents. Using BJTs alone would make this more difficult (but not impossible.) That said, BJTs can easily be a part of a very low current design.

But my second thoughts are that this would be broken into multiple sections and you need several features, each of which take some care to design, and over-all requires a fair number of parts. It would be much nicer to just use ICs.

My third thought was "just use an MCU." These are readily accessible to hobbyists, cheap, and can achieve the low power while at the same time allowing for version 2, version 3, etc., of the software to achieve new features and/or improve on old ones without needing to change the design topology. It's crazy that hundreds of thousands of transmission gates and inverters can be arranged at low cost and available to all of us while achieving such low current requirements. But you've nixed that as the software toolchain issue may greatly reduce your DIY target audience.

[Just FYI, if you can accept larger packages, the TI MSP430 is probably the way I'd prefer to go for ultra-low current. The smallest that a hobbyist could use would be their SO-8 packaging (they have wafer-scale, but I don't know many hobbyists working at that level.) If I wanted to go with a SOT23-6, I'd go with the PIC10(L)F322 device, or similar. These are XLP "extra low power" (which still isn't as good as an MSP430) and could do the job with a little care, I think.]

So let me pause for a moment and re-state in my own words what I think you want, given the question and your comments:

  • \$\le 20\:\mu\text{A}\$ idle current, regardless of the state of the reed switch
  • any change in state of the reed switch initiates an active pulse (probably doesn't matter if it is active-high or active-low) that lasts for an application-dependent time (which implies it must be settable.)

Something unstated so far is this:

  • should there be an input that can be used to shorten the active pulse if more than enough time has gone by (as determined by some ESP8266 or other controller board) and the controller would like to terminate the active pulse earlier than otherwise?

All this still very, very strongly suggests an MCU to me. I don't know your target DIY audience, but if it is everyone doing anything with an MCU board that draws power and would like to mitigate consumed energy after being woken by a human, then that is a very wide audience and probably only a small subset of them could pony up for the tools and investment in software skills to program their own device -- even if they are given assembly code for free to do it and don't have to pay a nickel for the software. (Such as with MPLAB-X.)

I'd like to suggest that you consider setting up someone as a point of sales contact or distribution for such a device. You can ship to Amazon, for example, thousands of pre-programmed devices -- ready to go. Amazon will take care of ALL of the logistics. And the customers can just "go buy one" whenever they want and you don't need to worry much. Amazon will let you know when they need more of them. And you can use a very tiny profit in all this to get yourself to break-even on the deal. In this way, you've created something useful, made it available, and don't have to baby-sit it all the time.

That's probably what I'd do. And if it is worth doing, the small initial investment on my end wouldn't bother me in the slightest.

One non-MCU Suggestion

Probably the first thing, non-MCU, that came to mind is what I used to have to do "back in the day" when an MCU was a non-starter as they didn't yet exist (in my world, anyway.) That's using a 74LS123. But let's switch that up and use a 74AHC123, because these have much lower idle current draw. (A typical of \$2\:\mu\text{A}\$ at \$25^\circ\text{C}\$ -- the datasheet figures suggest this increases by 50% for each increase in temperature by \$10^\circ\text{C}\$.) Something like this:

schematic

simulate this circuit – Schematic created using CircuitLab

The OR gate would draw from the same part family, of course. (Or, if creative, you could make something discrete, instead.)

I've not tested the above and I'm just going from vague memory, plus using a newer device I've never actually used before, too. I think it will work. But I may have made some mistake, too. And I don't have a ready model to use in simulation for the 74ACH123. So, it's all paper and pencil, for now, and from a mere hobbyist -- no professional here.

There are other ideas, such as wrapping a 7555 with some BJTs to de-power it after it finishes its one-shot output triggered by a reed switch state-change. I could draw that up, after thinking more about it. But that's more time and right now I'm kind of just wanting more input about the above thoughts first. Let me know.

jonk
  • 77,059
  • 6
  • 73
  • 185
  • Thank you for your good answer! Regarding a MCU, if I could have programmed it with a FTDI or TTL programmer it would have been fine. Since I don't think the number of people using this solution will be more than tens or hundreds I can't have it to complicated. (I am even worried that the SMD components will cause less people to use it) Regarding the unstated, yes, the best would be that the ESP8266 gives a signal when it is done. But if to complex, it would be better to use a set time (15s). – John-Arvid Nov 13 '19 at 10:27
  • Also if using deep-sleep on the ESP8266 the out signal needs to be Low. But if using the out signal to open a Mosfet or BJT, it can be used like this. – John-Arvid Nov 13 '19 at 10:29
  • @John-Arvid At ten or so, I'd just offer the service (probably for free.) I'd just ship to anyone, no money changing hands, no matter the cost to me. It can't be so much I'd hurt. If you are talking about hundreds, perhaps, I'd probably still do it for free... but at that level I *might* set up an Amazon account and do it that way. But I actually think that a well-considered design could be crafted in SOT23-6 that would have very broad application. You'd need to write an easily read application note so that artists could understand it. But I think it could reach many people. – jonk Nov 13 '19 at 16:54
  • @John-Arvid What do you think of the 74AHC123 design, though? Is it workable? Would you prefer to see something with the 7555 (or 555, perhaps?) – jonk Nov 13 '19 at 16:56
  • We can talk about that on another channel if you want. I really appreciate your offer and help. Yes absolutely, the 74AHC123 design looks very good. Could it be changed to use the /Q instead? Or would it be easiest to change the OR gate with a NOR gate? – John-Arvid Nov 13 '19 at 18:05
  • @John-Arvid I actually think you are perfectly capable of working all that out. Your writing certainly indicates to me that you were already on the right track at the outset and that you follow things well. So why not try your hand at the thought? (The datasheet is pretty clear and I've provided something to begin with.) I'm already drawing up a product line of SOT23-6 MCU products and this is going into the hopper. – jonk Nov 13 '19 at 19:52
  • Thanks, I will try. I will get some parts so I also can do a hands on later. – John-Arvid Nov 13 '19 at 20:07
  • @John-Arvid Hmm. I just read a note that says they are going to reward 10 pts for an upvote on questions, now. (Used to be 5.) You get to be my first experiment to see if that works. ;) I'm going to +1 your question and see what happens. Ha!! It worked!! – jonk Nov 13 '19 at 20:13
  • Thank you for your upvote! As my first question I am glad I got this good response and help. I will upvote this answer when I have enough reputation. I will accept this answer since it has pushed me towards finding a much better solution. – John-Arvid Nov 13 '19 at 20:21
0

Answering my own question since I have found a complete solution.

This is a working prototype that I made. You can see more details about parts, modify and order your own if you want.

This is the schematic:
schematic

Here is a link to my project on jlcpcb: https://easyeda.com/jakibsgaard/low-powered-rising-and-falling-power-on-circuit

I have also a open question where I want to improve the circuit I have made. But that is not required. This has much more information about the circuit I made. Improving edge detector with latching circuit for esp8266

John-Arvid
  • 135
  • 9