cant get setSafeguard to work with NodeManager 1.8dev



  • Hi

    First of all, since this is my first post. Thank you all who have made this possible and so easy for us to use, especially NodeManager.

    I'm currently working on a garage sensor. Everything is working except this safeguard.
    I'm using a relay to open my garage door, but I only need a puls so I want to de-energize the relay as soon as possible. I tried to use;

    // [108] when switching on, turns the output off after the given number of milliseconds. For latching relay controls the pulse width (default: 0)
        void setPulseWidth(int value);
    

    It worked, but with power loss it would send one puls at startup, I tried using EEPROM, but still the same problem.

    So I thought it would be possible to use it as a normal relay and then use setSafeguard to be sure to cut the signal to the relay within a short time. Nothing happens when I try to use setSafeguard.

    Here is my code. If anyone can see where my mistake is, or have another solution how to make a momentary relay with nodeManager. I would be very happy 🙂

    /*
    * The MySensors Arduino library handles the wireless radio link and protocol
    * between your home built sensors/actuators and HA controller of choice.
    * The sensors forms a self healing radio network with optional repeaters. Each
    * repeater and gateway builds a routing tables in EEPROM which keeps track of the
    * network topology allowing messages to be routed to nodes.
    *
    * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
    * Copyright (C) 2013-2017 Sensnology AB
    * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
    *
    * Documentation: http://www.mysensors.org
    * Support Forum: http://forum.mysensors.org
    *
    * This program is free software; you can redistribute it and/or
    * modify it under the terms of the GNU General Public License
    * version 2 as published by the Free Software Foundation.
    */
    
    /**********************************
     * MySensors node configuration
     */
    
    // General settings
    #define SKETCH_NAME "Relay"
    #define SKETCH_VERSION "1.0"
    #define MY_DEBUG
    #define MY_NODE_ID 3
    
    // RFM69 radio settings
    #define MY_RADIO_RFM69
    #define MY_RFM69_FREQUENCY RFM69_433MHZ  // Define for frequency setting. Needed if you're radio module isn't 868Mhz (868Mhz is default in lib)
    #define MY_IS_RFM69HW  // Mandatory if you radio module is the high power version (RFM69HW and RFM69HCW), Comment it if it's not the case
    #define MY_RFM69_NETWORKID 100  // Default is 100 in lib. Uncomment it and set your preferred network id if needed
    #define MY_RFM69_NEW_DRIVER
    
    // Advanced settings
    #define MY_BAUD_RATE 9600
    #define MY_SPLASH_SCREEN_DISABLED
    
    /***********************************
     * NodeManager configuration
     */
    
    #define NODEMANAGER_DEBUG ON
    #define NODEMANAGER_INTERRUPTS ON
    #define NODEMANAGER_SLEEP OFF
    #define NODEMANAGER_RECEIVE ON
    #define NODEMANAGER_DEBUG_VERBOSE ON
    #define NODEMANAGER_POWER_MANAGER OFF
    #define NODEMANAGER_CONDITIONAL_REPORT ON
    #define NODEMANAGER_EEPROM OFF
    #define NODEMANAGER_TIME ON
    #define NODEMANAGER_RTC OFF
    #define NODEMANAGER_SD OFF
    #define NODEMANAGER_HOOKING OFF
    #define NODEMANAGER_OTA_CONFIGURATION OFF
    #define NODEMANAGER_SERIAL_INPUT OFF
    
    // import NodeManager library (a nodeManager object will be then made available)
    #include <MySensors_NodeManager.h>
    
    /***********************************
     * Add your sensors
     */
    
    //#include <sensors/SensorConfiguration.h>
    //SensorConfiguration configuration;
    
    #include <sensors/SensorSignal.h>
    SensorSignal signal;
    
    #include <sensors/SensorLDR.h>
    SensorLDR ldr(A0);
    
    #include <sensors/SensorRelay.h>
    SensorRelay relay(6);
    
    #include <sensors/SensorDHT22.h>
    SensorDHT22 dht22(4);
    
    #include <sensors/SensorDoor.h>
    SensorDoor door(3);
    
    /***********************************
     * Main Sketch
     */
    
    // before
    void before() {
    
    
      /***********************************
       * Configure your sensors
       */
    
      // report measures of every attached sensors every 10 minutes
      nodeManager.setReportIntervalMinutes(10);
      // [105] automatically turn the output off after the given number of minutes
      relay.setSafeguard(1);
      // call NodeManager before routine
      nodeManager.before();
    }
    
    // presentation
    void presentation() {
      // call NodeManager presentation routine
      nodeManager.presentation();
    }
    
    // setup
    void setup() {
      // call NodeManager setup routine
      nodeManager.setup();
    }
    
    // loop
    void loop() {
      // call NodeManager loop routine
      nodeManager.loop();
    }
    
    #if NODEMANAGER_RECEIVE == ON
    // receive
    void receive(const MyMessage &message) {
      // call NodeManager receive routine
      nodeManager.receive(message);
    }
    #endif
    
    #if NODEMANAGER_TIME == ON
    // receiveTime
    void receiveTime(unsigned long ts) {
      // call NodeManager receiveTime routine
      nodeManager.receiveTime(ts);
    }
    #endif
    


  • It Looks like I can somewhat answer my own question.
    I got Safeguard to work, even if I have set it to 1minute, it doesn't update before next

      // report measures of every attached sensors every 10 minutes
      nodeManager.setReportIntervalMinutes(10);
    

    So it takes 10minutes, even if I have sent it to 1min. Is it supposed to be like this or is it a bug?


  • Contest Winner

    Sorry for the delay first of all, unfortunately I didn't get the notification of this thread 😕 If you are using a latching relay I'd recommend using SensorLatchingRelay1Pin or SensorLatchingRelay2Pins which should take better all the aspects of a latching relay. Then you can still use the safeguard for closing the door after a given timeframe. And yes you have to set a reporting interval even if not intuitive at all. This is because the safeguard is checked in the loop cycle which is called only if a reporting interval is set. So if you have a safeguard set to 1 minute, the report interval should be 1 minute or less. Thanks!



Suggested Topics

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts