Basic Setup Network



  • Sorry I know that I am writing a stupid question but I am a little bit confused. I am trying to make a very basic node to node program; from one NRF24 to another NRF24. Send command from 1 module to light LED on the other module. I read more than twice the API (http://www.mysensors.org/download/sensor_api_15) but still get ground! Is there a basic network please to light led on the other side and I will continue from there please?

    Sorry once again, but I really need some help to get on.



  • this is my node to node program:

    // Enable debug prints
    #define MY_DEBUG
    #define SWITCH_PIN 2
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    boolean state=false;
    #include <SPI.h>
    #include <MySensor.h>  
    #define MY_NODE_ID 10
    #define CHILD_ID_SWITCH 1 
    
    MyMessage switchMsg(CHILD_ID_SWITCH, V_LIGHT);
    
    void setup()
    {
      pinMode(SWITCH_PIN,INPUT_PULLUP);
    }
    
    void loop()
    {
      if(digitalRead(SWITCH_PIN)==LOW)
      {
        delay(100);
        if(digitalRead(SWITCH_PIN)==HIGH);
        {
          state=!state;
          if(state)
          {
            send(switchMsg.setDestination(2).set(49));
          }
          else
          {
            send(switchMsg.setDestination(2).set(0));
          }
        }
      }
    }
    
    • destination node id is 2
    • destination of type light variable

Log in to reply
 

Suggested Topics

  • 4
  • 4
  • 8
  • 17
  • 9
  • 2

58
Online

11.4k
Users

11.1k
Topics

112.6k
Posts