HAD Article, Improvements

A project log for ESPLux - Smarts for your downlights

A circuit you can place inline with your existing low voltage lights to allow for wireless control

mattMatt 07/27/2015 at 07:567 Comments

Wow thanks everyone! I wasn't expecting an article posted about my little project.

Thanks to @arcol and @bogdan for their input, I'm keen to include your suggestions into my project.

@arcol suggested that I should use different colours for the input and output terminals, which is a great idea, I didn't realise there were different colours in the same type. He also suggested using spring terminals and having two different locations to be able to wire the DC out into, both which I'll be looking into in the near future.

@bogdan noted, rightly, that the rectifier will get warm pretty quickly, which is correct. He suggested using active rectification to reduce the amount of heat produced in the process of getting a DC signal out. I hadn't heard about this before, so I was intrigued. It looks like you can use a couple of MOSFETs to perform the same role. Two downsides that I can see for this are, first, added complexity. This shouldn't be a problem, just something I need to wrap my head around! The second is the Vgss value on whatever MOSFET I choose, I need to make sure that it is capable of handling the voltages that I would like the ESPLux to handle. Alternatively I should be able to throw a zener diode in to drop the voltage to an acceptable level. I am super keen to have a shot at getting this working, it'll increase the number of lights that you can run on one unit.

Thanks again for everyone who has followed me in the past 24 hours, I'm chuffed at the amount of people who are interested in it!


arcol wrote 07/27/2015 at 10:49 point

@Matt: So are you saying, no electrical modification is needed, the current version is good enough to hold the voltage long enough to register the different functions?

  Are you sure? yes | no

Matt wrote 07/27/2015 at 11:06 point

Nah, it stores it in a text file on the unit itself. So you change the light value, it writes it to a file. On startup, it checks this value and then sets the light based on that if you have chosen to do so. Based on this functionality, it would be relatively trivial to make it so if the previous value was 100%, the next power on would be set to 50%, then next power on would be 10%, then back to 100% and so on. Of course, this would be another feature set in the firmware, but it is possible to do it without any modifications to the board. There are some problems with my method, for example, it wont matter how long the light has been off, it'll always just choose the next in the sequence. This might not be what you are after when you are trying to turn on your night light in the middle of the night, but it is a potentially useful feature in any case.

  Are you sure? yes | no

arcol wrote 07/27/2015 at 18:29 point

Is there a way to measure time without power? 

If so, it could default itself if between two switch no more then 10 minutes have passed. 

Still, I think the best would be to notice the power outage, and save it. So a 5-10sec of power on 3.3V rail should be more then enough...

  Are you sure? yes | no

Matt wrote 07/27/2015 at 22:58 point

Not that I am aware of, without contacting the net, which will introduce a significant delay in responsiveness.

I've done some calculations to see how much capacitance I would need. If anyone reading this knows more about this than me, please chime in. On a busy wifi network, the ESP8266 will consume 62mA ( This means to have the unit on for 10 secs, we will consume 0.17mAh  (60mAh / 60 / 60 * 10) or 167uAh. 

To convert this to farads (rough I know), I used this page:

According to this, I would need 0.27F (270000uF) of capacitance. In standard capacitors, that is quite a significant amount of board space. I haven't looked into supercaps yet, but i believe I am looking at something around 10mm in diameter. I'd like to keep the current footprint at this stage, so I am not sure if I can fit it on the board. I will have a look into it in the next board revision. There are other things that I need to take into consideration also, like how to determine when the light has been switched on/off when the circuit is being powered by the charge circuit. These problems aren't insurmountable, however, it is something for another day. Thanks for your suggestion in any case, I believe it is a very useful feature.

  Are you sure? yes | no

arcol wrote 07/28/2015 at 08:29 point

Thank you researching my idea.

The 10 sec was a ballpark number only, I think a 1-2 sec is enough. The feature may work even at 500ms. But to work we need to detect power outage instantanously. 

Looking at your page, there are some other power state mode (power save mode DTIM 1,3, standby). Maybe when we detect power outage, we switch off wifi immediatly and save the current state.

I assume you are using NodeMCU:

If in case of power outage we enter in deep sleep mode immediatly:

node.dsleep(us, option), and wake up to GPIO16 (that is a logical 1 if there is power. A MOSFET maybe?).

If there is no wake up signal, that means we have been switched off for real. So we wake up after 2 sec, and write to the file what we want, and die gracefully.

If the above functionality is not enough we can still switch off wifi to save power (wifi.sleeptype())

Calculating with 2 sec, and deep sleep (10 uA), and 200ms for power save mode (1.2mA), the figure is not that scary:

((10/1000) / 3600 ) *2 + (1.2 / 3600) * 0.2 = 0.06 uAh (!)

Using your site it ends up 5uF capacitor. 

It does not seems like a mission impossible thing to me. I know it is ideal condition, maybe I even missed a magnitude here and there, but the point is, we do not need wifi while power has been cut.

  Are you sure? yes | no

arcol wrote 07/27/2015 at 09:03 point


I really appreciate listening to me. 

I'll throw a yet another idea, it is rather crazy, so don't take it too serious.

I'm wondering if we could command the light via a single switch. Like two short turn on/off means switch off after 10 minutes. 

The key to work for this is to be able to be powered on for 10 sec after the power has been cut. I don't know how big capacitor is needed but I suspect esp8266 do not consume too much current. So it could detect the power has been cut, and could act accordingly. I'm thinking like one short on/off, two short on/off, and maybe switching on off three times. We could assign different functions for each switching mode.


- night lighting (50% reduced light)

- timer to switch off (like 10 minutes)

- switch off some predefined lamps from a set of lamps.

But maybe it is too difficult to implement. Just an idea.

  Are you sure? yes | no

Matt wrote 07/27/2015 at 09:43 point

Interesting idea! And to be honest, it probably wouldn't be overly difficult to implement some parts of this through the existing firmware.

At the moment, I take note of the last known brightness of the light, and I've got the option to either remember the previous setting on AC on, or set it to full brightness. Another option could be that it could iterate through each of the different options, like full brightness, 50% dim, etc. Having said that, my priority is right now to try and get three of them out the door for the best product prize, so once that it sorted, I'll start investigating additional options for the firmware. I am quickly running out of time! Making the UI easy would be the tricky bit, making it so anyone can intuitively use it. Thanks for your suggestions!

  Are you sure? yes | no