[SOLVED] Long distance radios not working with mySensors code (nrf24l01+)



  • Hi,

    i am playing with mysensors and OpenHAB for a little while now and have around 6 sensors running just fine. I use the standard NRF24L01+ radios but want to have two more sensors with the NRF24L01+ long-range version so i can meassure the temperature in my compost experiment. So i bought these two:
    http://cgi.ebay.de/ws/eBayISAPI.dll?ViewItem&item=231799511604#ht_1500wt_1161

    But the mysensors code is not working with the long-range versions. When i take a already working sensor and change the radio with the long-range version. Nothing happens. Even the serial monitor is empty. Not even an error like "radio init failed"... just empty.

    I tried this test: http://shanes.net/simple-nrf24l01-with-arduino-sketch-and-setup/
    And i can get it running successfully. Means the hardware is working but isn't compatible with the mysensors code. Or am i doing something wrong?

    This is what i tried already:

    • reinstalled Arduino IDE
    • changed the USB ports and cables and tried on different Arduino Nanos

    Here is one of my running sketches which only runs on the short-range radios 😞
    Hope somebody telling me how stupid i am 😉

    #include <MySensor.h>  
    #include <SPI.h>
    
    unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
    #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
    #define CHILD_ID 1   // Id of the sensor child
    #define NODE_ID 11
    
    MySensor gw;
    // Initialize motion message
    MyMessage msg(CHILD_ID, V_TRIPPED);
    
    void setup()  
    {  
      gw.begin(NULL, NODE_ID, true);
    
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Motion Sensor", "1.0");
    
      pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
      // Register all sensors to gw (they will be created as child devices)
      gw.present(CHILD_ID, S_MOTION);
      
    }
    
    void loop()     
    {     
      // Read digital motion value
      boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; 
            
      Serial.println(tripped);
      gw.send(msg.set(tripped?"1":"0"));  // Send tripped value to gw 
     
      // Sleep until interrupt comes in on motion sensor. Send update every two minute. 
      gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME);
    }
    
    

  • Mod

    @edsteve how are you powering the radios? The long range versions need 5-10x more power. This might cause your nodes to fail.

    Also see the power troubleshooting diagram at https://forum.mysensors.org/topic/666/debug-faq-and-how-ask-for-help

    Many people use the long range versions with MySensors so there is no direct incompatibility.

    You can also try adding Serial.println statements after each statement in setup and loop, to see where the code stops running. Add wait(100) after each println so the serial has time to send the data.



  • Hey Vidd,

    Thanks for your perfect answer and the diagram. Useful info for newbie like me 🙂
    I tried external power for the radio and it worked right away. I got mislead from the fact that the radio worked with a simple test code but not with mysensors code.


Log in to reply
 

Suggested Topics

  • 87
  • 1
  • 8
  • 6
  • 5
  • 7

65
Online

11.4k
Users

11.1k
Topics

112.6k
Posts