Low power, tiny, wall switch controlled ESP8266, for a hue project

Thread Starter

Ztimac

Joined May 8, 2021
6
Greetings enthusiasts!

I've joyfully immersed myself in a DIY project controlling Hue lights with a wall switch. Hoping for some tips to get me through as I haven't done any electronics since high school. In my 40s now.

My main inspirations is a project on diyhue and one on this forum using a ESP8266 wi-fi microcontroller. My goal is to combine the two for a low power (battery powered) solution with a double wall switch i.e. four states, small in size for mounting behind the switch.

For the moment, we'll not worry about the actual GPIOs. The ESP8266 apparently provides a deep sleep mode and is awaked by pulling down the RST pin. The diyhue project demonstrates this with a push button, however, like the aac-project, I need pulses on both the on and off sides. The mcu will wake up, read the state, do its thing and go back to sleep.

On the other hand, I'm worried about the power consumption of the aac-project. No point in exploiting the deep sleep function if the support circuit is going to drain the battery if any switch is in the on state, requiring an exchange of battery every few weeks. Perhaps redimensioning the spark protection would do it, but I'm out of my depth as to side effects.

One of the first questions asked in the aac-project was, discrete or IC. I'm not concerned either way, as long as power consumption and dimensions are kept low.

Any tips very much appreciated!
 

wayneh

Joined Sep 9, 2010
17,498
My goal is to combine the two for a low power (battery powered) solution with a double wall switch i.e. four states, small in size for mounting behind the switch.
I'm wondering about the strategy of using a battery when there's line power so readily available. Why not take power off the line and just leave the device on all the time? It's far less power than a nightlight and probably no more than all the other things we leave plugged in 24/7.
 

Thread Starter

Ztimac

Joined May 8, 2021
6
I'm wondering about the strategy of using a battery when there's line power so readily available. Why not take power off the line and just leave the device on all the time? It's far less power than a nightlight and probably no more than all the other things we leave plugged in 24/7.
1. It's more interesting that way. I could easily do it with the MCU looping eternally.
2. Line power is not actually readily available. I'd need need a 230 V DC in the wall and I'd need to burden you with questions about fire safety instead.
 

wayneh

Joined Sep 9, 2010
17,498
I'd need need a 230 V DC in the wall and I'd need to burden you with questions about fire safety instead.
I was imagining this installed in a standard electrical box where there are already line-power switches. Are you saying this is a standalone switch-box, like a big remote control?
 

MisterBill2

Joined Jan 23, 2018
18,502
Certainly one option to reduce the battery consumption would be a 3 position, spring return to center off, toggle switch, instead of a traditional wall switch. Since the proposed control transmitter is battery powered, the rules for 230 volt mains powered wiring do not apply. A standard electrical box and standardswitch cover plate, or a home-made cover, can comply with code requirements easily because of low voltage battery power, not mains.
That would be one way to do it.
 

Thread Starter

Ztimac

Joined May 8, 2021
6
I was imagining this installed in a standard electrical box where there are already line-power switches. Are you saying this is a standalone switch-box, like a big remote control?
Yes!

Certainly one option to reduce the battery consumption would be a 3 position, spring return to center off, toggle switch, instead of a traditional wall switch. Since the proposed control transmitter is battery powered, the rules for 230 volt mains powered wiring do not apply. A standard electrical box and standardswitch cover plate, or a home-made cover, can comply with code requirements easily because of low voltage battery power, not mains.
That would be one way to do it.
I've already purchased the switch at a flee sale. It's vintage and lovely.
 

MisterBill2

Joined Jan 23, 2018
18,502
It may be possible to add to the original vintage switch so that it provides a closure in each direction. Then, use capacitance coupling to obtain a short pulse as each closure is made. And because the switching will be done at logic levels, the requirements for mains switching applications will not apply. This will allow quite a bit more freedom to create switching points.
 

Thread Starter

Ztimac

Joined May 8, 2021
6
It may be possible to add to the original vintage switch so that it provides a closure in each direction. Then, use capacitance coupling to obtain a short pulse as each closure is made. And because the switching will be done at logic levels, the requirements for mains switching applications will not apply. This will allow quite a bit more freedom to create switching points.
Maybe. Or maybe the other way around, so that there's closure between the endpoints.
 

wayneh

Joined Sep 9, 2010
17,498
The ESP8266 apparently provides a deep sleep mode and is awaked by pulling down the RST pin.
Do you have the info on what it takes to trigger that? How long, for instance? I agree that a capacitor-coupling may be all that's needed to accomplish the triggering. Easy enough to experiment and find out. I's start with a 0.1µF ceramic, just because that's cheap, small, and commonly on hand for use as a bypass capacitor on every IC. If it works, you're done.
 

MisterBill2

Joined Jan 23, 2018
18,502
I like even better the concept of a closed contact during the transition and being open at each end. That delivers the functionality with no extra parts. Of course, contact bounce could provide a bit of entertainment.

The fact is that such a setup could allow me to install ceiling lights without needing to pull wires in the wall. That could make me a surer-hero for a few folks.
 

Thread Starter

Ztimac

Joined May 8, 2021
6
Hello! Hope some of you are still with me after so long time. I started experimenting with LTSpice, and the summer came...

Anyway, what I've come up with originates from the diyhue project linked in the question. Remember, I'm trying to go from a wall switch on/off action to short pulses to wake a microcontroller.

This design seems to do precisely that. But will it really work?

1631562164979.png

Way at the left I have my battery stack and I'm taking my reference ground between them. Then I have a voltage controlled switch to simulate the on/off action of the wall switch, 2 second per period. The first plot is probed at the resistor marked R8.

Next is the essential part of the design from the diyhue project.

Then comes a circuit largely copied from here but I've exchanged the opamps to low power variants. It's an absolute value circuit.

1631563578720.png

The following is the input to the absolute value circuit at C2. As expected we have stong pulses on switch ON, but also a small negative pulse on switch OFF.

1631563963402.png

Putting it through the opamps brings us this:

1631564065835.png

Looks good to me. Will it work?
 

Attachments

Top