Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[latching relay] adding support for one trigger pin instead of two #18386

Closed
5 of 14 tasks
Gifford47 opened this issue Apr 11, 2023 · 11 comments
Closed
5 of 14 tasks

[latching relay] adding support for one trigger pin instead of two #18386

Gifford47 opened this issue Apr 11, 2023 · 11 comments
Assignees
Labels
enhancement Type - Enhancement that will be worked on fixed Result - The work on the issue has ended

Comments

@Gifford47
Copy link

PROBLEM DESCRIPTION

Hey! I have this latching relay

I have tasmota 12.4 and configured the esp pin as relay_bi because the relay is triggered by low level. But every time I need 2 clicks to switch the relay. So I need 4 clicks to switch the relay on and off again. Normally I only need 2 impulses to switch it on and off.
i think this topic here is the first to introduce the implementation of a bistable relay.
like @arendst said, i need to configure two configure two pins to switch the relay. My one has only one trigger pin to toggle both states. And there are many other bistable relays that have only one trigger pin.

It would be awesome if there is an option (i.e. setoption or a #define to compile my own build) to toggle such a relay with only one gpio. I know that there is no acknowledgment that the relay is in the right state, but as long as it is not accidentally switched in the boot phase or through incorrect configuration, you don't need it.

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

  • Read the Contributing Guide and Policy and the Code of Conduct
  • Searched the problem in issues
  • Searched the problem in discussions
  • Searched the problem in the docs
  • Searched the problem in the chat
  • Device used (e.g., Sonoff Basic): _____
  • Tasmota binary firmware version number used: _____
    • Pre-compiled
    • Self-compiled
  • Flashing tools used: _____
  • Provide the output of command: Backlog Template; Module; GPIO 255:
  Configuration output here:

  • If using rules, provide the output of this command: Backlog Rule1; Rule2; Rule3:
  Rules output here:

  • Provide the output of this command: Status 0:
  STATUS 0 output here:

  • Set weblog to 4 and then, when you experience your issue, provide the output of the Console log:
  Console output here:

TO REPRODUCE

EXPECTED BEHAVIOUR

The ESP is able to toggle a bistable relay (like the device above) with only one gpio (relay_b).

The procedure would be:
Init:

  • define one gpio to relay_bi (or relay_b)
  • gpio is at high level
    ->relay is at state 0

toggling relay:

  • tasmota switches gpio to gnd for pulsetime(x) seconds
  • tasmota switches gpio back to high level
    -> relay is now in state 1

toggling relay to state 0:

  • same procedure like above

SCREENSHOTS

ADDITIONAL CONTEXT

(Please, remember to close the issue when the problem has been addressed)

@barbudor
Copy link
Contributor

Use a standard Relay with Pulsetime to generate the toggling change
With a single pin bi-stable relay you will never be able to synchronize Tasmota power state with the relay state. If you need so, you need a feedback from the relay to a switch input

@Gifford47
Copy link
Author

Gifford47 commented Apr 11, 2023

Use a standard Relay with Pulsetime to generate the toggling change With a single pin bi-stable relay you will never be able to synchronize Tasmota power state with the relay state. If you need so, you need a feedback from the relay to a switch input

yes, but then i had to track the state otherwise.
Why should it change without tasmota noticing? the only trigger comes from the tasmota gpio. i've had it running with custom firmware for weeks. but i'd like to run it with more features with tasmota.
here is the commit from the past

@arendst
Copy link
Owner

arendst commented Apr 13, 2023

As @barbudor stated use pulsetime to toggle your relay. Why all the hassle for wanting to know a state where the relay itself not even knows it's state.

The current implementation (and the legacy implementation) both use two pins to know a fixed state of the relay. They are the known commercial bi-stable relay solutions too.

@Gifford47
Copy link
Author

yes, you are right! one trigger for one channel is always the best!
but in my case you only need to know the initial state before triggering. after that you only need to track the state with the logik/software. as i said it runs for weeks with 6-10 toggles a day. and there are a bunch of relays with only one trigger.

but if it isn´t wanted by now, can anybody push me in the right direction to build my own version please? i only do not know how to toggle the first relay again instead of the second...

@barbudor
Copy link
Contributor

There are still possible reasons for it to go wrong but that's your choice

With an esp8266 I would go by defining a virtual relay on an unused gpio and a rule set to trigger the actual control pin as a relay with pulsetile
Use WebUI and MQTT only to control the virtual relay and let the rules handle the real thing

If you have an esp32 you could most probably write a driver in berry

Making changes in Tasmota that won't be merged is not a good solution as it will require you to maintain this fork on your own and report all changes from the core to get the new features

@Gifford47
Copy link
Author

With an esp8266 I would go by defining a virtual relay on an unused gpio and a rule set to trigger the actual control pin as a relay with pulsetile Use WebUI and MQTT only to control the virtual relay and let the rules handle the real thing

Thanks (also for your time)! that´s a good idea! I will try that soon!

@Gifford47
Copy link
Author

ok, for my case @barbudor has solved my issue. I toggle the relay with a rule watching var1. on both sides i enabled qos2 via mqtt.
i would be happy if such a function would be implemented anyway. But I can also understand if the benefit is too small for others.

@arendst arendst self-assigned this Apr 18, 2023
@arendst arendst added enhancement Type - Enhancement that will be worked on fixed Result - The work on the issue has ended labels Apr 18, 2023
@arendst
Copy link
Owner

arendst commented Apr 18, 2023

Implemented in latest dev branch (v12.5.0.1)

Switch to single pin control using command SetOption152 1

arendst added a commit that referenced this issue Apr 18, 2023
Add command ``SetOption152 0/1`` to select two (default) or one pin bistable relay control (#18386)
@Gifford47
Copy link
Author

Thanks!!!

@arendst
Copy link
Owner

arendst commented Apr 19, 2023

Just had a look at this kind of relay modules and must conclude they are NOT real bi-stable relays. They are "normal" relays connected after a flip-flop; when turned on and power is lost they will come back turned off instead of turned on like a real bi-stable relay.

The only "bi-stable" feature they have is a single input allowing to toggle the relay by a low pulse of the flip-flop.

The current tasmota single-pin implementation stores the last power state and remembers the state after power on. This is probably NOT the state of the fake bi-stable relay after power on.

In short, it's a toy needing a different implemtation then the current one.....

NOTE: In addition they draw power when turned on (60mA) while a real bi-stable relay only draws power during switching.

arendst added a commit that referenced this issue Apr 19, 2023
Fix single pin latching relay power on state (#18386)
@arendst
Copy link
Owner

arendst commented Apr 19, 2023

OK. Fixed in latest dev branch. Single pin latching relay is NOT a two-pin bistable relay.

@arendst arendst closed this as completed Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Type - Enhancement that will be worked on fixed Result - The work on the issue has ended
Projects
None yet
Development

No branches or pull requests

3 participants