[RESOLVED] Problems connecting node to gateway



  • Greetings,

    After much searching in the forums and google I've been unable to resolve the issue on my own. Any assistance is welcomed.

    My gateway is a Ardunio Uno with an Ethernet Shield and a RFM69HCW radio set to 915Mhz
    My node is an Arudino Nano and a RFM69HCW radio set to 915Mhz (currently no sensors connected for troubleshooting)

    I am using an Adafruit breakout board that has a level shifter build in.

    Below are the outputs of the node and gw:

    GW Debug:

    0;255;3;0;9;MCO:BGN:INIT GW,CP=RRNGA--,VER=2.1.1
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;TSF:WUR:MS=0
    0;255;3;0;9;TSM:INIT:TSP OK
    0;255;3;0;9;TSM:INIT:GW MODE
    0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
    0;255;3;0;9;MCO:REG:NOT NEEDED
    IP: 192.168.1.204
    0;255;3;0;9;MCO:BGN:STP
    0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
    0;255;3;0;9;Eth: connect
    0;255;3;0;9;Eth: 0;255;3;0;2;
    0;255;3;0;9;Eth: 255;255;3;0;20;
    0;255;3;0;9;TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
    0;255;3;0;9;Eth: 0;255;3;0;2;
    0;255;3;0;9;Eth: 0;255;3;0;2;
    

    Node Debug:

    0 MCO:BGN:INIT NODE,CP=RRNNA--,VER=2.1.1
    3 TSM:INIT
    4 TSF:WUR:MS=0
    6 TSM:INIT:TSP OK
    8 TSM:INIT:STATID=1
    10 TSF:SID:OK,ID=1
    11 TSM:FPAR
    142 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    2149 !TSM:FPAR:NO REPLY
    2151 TSM:FPAR
    2281 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    4288 !TSM:FPAR:NO REPLY
    4290 TSM:FPAR
    4420 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    6427 !TSM:FPAR:NO REPLY
    6429 TSM:FPAR
    6559 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    8566 !TSM:FPAR:FAIL
    8567 TSM:FAIL:CNT=1
    8569 TSM:FAIL:PDT
    

    GW Sketch:

    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_RFM69
    
    #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_FREQUENCY RF69_915MHZ  // Define for frequency setting. Needed if you're radio module isn't 868Mhz (868Mhz is default in lib)
    #define MY_RF69_SPI_CS 4
    #define MY_RF69_IRQ_PIN 2
    
    // How many clients should be able to connect to this gateway (default 1)
    #define MY_GATEWAY_MAX_CLIENTS 2
    
    // Enable gateway ethernet module type
    #define MY_GATEWAY_W5100
    
    // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
    #define MY_W5100_SPI_EN 4
    
    // Enable to UDP
    //#define MY_USE_UDP
    
    #define MY_IP_ADDRESS 192,168,1,204   // If this is disabled, DHCP is used to retrieve address
    // Renewal period if using DHCP
    //#define MY_IP_RENEWAL_INTERVAL 60000
    // The port to keep open on node server mode / or port to contact in client mode
    #define MY_PORT 5003
    
    // Controller ip address. Enables client mode (default is "server" mode).
    // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere.
    //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254
    
    // The MAC address can be anything you want but should be unique on your network.
    // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
    // Note that most of the Ardunio examples use  "DEAD BEEF FEED" for the MAC address.
    #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
    
    // Enable inclusion mode
    #define MY_INCLUSION_MODE_FEATURE
    // Enable Inclusion mode button on gateway
    //#define MY_INCLUSION_BUTTON_FEATURE
    // Set inclusion mode duration (in seconds)
    #define MY_INCLUSION_MODE_DURATION 60
    // Digital pin used for inclusion mode button
    //#define MY_INCLUSION_MODE_BUTTON_PIN  3
    
    // Set blinking period
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // Flash leds on rx/tx/err
    // Uncomment to override default HW configurations
    #define MY_DEFAULT_ERR_LED_PIN 5  // Error led pin
    #define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
    #define MY_DEFAULT_TX_LED_PIN  7  // Transmit led pin
    
    #if defined(MY_USE_UDP)
    #include <EthernetUdp.h>
    #endif
    #include <Ethernet.h>
    #include <MySensors.h>
    
    
    void setup()
    {
    }
    
    void loop()
    {
    }
    

    Node sketch:

    // Enable debug prints
    #define MY_DEBUG
    #define MY_SPECIAL_DEBUG
    #define MY_NODE_ID 1
    
    // Enable and select radio type attached 
    #define MY_RADIO_RFM69
    #define MY_IS_RFM69HW
    #define MY_RFM69_FREQUENCY RF69_915MHZ
    #define MY_RF69_SPI_CS 10
    #define MY_RF69_IRQ_PIN 3
    #define MY_RF69_IRQ_NUM 1
    #define MY_DEFAULT_TX_LED_PIN 13
    
    
    #include <SPI.h>
    #include <MySensors.h>  
    #include <DHT.h>
    
    // Set this to the pin you connected the DHT's data pin to
    #define DHTPIN 4
    #define DHTTYPE DHT22
    
    // Set this offset if the sensor has a permanent small offset to the real temperatures
    #define SENSOR_TEMP_OFFSET 0
    
    // Sleep time between sensor updates (in milliseconds)
    // Must be >1000ms for DHT22 and >2000ms for DHT11
    // static const uint64_t UPDATE_INTERVAL = 60000;
    
    // Force sending an update of the temperature after n sensor reads, so a controller showing the
    // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
    // the value didn't change since;
    // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
    static const uint8_t FORCE_UPDATE_N_READS = 10;
    
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    
    // Motion Detection
    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 CHILD_ID_PIR 2   // Id of the sensor child
    
    // Initialize motion message
    MyMessage msg(CHILD_ID_PIR, V_TRIPPED);
    
    // DHT22 Stuff
    float lastTemp;
    float lastHum;
    uint8_t nNoUpdatesTemp;
    uint8_t nNoUpdatesHum;
    bool metric = false;
    
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    DHT dht(DHTPIN, DHTTYPE);
    
    // LUX Sensor
    #define LIGHT_SENSOR_ANALOG_PIN 3
    #define CHILD_ID_LIGHT 3
    int lastLightLevel;
    
    
    void presentation()  
    { 
      // Send the sketch version information to the gateway
      sendSketchInfo("MultiSensor", "0.1");
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_HUM, S_HUM);
      present(CHILD_ID_TEMP, S_TEMP);
      present(CHILD_ID_PIR, S_MOTION);
      present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
    
      //metric = getControllerConfig().isMetric;
    }
    
    
    void setup()
    {
      Serial.println("Setting up...");
    //  dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
      if (SLEEP_TIME <= 2000) {
        Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
      }
      // Sleep for the time of the minimum sampling period to give the sensor time to power up
      // (otherwise, timeout errors might occure for the first reading)
      sleep(2000);
    }
    
    
    void loop()      
    {  
    
      // LUX Stuff
      int16_t lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23;
      Serial.println(lightLevel);
      if (lightLevel != lastLightLevel) {
          send(msg.set(lightLevel));
          lastLightLevel = lightLevel;
      }
    
      
      // Force reading sensor, so it works also after sleep()
      //dht.readSensor(true);
    
      // Get temperature from DHT library
      float temperature = dht.readTemperature();
      if (isnan(temperature)) {
        Serial.println("Failed reading temperature from DHT!");
      } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
        // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
        lastTemp = temperature;
        if (!metric) {
          temperature = dht.readTemperature(true);
        }
        // Reset no updates counter
        nNoUpdatesTemp = 0;
        temperature += SENSOR_TEMP_OFFSET;
        send(msgTemp.set(temperature, 1));
    
        #ifdef MY_DEBUG
        Serial.print("T: ");
        Serial.println(temperature);
        #endif
      } else {
        // Increase no update counter if the temperature stayed the same
        nNoUpdatesTemp++;
      }
    
      // Get humidity from DHT library
      float humidity = dht.readHumidity();
      if (isnan(humidity)) {
        Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
        // Only send humidity if it changed since the last measurement or if we didn't send an update for n times
        lastHum = humidity;
        // Reset no updates counter
        nNoUpdatesHum = 0;
        send(msgHum.set(humidity, 1));
    
        #ifdef MY_DEBUG
        Serial.print("H: ");
        Serial.println(humidity);
        #endif
      } else {
        // Increase no update counter if the humidity stayed the same
        nNoUpdatesHum++;
      }
      
      // Read digital motion value
      bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
    
      Serial.println(tripped);
      send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
    
      // Sleep until interrupt comes in on motion sensor. Send update every two minute.
      sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
    
    }
    

    I have them both currently powered via my computer's USB. I tested with a simple sketch and I was able to get them to communicate "Hello world!" packets.

    Anyone have any thoughts?

    Thank you.


  • Hardware Contributor



  • The radios seem to initialize fine according to the logs. Any other ideas?


  • Hardware Contributor

    @firstof9 - a resource i found good, if you didnt know: https://learn.sparkfun.com/tutorials/rfm69hcw-hookup-guide



  • The radios are connected correctly, the issue appears to be related to this:

    2149 !TSM:FPAR:NO REPLY
    

  • Mod

    See if adding

    #define MY_DEBUG_VERBOSE_RFM69
    

    before including MySensors.h gives any useful clues.



  • // Enable debug prints to serial monitor
    #define MY_DEBUG_VERBOSE_RFM69
    #define MY_DEBUG
    

    Nothing new is being reported on the serial monitor. 😞

    0;255;3;0;9;MCO:BGN:INIT GW,CP=RRNGA--,VER=2.1.1
    0;255;3;0;9;TSM:INIT
    0;255;3;0;9;TSF:WUR:MS=0
    0;255;3;0;9;TSM:INIT:TSP OK
    0;255;3;0;9;TSM:INIT:GW MODE
    0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
    0;255;3;0;9;MCO:REG:NOT NEEDED
    IP: 192.168.1.204
    0;255;3;0;9;MCO:BGN:STP
    0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
    0;255;3;0;9;Eth: connect
    0;255;3;0;9;Eth: 0;255;3;0;2;
    0;255;3;0;9;Eth: 255;255;3;0;20;
    0;255;3;0;9;TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
    0;255;3;0;9;Eth: 0;255;3;0;2;
    0;255;3;0;9;Eth: 0;255;3;0;2;
    0;255;3;0;9;Eth: 0;255;3;0;2;
    0;255;3;0;9;Eth: 0;255;3;0;2;
    0;255;3;0;9;Eth: 0;255;3;0;2;
    0;255;3;0;9;Eth: 0;255;3;0;2;
    0;255;3;0;9;Eth: 0;255;3;0;2;
    


  • Got it working it was this bit causing issues:

    // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
    #define MY_W5100_SPI_EN 4
    

    removing that fixed it

    Also as my gateway was having issues freaking out when receving radio packets I also modified my ethernet.h per this post:
    https://forum.mysensors.org/topic/5109/solved-rfm69-based-nodes-unable-to-report-lib-version/26

    and changed the following:

    #define MY_DEFAULT_ERR_LED_PIN A0  // Error led pin
    #define MY_DEFAULT_RX_LED_PIN  A1  // Receive led pin
    #define MY_DEFAULT_TX_LED_PIN  A2  // Transmit led pin
    

    Thank you all for your suggestions.


  • Mod

    @firstof9 great work! Thanks for reporting back on your solution.


Log in to reply
 

Suggested Topics

  • 3
  • 1
  • 5
  • 8
  • 2
  • 6

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts