relay actuator fails to presenting itself



  • I took Example sketch showing how to control physical relays and modified it a bit to use fixed NodeID in the sensor.
    It is not presenting it self in the gateway. I was trying to use MYSController to debug but the actuator node also was not appearing there.
    If I flush to the same hardware setup I use for actuator the sample code for switch it works like a charm. All radios communicates well.
    Really lost here...

    IDE 1.6.4
    my sensors 1-5
    nano Arduino board

    #include <MySigningNone.h>
    #include <MyTransportNRF24.h>
    #include <MyTransportRFM69.h>
    #include <MyHwATMega328.h>
    #include <MySensor.h>
    #include <SPI.h>
    
    #define RELAY_1 5  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define NUMBER_OF_RELAYS 1 // Total number of attached relays
    #define RELAY_ON 1  // GPIO value to write to turn on attached relay
    #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
    
    // NRFRF24L01 radio driver (set low transmit power by default) 
    MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);  
    //MyTransportRFM69 radio;
    // Message signing driver (none default)
    //MySigningNone signer;
    // Select AtMega328 hardware profile
    MyHwATMega328 hw;
    // Construct MySensors library
    MySensor gw(radio, hw);
    
    void setup()  
    {   
      
      #define NodeID 55
    
      // Initialize library and add callback for incoming messages
      gw.begin(incomingMessage, NodeID, false,5);
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Relay", "1.0");
    
        gw.present(NodeID , S_LIGHT);
        // Then set relay pins in output mode
        pinMode(RELAY_1, OUTPUT);   
        // Set relay to last known state (using eeprom storage) 
        digitalWrite(RELAY_1, gw.loadState(NodeID)?RELAY_ON:RELAY_OFF);
    }
    
    
    void loop() 
    {
      // Alway process incoming messages whenever possible
      gw.process();
    }
    
    void incomingMessage(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_LIGHT) {
         // Change relay state
         digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
         // Store state in eeprom
         gw.saveState(message.sensor, message.getBool());
         // Write some debug info
         Serial.print("Incoming change for sensor:");
         Serial.print(message.sensor);
         Serial.print(", New status: ");
         Serial.println(message.getBool());
       } 
    }
    
    

    actuator monitor log

    send: 55-55-5-0 s=255,c=0,t=17,pt=0,l=3,sg=0,st=fail:1.5
    send: 55-55-5-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=fail:5
    sensor started, id=55, parent=5, distance=1
    send: 55-55-5-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=fail:Relay
    send: 55-55-5-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=fail:1.0
    send: 55-55-5-0 s=55,c=0,t=3,pt=0,l=0,sg=0,st=fail:

    gateway monitor log

    0;0;3;0;9;gateway started, id=0, parent=0, distance=0
    0;0;3;0;14;Gateway startup complete.


  • Admin

    You seem to have had-coded parent to 5. Is that really correct?



  • Yes. I use switch as parent with ID ==5

    like this :

    #include <MySensor.h>
    #include <SPI.h>
    #include <Bounce2.h>
    
    #define CHILD_ID 55
    #define BUTTON_PIN  5  // Arduino Digital I/O pin for button/reed switch
    
    MySensor gw;
    Bounce debouncer = Bounce(); 
    int oldValue=-1;
    
    // Change to V_LIGHT if you use S_LIGHT in presentation below
    MyMessage msg(CHILD_ID,V_LIGHT);
    
    void setup()  
    {  
      #define NodeID 5
    
      // Initialize library and add callback for incoming messages
      gw.begin(NULL, NodeID, false);
    
    
    
    //  gw.begin();
    
     // Setup the button
      pinMode(BUTTON_PIN,INPUT);
      // Activate internal pull-up
      digitalWrite(BUTTON_PIN,HIGH);
      
      // After setting up the button, setup debouncer
      debouncer.attach(BUTTON_PIN);
      debouncer.interval(5);
      
      // Register binary input sensor to gw (they will be created as child devices)
      // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
      // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
      gw.present(CHILD_ID, S_LIGHT);  
    }
    
    

  • Admin

    And what does the repeater (5) log look like?

    As you can see (ack fail) the node is having problem communicating with repeater.

    Also.. are you calling gw.process() in the loop-function on your repeater?



  • re:
    And what does the repeater (5) log look like?

    I do not use repeater. 5 is sample code for switch with hard coded ID == 5

    switch monitor log

    send: 5-5-0-0 s=255,c=0,t=17,pt=0,l=3,sg=0,st=ok:1.5
    send: 5-5-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
    sensor started, id=5, parent=0, distance=1
    send: 5-5-0-0 s=55,c=0,t=3,pt=0,l=0,sg=0,st=ok:
    send: 5-5-0-0 s=55,c=1,t=2,pt=2,l=2,sg=0,st=ok:1
    send: 5-5-0-0 s=55,c=1,t=2,pt=2,l=2,sg=0,st=ok:0
    send: 5-5-0-0 s=55,c=1,t=2,pt=2,l=2,sg=0,st=ok:1

    re:
    As you can see (ack fail) the node is having problem communicating with repeater.

    do I need to switch off somewhere repeater mode? I do not need repeater.
    I use
    gw.begin(incomingMessage, NodeID, false,5); in actuator code
    gw.begin(NULL, NodeID, false); in switch code.

    re:
    Also.. are you calling gw.process() in the loop-function on your repeater?

    I added now...

    //  Check if digital input has changed and send in new value
    void loop() 
    {
    
      debouncer.update();
      // Get the update value
      int value = debouncer.read();
     
      if (value != oldValue) {
         // Send in the new value
         gw.send(msg.set(value==HIGH ? 1 : 0));
         oldValue = value;
      }
     gw.process();
    }
    
    

    After I added gw.process(); log looks good but still no traeces of actuator in serial gateway.

    Actuator log:
    send: 55-55-5-0 s=255,c=0,t=17,pt=0,l=3,sg=0,st=ok:1.5
    send: 55-55-5-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:5
    sensor started, id=55, parent=5, distance=1
    send: 55-55-5-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=ok:Relay
    send: 55-55-5-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
    send: 55-55-5-0 s=55,c=0,t=3,pt=0,l=0,sg=0,st=ok:


  • Admin

    @yury said:

    gw.begin(NULL, NodeID, false); <--

    You must enable repeater mode (3:rd argument) of your repeater, otherwise it won't relay message from your node 55 to your gateway.

    gw(0) <-- Repeater(5) <---- Node (55)



  • added as repeater node 5, but still no traces of the actuator 55 in the gateway.

    send: 5-5-0-0 s=255,c=0,t=18,pt=0,l=3,sg=0,st=ok:1.5
    send: 5-5-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
    repeater started, id=5, parent=0, distance=1
    send: 5-5-0-0 s=55,c=0,t=3,pt=0,l=0,sg=0,st=ok:
    send: 5-5-0-0 s=55,c=1,t=2,pt=2,l=2,sg=0,st=ok:1


  • Admin

    Ok, What does the Node(55) log look like now then?



  • 55 log looks llike this:

    send: 55-55-5-0 s=255,c=0,t=17,pt=0,l=3,sg=0,st=ok:1.5
    send: 55-55-5-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:5
    sensor started, id=55, parent=5, distance=1
    send: 55-55-5-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=ok:Relay
    send: 55-55-5-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
    send: 55-55-5-0 s=55,c=0,t=3,pt=0,l=0,sg=0,st=ok:


  • Admin

    Ok. Are you sure the repeater log above is correct? We can we that node 55 successfully sends its messages to it.



  • Hek, you are the best!

    I plug all three things into my laptop to be able to see all logs and actuator (55) appeared in the serial gateway log

    0;0;3;0;9;gateway started, id=0, parent=0, distance=0
    0;0;3;0;14;Gateway startup complete.
    0;0;3;0;9;read: 5-5-0 s=255,c=0,t=18,pt=0,l=3,sg=0:1.5
    5;255;0;0;18;1.5
    0;0;3;0;9;read: 5-5-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0
    5;255;3;0;6;0
    0;0;3;0;9;read: 55-5-0 s=255,c=0,t=17,pt=0,l=3,sg=0:1.5
    55;255;0;0;17;1.5
    0;0;3;0;9;read: 55-5-0 s=255,c=3,t=6,pt=1,l=1,sg=0:5
    55;255;3;0;6;5
    0;0;3;0;9;read: 5-5-0 s=55,c=0,t=3,pt=0,l=0,sg=0:
    5;55;0;0;3;
    0;0;3;0;9;read: 5-5-0 s=55,c=1,t=2,pt=2,l=2,sg=0:1
    5;55;1;0;2;1
    0;0;3;0;9;read: 55-5-0 s=255,c=3,t=11,pt=0,l=5,sg=0:Relay
    55;255;3;0;11;Relay
    0;0;3;0;9;read: 55-5-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
    55;255;3;0;12;1.0
    0;0;3;0;9;read: 55-5-0 s=55,c=0,t=3,pt=0,l=0,sg=0:
    55;55;0;0;3;

    repeater (5) log also showing it
    send: 5-5-0-0 s=255,c=0,t=18,pt=0,l=3,sg=0,st=ok:1.5
    send: 5-5-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
    repeater started, id=5, parent=0, distance=1
    send: 5-5-0-0 s=55,c=0,t=3,pt=0,l=0,sg=0,st=ok:
    send: 5-5-0-0 s=55,c=1,t=2,pt=2,l=2,sg=0,st=ok:1
    read: 55-55-0 s=255,c=0,t=17,pt=0,l=3,sg=0:1.5
    send: 55-5-0-0 s=255,c=0,t=17,pt=0,l=3,sg=0,st=ok:1.5
    read: 55-55-0 s=255,c=3,t=6,pt=1,l=1,sg=0:5
    send: 55-5-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:5
    read: 55-55-0 s=255,c=3,t=11,pt=0,l=5,sg=0:Relay
    send: 55-5-0-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=ok:Relay
    read: 55-55-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
    send: 55-5-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
    read: 55-55-0 s=55,c=0,t=3,pt=0,l=0,sg=0:
    send: 55-5-0-0 s=55,c=0,t=3,pt=0,l=0,sg=0,st=ok:
    send: 5-5-0-0 s=55,c=1,t=2,pt=2,l=2,sg=0,st=ok:0
    send: 5-5-0-0 s=55,c=1,t=2,pt=2,l=2,sg=0,st=ok:1

    understand something wrong was with external power supply.

    the only thing left, actuator(55) not receiving from repeater(5) which is the switch sensor, messages. These two entries

    send: 5-5-0-0 s=55,c=1,t=2,pt=2,l=2,sg=0,st=ok:0
    send: 5-5-0-0 s=55,c=1,t=2,pt=2,l=2,sg=0,st=ok:1

    not getting to actuator...


  • Admin

    There was a bug fix a couple of days ago fixing problem when routing from repeater to a node. Please make sure that you run the latest library code.


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.