SK
Signal K•3mo ago
sailingYOLO

sailingYOLO - Hi. I have a simple bilge sensor ...

Hi. I have a simple bilge sensor on/off connected to a GPIO, it works fine. BUT I would like to be able to have it HIGH for x seconds before sending to SignalK due to false positives in coppy sea states. Anyone have an idea? Thanks, Mattias.
3 Replies
Unknown User
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
Matti Airas
Matti Airas•2mo ago
A debounce transform does just that. On a shorter time scale, debouncing is used because all push buttons rattle/flicker back and forth when they're just about to make contact. But the same concept works perfectly well in larger time scales as well. https://signalk.org/SensESP/generated/docs/classsensesp_1_1_debounce.html#details
sailingYOLO
sailingYOLOOP•2mo ago
Thank you for your answers, what a community 😃 Debounce was exactly what I was after, perfect! This is the code that works greate for a digital inputreader, and for me:
c++
auto* bilge_input = new DigitalInputState(4, INPUT, 11000,"/bilge/input");

bilge_input->connect_to(new DebounceBool(10000,"/bilge/debounce"))
->connect_to(new LambdaTransform<bool, String>([](bool input) ->String {
if (input == 1) {return "Liquid detected in bilge!";}
else {return "Bilge is clear";}}))
->connect_to(new SKOutputString("propulsion.engine.bilge"));
c++
auto* bilge_input = new DigitalInputState(4, INPUT, 11000,"/bilge/input");

bilge_input->connect_to(new DebounceBool(10000,"/bilge/debounce"))
->connect_to(new LambdaTransform<bool, String>([](bool input) ->String {
if (input == 1) {return "Liquid detected in bilge!";}
else {return "Bilge is clear";}}))
->connect_to(new SKOutputString("propulsion.engine.bilge"));

Did you find this page helpful?