sblantipodi / glow_worm_luciferin

Bias Lighting and Ambient Light firmware, designed for Firefly Luciferin.
GNU General Public License v3.0
158 stars 19 forks source link

[Feature request]: Support for a power supply relay #22

Closed ReiberAndras closed 3 years ago

ReiberAndras commented 3 years ago

Is your feature request related to a problem? Please describe

No

Describe the solution you'd like

First of all kudos for this great piece of software.

REQUEST: Please consider adding a feature to make it possible to use a power supply relay.

Being able to use 2 separate power supplies - a "small" one to power the board with 5v and GND and another "big" one to provide power for the LEDs with a relay attached - would be really nice. So when powering off the LEDs completely it can trigger a relay to shut off power to the LEDs (via the “LED Power Supply”) while a separate power supply could keep the ESP board awake constantly.

Describe alternatives you've considered

Using another ESP board with a relay which works, but this way I need to use two separate devices.

sblantipodi commented 3 years ago

@ReiberAndras thank for taking time to suggest new features, I'm always glad to hear new ideas.

Can I ask you why you want to have a relay? If you turn of the LEDs it's like if the strip is powered off, it doesn't consume power, so why have a relay to cut the power to the strip?

I'm sorry if I don't understood well...

some new PCBs is coming so new ideas on this ares is very welcomed :)

image

ReiberAndras commented 3 years ago

Hi Davide,

Thank you very much for your reply. First of all I am not an electrical engineer, so I might be wrong, so please read my comment with that in mind.

Digital LEDs have a tiny controller inside of them, so even when you turn them off each LED will continue to use a little bit of power. This might be negligible for smaller installations, but not desireable in larger ones. My set up includes a PCTV and a TV set, meaning that I am going to be driving 208 LEDs in total.

Quindor from quinled.info did a gread job in measuring the power consumption of different LED strips under different usage patterns. I have a WS2812b-Eco LED strip which is the most economical, but it still uses 5W of power per 5 meters or per 300 LEDs. Projecting that number to 208 LEDs means that I am going to be wasting 3.5W of power. To put this into context I have a 4W LED light bulb in my desk lamp.

You can find Quindor's measurements here.

Including a power relay we can prevent this energy being wasted. We have two options:

Quindor has a good article on this topic.

I have a cheap Chinese relay rated for 10A AC. I didn't find any good data sheets which would give me a reassuring answer on what is the maximum current it could handle with DC. Because the relay needs to carry a lot of current if I were to use it in the DC path I guess the Amperage must be much lower.

It is described here that the DC current rating of a relay is usually below the AC current rating. Also another limitation factor for switching DC is usually the maximum voltage, but above all the main limitation is the contact set's ability to break the arc that forms at the contact surface. When AC is switched the voltage and current fall to zero and reverse polarity at twice the AC frequency (ie 2 zero crossings per cycle). This drop to 0 Volts and polarity reversal leads to extinguishing of any arc that forms (within the rated operating conditions.) With DC there are no zero crossing points and arcs can form and sustain at far greater distances for a given voltage / current. This is a good video demonstration.

So I found that for my use case using a relays on the AC path is much safer, not to mention that my Meanwell LPV-100-5 60W power supply is using 0.3W even when it has no load on it. (Meaning that the LED strip and the power supply wastes 3.8W of energy together which is a lot.) Obviously I need a second small power supply to constantly keep the ESP board on. Using a second PSU would hopefully mean that I can extend the lifetime of 60W bulky one a bit. I saw premium class 12V LED Power Supplies stating that they are suitable for 10-12 hours daily use and usage of the product for 24 hours a day would void the warranty. So that is another aspect as well.

By the way I tested a MeanWell APV-8E-5 (out: 5v/1.4A) small power supply and a phone charger and I couldn't detect any power consumption. I guess that is because I don't have sensitive enough equipment, but I am sure there must be even it is negligible. Nowadays phone chargers produce their outputs by converting AC -> DC -> AC -> DC just to be able to keep their dimensions so small. I guess that many conversions makes them less efficient, but might be still more power efficient than keeping a bulky power supply constantly on.

The DigUno and DiqQuad boards are prepared to use 2 power supplies by sharing their grounds and WLED also has relay and push button support. So I thought it would be a great idea to add this functionality to luciferin as well.

Regards, Andras

sblantipodi commented 3 years ago

@ReiberAndras thanks for the detailed explanations and sorry for the late reply.

As Luciferin is not an hardware components (for the moment) but only a firmware/software all I can do is to add the possibility to drive the relay via a GPIO pin. is this enough to cover your scenario?

Did I get it right?

andras-reiber-epam commented 3 years ago

@sblantipodi Yes, it would be great if you could implement the logic to turn a user selectable GPIO pin on (high) when the LEDs are on and off (low) when the LEDs are off.

Preferred gpio pins for esp8266 would be: GPIO12 (D6) or GPIO13 (D7)

Preferred gpio pins for esp32 would be: GPIO19 or GPIO23

As an extra you could also add some wait time (preffered to be configurable in milliseconds) before turning on LEDs after turning on power/relay (pulling the respective pin high) in order to avoid issues to display inaccurate effects due to the fact that power from the power supply would not come immediatelly, but driver signals were already dispatched.

Thank you for your consideration.

sblantipodi commented 3 years ago

@andras-reiber-epam I love this kind of feature request, thanks for the idea, I'll implement it soon, leave this feature request opened until the release.

If you like Luciferin, please don't forget to cast a star here on GitHub :)

Thank you!

sblantipodi commented 3 years ago

hi @andras-reiber-epam can I ask you why the preferred PIN are those ones please?

Preferred gpio pins for esp8266 would be:
GPIO12 (D6) or
GPIO13 (D7)

Preferred gpio pins for esp32 would be:
GPIO19 or
GPIO23

Is there a particular reason for this?

andras-reiber-epam commented 3 years ago

Hi @sblantipodi ,

Those header pins are lead out to the dig uno board.

sblantipodi commented 3 years ago

ok @andras-reiber-epam, for the moment I added support for GPIO12 on ESP8266 and GPIO19 on ESP32. I'm going to release it soon.