Super simple node to node, why doesn't it work?



  • Hi Guys,

    I'm trying to make a relay switch on and off with this simple code:

    /*
      REVISION HISTORY
      Created by Mark Swift
      V1.0 - Initial release.
    */
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    #define MY_NODE_ID 5
    // #define MY_PARENT_NODE_ID 0 // AUTO
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    // Set RF24L01+ channel number
    // #define MY_RF24_CHANNEL 125
    
    // For crappy PA+LNA module
    // #define MY_RF24_PA_LEVEL RF24_PA_LOW
    
    // Enable repeater functionality for this node
    // #define MY_REPEATER_FEATURE
    
    // Include additional libraries
    #include <SPI.h>
    #include <MySensor.h>
    
    void setup()
    {
    }
    
    void loop()
    {
      send(MyMessage(1,V_LIGHT).setDestination(4).set(0));
      delay(2000);
      send(MyMessage(1,V_LIGHT).setDestination(4).set(1));
      delay(2000);
    }
    

    It seems to switch the relay off, but not on, what am I doing wrong?

    Mark



  • Okay, I fixed it by changing the 0 / 1 to true / false, didn't realise the relay looked for a boolean!

    On another note, as this node has no sensors, does it matter what is specified in the send message as the CHILD_ID? Seems irrelevant, or am I missing something?

    Edit, Figured it out, the relay example doesn't check what sensor the inbound message is for, but I presume it's better to use the right ID!


  • Admin

    @Mark-Swift said:

    Edit, Figured it out, the relay example doesn't check what sensor the inbound message is for, but I presume it's better to use the right ID!

    Yes.



  • @hek A man of many words, huh? 🙂


  • Admin

    No

    😉


 

444
Online

7.9k
Users

8.8k
Topics

93.8k
Posts