Signal KSK
Signal K13mo ago
1 reply
sailingYOLO

sailingYOLO - Hi guys.This code works well ex...

Hi guys.

This code works well except it doesn't send value every 11 seconds. If the value has changed or not it should send it, right? What do I need to do different?
The only time a value is sent is when the value change on pin 4 OR the ESP restarts.

If I have a value in the SK-server and then restart the SK-server the SK-path goes away and does not appear until I restart the ESP or change the value on pin 4 (trigger/untrigger the sensor).

How can I make it repeat every 11 seconds, as I thought I was doing?

// Bilge Monitor //

  const uint8_t kDigitalInputBilgePin = 4;
  const unsigned int kDigitalInputBilgeInterval = 11000;

  // Configure the pin. Replace this with your custom library initialization
  // code!
  pinMode(kDigitalInputBilgePin, INPUT_PULLUP);

  SKMetadata* Bilgemetadata = new SKMetadata();
  Bilgemetadata->description_ = "Bilge Sensor";
  Bilgemetadata->display_name_ = "Bilge Sensor";
  Bilgemetadata->short_name_ = "Bil Sen";

  auto* bilge_input = new RepeatSensor<bool>(
      kDigitalInputBilgeInterval,
      [kDigitalInputBilgePin]() { return digitalRead(kDigitalInputBilgePin); });

  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("environment.bilge.liquid",Bilgemetadata));
Was this page helpful?