Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Feature Requests
  3. Heartbeat

Heartbeat

Scheduled Pinned Locked Moved Feature Requests
3 Posts 2 Posters 3.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    filoucaenais
    Plugin Developer
    wrote on last edited by filoucaenais
    #1

    hello
    Has it there in the library means to control whether a node is active?
    type heartbeat
    thanks

    BulldogLowellB 1 Reply Last reply
    0
    • F filoucaenais

      hello
      Has it there in the library means to control whether a node is active?
      type heartbeat
      thanks

      BulldogLowellB Offline
      BulldogLowellB Offline
      BulldogLowell
      Contest Winner
      wrote on last edited by
      #2

      @filoucaenais

      I do it by sending the status with a regular interval... so that you can see from the Last Update time in the device panel (Vera).

      like this example:

      /*
      * Motion Sensor Version 1.1
      *
      * November 7, 2014
      * -Added pushing text status to V_VAR1
      *
      * Version 1 - October 4, 2014
      * -Modified to transmit on state change
      * -removed Sleep for mains-only device
      * -Updates gateway according to UPDATE_INTERVAL
      *
      */
      #include <MySensor.h>
      #include <SPI.h>
      //
      #define DEBUG
      //
      #define DIGITAL_INPUT_SENSOR 3
      #define RADIO_ID 2
      #define CHILD_ID 1
      #define UPDATE_INTERVAL 60000UL  // 1 minute
      //
      boolean lastSensorState;
      
      //
      MySensor gw;
      //
      MyMessage stateMsg(CHILD_ID, V_TRIPPED);
      MyMessage updateMsg(CHILD_ID, V_VAR1);
      //
      void setup()
      {
        gw.begin(NULL, RADIO_ID, false);
        #ifdef DEBUG
          Serial.begin(115200);
        #endif
        gw.sendSketchInfo("MotionSensor", "V1.1");
        pinMode(DIGITAL_INPUT_SENSOR, INPUT);
        gw.present(CHILD_ID, S_MOTION);
      }
      //
      void loop()
      {
        boolean sensorState = digitalRead(DIGITAL_INPUT_SENSOR);
        if (sensorState != lastSensorState)
        {
          #ifdef DEBUG
            digitalWrite(13, sensorState ? HIGH : LOW);
            Serial.println(sensorState ? "Tripped" : "Not Tripped");
          #endif
          gw.send(stateMsg.set(sensorState ? "1" : "0"));
        }
        lastSensorState = sensorState;
        updateStatus(UPDATE_INTERVAL);
      }
      //
      void updateStatus(unsigned long updateInterval)
      {
        static unsigned long lastUpdate;
        if (millis() - lastUpdate >= updateInterval)
        {
          gw.send(updateMsg.set(lastSensorState ? "Motion Detected" : "No Motion"));
          #ifdef DEBUG
            digitalWrite(13, lastSensorState ? HIGH : LOW);
            Serial.println(lastSensorState ? F("Tripped") : F("Not Tripped"));
          #endif
          lastUpdate += updateInterval;
        }
      }
      
      1 Reply Last reply
      0
      • F Offline
        F Offline
        filoucaenais
        Plugin Developer
        wrote on last edited by
        #3

        thank you for your answer

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        19

        Online

        11.7k

        Users

        11.2k

        Topics

        113.1k

        Posts


        Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • MySensors
        • OpenHardware.io
        • Categories
        • Recent
        • Tags
        • Popular