Atmega328P + RFM69HW(868) not working



  • I need help after 3wks of trying to find the problem. Couldn't find any similar problems of the forum either.
    I have built a node using Slim Node PCB but instead of NRF24 I have jumper wires to RFM69 connected per pin numbers to Atmega328P.
    My gateway is ESP8266(LolinV3)+RFM69HW (I can ping the ip without problems) so it's probably working (Domoticz "sees" it OK as well).

    This is my node sketch. The "void before" blinks the LED okay, but then it hangs.
    I have checked radio connections. I have the normal 10K res & 3x 0.1yF caps on PCB + 1x 4.7yF electrolytic+1x 0.1yF ceramic closer to the radio.
    I built also another node, but it has similar problems.

    /**
     * DESCRIPTION
     * RFID Lock sensor/actuator
     *
     * Use the I2C wiring option for your RFID module and connect to the following Arduino pins.
     * RFID       Arduino
     * -----      -------
     * GND   ->   GND
     * VCC   ->   +5V
     * SCL   ->   A5
     * SDA   ->   A4
     * Relay for solenoid lock on pin 4
     */
    
    #define MY_DEBUG 
    #define MY_RADIO_RFM69
    #define MY_RFM69_FREQUENCY RFM69_868MHZ // Set your frequency here
    #define MY_IS_RFM69HW
    #define MY_SIGNING_SIMPLE_PASSWD "XXXXXXXXXX"
    #define MY_NODE_ID 51
    #define MY_BAUD_RATE 57600
    
    #include <MySensors.h>  
    #include <Wire.h>
    #include <PN532_I2C.h>
    #include <PN532.h>
    
    
    // Add your valid rfid keys here. To find you your key just run sketch; hold your new RFID tag in fron ot the reader; 
    // and copy the key from serial output of this sketch.
    const uint8_t maxKeyLength = 7;
    uint8_t validKeys[][maxKeyLength] = {
                        { 0xB3, 0xC6, 0xD9, 0x80, 0x00, 0x00, 0x00 },
                        { 0, 0, 0, 0, 0, 0, 0 },    // ADD YOUR KEYS HERE!
                        { 0, 0, 0, 0, 0, 0, 0 }};
    int keyCount = sizeof validKeys / maxKeyLength; 
    
    
    #define LOCK 4   // Id and pin of Lock solenoid
    #define DOOR 5   // Reed switch
    #define LED 7  //Indicator LED
    
    bool lockStatus;
    bool lastStatus = 1;
    MyMessage lockMsg(LOCK, V_LOCK_STATUS);
    MyMessage doorMsg(DOOR, V_TRIPPED);
    
    PN532_I2C pn532i2c(Wire);
    PN532 nfc(pn532i2c);
    
    void before()
    {
      pinMode(LED, OUTPUT);
        int i = 0;
        for(i=0; i < 5; i++) {
        digitalWrite(LED, HIGH);
        delay(100);
        digitalWrite(LED, LOW);
        delay(300);
        }
    }
    void setup() {
    
      pinMode(LOCK, OUTPUT);
      pinMode(DOOR, INPUT); digitalWrite(DOOR, HIGH);
    
      nfc.begin();
      uint32_t versiondata = nfc.getFirmwareVersion();
      if (! versiondata) {
        Serial.print("Couldn't find PN53x board");
        while (1); // halt
      }
      Serial.print("Found NFC chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); 
      Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); 
      Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
      // Set the max number of retry attempts to read from a card
      // This prevents us from waiting forever for a card, which is
      // the default behaviour of the PN532.
      nfc.setPassiveActivationRetries(0x3);
    
      // configure board to read RFID tags
      nfc.SAMConfig();
    
      lockStatus = loadState(LOCK);    // Read last lock status from eeprom
      setLockState(lockStatus, true); // Now set the last known state and send it to controller 
    
    }
    
    void presentation()  {
      sendSketchInfo("RFID Lock & Door sensor", "v11052019");
      present(LOCK, S_LOCK);
      present(DOOR, S_BINARY);
    }
    
    void loop() {
      bool success;
      uint8_t key[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
      uint8_t currentKeyLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
    
    
      // Wait for an ISO14443A type cards (Mifare, etc.).  When one is found
      // 'uid' will be populated with the UID, and uidLength will indicate
      // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
      success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &key[0], &currentKeyLength);
    
      if (success) {
        Serial.print("Found tag id: ");
        for (uint8_t i=0; i < currentKeyLength; i++) 
        {
          if (i>0) Serial.print(",");
          Serial.print("0x");Serial.print(key[i], HEX); 
        }
        for (uint8_t i=currentKeyLength; i < maxKeyLength; i++) 
        {
          Serial.print(",0x00"); 
        }
    
    
        Serial.println("");
    
        bool valid = false;
        // Compare this key to the valid once registered here in sketch 
        for (int i=0;i<keyCount && !valid;i++) {
          for (int j=0;j<currentKeyLength && !valid;j++) {
            if (key[j] != validKeys[i][j]) {
              break;
            }
            if (j==currentKeyLength-1) {
              valid = true;
            }
          }
        }
        if (valid) {
          // Switch lock status
          setLockState(!lockStatus, true);       
        }
    
        // Wait for card/tag to leave reader    
        while(nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &key[0], &currentKeyLength));
      }
    
         wait(10);
    // Door status read and send if changed, require ACK
      bool tripped = digitalRead(DOOR) == HIGH;
    
      if (tripped != lastStatus) {
      Serial.print("Door");
        if (tripped == 1) {
          Serial.println(" open");
          }
          else {
          Serial.println(" closed");
          }
      send(doorMsg.set(tripped?"1":"0"));  // Send tripped value to gw
        digitalWrite(LED, HIGH);
        wait(100);
        digitalWrite(LED, LOW);
      lastStatus = tripped;
      }
      
    } 
    
    
    
    // Unlocks the door.
    void setLockState(bool state, bool doSend){
      if (state) 
         Serial.println("open lock");
      else
         Serial.println("close lock");
      if (doSend)
        send(lockMsg.set(state));
      digitalWrite(LOCK, state);
      saveState(LOCK,state);
      lockStatus = state;
    }
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_LOCK_STATUS) {
         // Change relay state
         setLockState(message.getBool(), false); 
    
         // Write some debug info
         Serial.print("Incoming lock status:");
         Serial.println(message.getBool());
       } 
    }
    

    And this is my debug:

     __  __       ____
    |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
    | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
    | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
    |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
            |___/                      2.3.1
    
    32 MCO:BGN:INIT NODE,CP=RRNNAS--,REL=255,VER=2.3.1
    53 MCO:BGN:BFR
    2086 TSM:INIT
    2088 TSF:WUR:MS=0
    2095 TSM:INIT:TSP OK
    2099 TSM:INIT:STATID=51
    2103 TSF:SID:OK,ID=51
    2107 TSM:FPAR
    

  • Mod

    @masmat nothing happens after TSM:FPAR ?



  • @mfalkvidd Exactly. That's where it just gets stuck. The other node didn't have the void-before so it just gets stuck when I power it up.


  • Mod

    @masmat see if adding #define MY_DEBUG_VERBOSE_RFM69 at top of the sketch can give useful information
    (Link)


  • Mod

    You can also try removing define MY_IS_RFM69HW - sometimes the vendors send non-HW versions with wrong label.



  • @mfalkvidd Verbose_rfm69 did nothing but uncommenting the HW seems to have worked. I'm getting 2m range now, so probably same problem on the GW as well?

    I looked at the modules and compared pictures. They're Chinese but the smd's on the board do match the HW-version.



  • I added the NEW_DRIVER to gw and node and re-added HW-option as well.
    Now within 1m of each other I get this output from node:

    |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
    | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
    | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
    |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
            |___/                      2.3.1
    
    32 MCO:BGN:INIT NODE,CP=RPNNAS--,REL=255,VER=2.3.1
    53 MCO:BGN:BFR
    2082 TSM:INIT
    2086 TSF:WUR:MS=0
    2088 RFM69:INIT
    2093 RFM69:INIT:PIN,CS=10,IQP=2,IQN=0
    2099 RFM69:PTX:LEVEL=5 dBm
    2105 TSM:INIT:TSP OK
    2109 TSM:INIT:STATID=51
    2113 TSF:SID:OK,ID=51
    2117 TSM:FPAR
    2119 RFM69:SWR:SEND,TO=255,SEQ=0,RETRY=0
    2129 RFM69:CSMA:RSSI=-92
    2134 RFM69:CSMA:RSSI=-96
    2138 TSF:MSG:SEND,51-51-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    3012 RFM69:SAC:SEND ACK,TO=0,RSSI=-46
    3020 RFM69:CSMA:RSSI=-100
    3026 TSF:MSG:READ,0-0-51,s=255,c=3,t=15,pt=6,l=2,sg=0:0101
    4153 !TSM:FPAR:NO REPLY
    4157 TSM:FPAR
    4159 RFM69:SWR:SEND,TO=255,SEQ=2,RETRY=0
    4167 RFM69:CSMA:RSSI=-93
    4171 RFM69:CSMA:RSSI=-95
    4179 TSF:MSG:SEND,51-51-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    4710 RFM69:SAC:SEND ACK,TO=0,RSSI=-48
    4718 RFM69:CSMA:RSSI=-94
    4724 RFM69:CSMA:RSSI=-95
    4730 TSF:MSG:READ,0-0-51,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    4741 TSF:MSG:FPAR OK,ID=0,D=1
    6195 TSM:FPAR:OK
    6197 TSM:ID
    6199 TSM:ID:OK
    6203 TSM:UPL
    6205 RFM69:SWR:SEND,TO=0,SEQ=4,RETRY=0
    6213 RFM69:CSMA:RSSI=-92
    6217 RFM69:CSMA:RSSI=-94
    6221 RFM69:CSMA:RSSI=-91
    6227 RFM69:CSMA:RSSI=-92
    6232 RFM69:CSMA:RSSI=-90
    6236 RFM69:CSMA:RSSI=-93
    6240 RFM69:CSMA:RSSI=-98
    6301 RFM69:SWR:ACK,FROM=0,SEQ=5,RSSI=-46
    6309 RFM69:ATC:ADJ TXL,cR=-46,tR=-78..-82,TXL=5
    6318 RFM69:PTX:LEVEL=4 dBm
    6322 TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    7012 RFM69:SAC:SEND ACK,TO=0,RSSI=-55
    7020 RFM69:CSMA:RSSI=-89
    7024 RFM69:CSMA:RSSI=-91
    7028 RFM69:CSMA:RSSI=-88
    7032 RFM69:CSMA:RSSI=-91
    7038 RFM69:CSMA:RSSI=-95
    7045 TSF:MSG:READ,0-0-51,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    7055 TSF:MSG:PONG RECV,HP=1
    7061 TSM:UPL:OK
    7063 TSM:READY:ID=51,PAR=0,DIS=1
    7069 RFM69:SWR:SEND,TO=0,SEQ=6,RETRY=0
    7077 RFM69:CSMA:RSSI=-96
    7139 RFM69:SWR:ACK,FROM=0,SEQ=7,RSSI=-50
    7147 RFM69:ATC:ADJ TXL,cR=-50,tR=-78..-82,TXL=4
    7155 RFM69:PTX:LEVEL=3 dBm
    7159 TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0101
    7839 RFM69:SAC:SEND ACK,TO=0,RSSI=-55
    7845 RFM69:CSMA:RSSI=-92
    7852 RFM69:CSMA:RSSI=-93
    7856 RFM69:CSMA:RSSI=-99
    7862 TSF:MSG:READ,0-0-51,s=255,c=3,t=15,pt=6,l=2,sg=0:0101
    7874 RFM69:SWR:SEND,TO=0,SEQ=8,RETRY=0
    7882 RFM69:CSMA:RSSI=-93
    7886 RFM69:CSMA:RSSI=-93
    7890 RFM69:CSMA:RSSI=-96
    7952 RFM69:SWR:ACK,FROM=0,SEQ=9,RSSI=-50
    7960 RFM69:ATC:ADJ TXL,cR=-50,tR=-78..-82,TXL=3
    7968 RFM69:PTX:LEVEL=2 dBm
    7972 TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=16,pt=0,l=0,sg=0,ft=0,st=OK:
    8806 RFM69:SAC:SEND ACK,TO=0,RSSI=-57
    8814 RFM69:CSMA:RSSI=-92
    8818 RFM69:CSMA:RSSI=-92
    8824 RFM69:CSMA:RSSI=-92
    8828 RFM69:CSMA:RSSI=-94
    8833 RFM69:CSMA:RSSI=-94
    8837 RFM69:CSMA:RSSI=-93
    8843 RFM69:CSMA:RSSI=-90
    8847 RFM69:CSMA:RSSI=-95
    8851 RFM69:CSMA:RSSI=-93
    8855 RFM69:CSMA:RSSI=-90
    8861 RFM69:CSMA:RSSI=-92
    8865 RFM69:CSMA:RSSI=-91
    8869 RFM69:CSMA:RSSI=-92
    8873 RFM69:CSMA:RSSI=-94
    8880 RFM69:CSMA:RSSI=-93
    8884 RFM69:CSMA:RSSI=-91
    8888 RFM69:CSMA:RSSI=-91
    8892 RFM69:CSMA:RSSI=-91
    8898 RFM69:CSMA:RSSI=-93
    8902 RFM69:CSMA:RSSI=-91
    8906 RFM69:CSMA:RSSI=-96
    8914 TSF:MSG:READ,0-0-51,s=255,c=3,t=17,pt=6,l=25,sg=0:<NONCE>
    8972 RFM69:SWR:SEND,TO=0,SEQ=10,RETRY=0
    8980 RFM69:CSMA:RSSI=-93
    8986 RFM69:CSMA:RSSI=-91
    8990 RFM69:CSMA:RSSI=-96
    9056 RFM69:SWR:ACK,FROM=0,SEQ=11,RSSI=-51
    9062 RFM69:ATC:ADJ TXL,cR=-51,tR=-78..-82,TXL=2
    9070 RFM69:PTX:LEVEL=1 dBm
    9076 TSF:MSG:SEND,51-51-0-0,s=255,c=0,t=17,pt=0,l=5,sg=1,ft=0,st=OK:2.3.1
    9091 RFM69:SWR:SEND,TO=0,SEQ=11,RETRY=0
    9099 RFM69:CSMA:RSSI=-96
    9162 RFM69:SWR:ACK,FROM=0,SEQ=12,RSSI=-54
    9171 RFM69:ATC:ADJ TXL,cR=-54,tR=-78..-82,TXL=1
    9179 RFM69:PTX:LEVEL=0 dBm
    9185 TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    10354 RFM69:SAC:SEND ACK,TO=0,RSSI=-56
    10362 RFM69:CSMA:RSSI=-97
    10369 TSF:MSG:READ,0-0-51,s=255,c=3,t=17,pt=6,l=25,sg=1:<NONCE>
    10427 RFM69:SWR:SEND,TO=0,SEQ=13,RETRY=0
    10436 RFM69:CSMA:RSSI=-91
    10440 RFM69:CSMA:RSSI=-93
    10446 RFM69:CSMA:RSSI=-93
    10450 RFM69:CSMA:RSSI=-91
    10456 RFM69:CSMA:RSSI=-93
    10460 RFM69:CSMA:RSSI=-93
    10464 RFM69:CSMA:RSSI=-94
    10470 RFM69:CSMA:RSSI=-96
    10534 RFM69:SWR:ACK,FROM=0,SEQ=14,RSSI=-53
    10542 RFM69:ATC:ADJ TXL,cR=-53,tR=-78..-82,TXL=0
    10550 RFM69:PTX:LEVEL=-1 dBm
    10556 TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=6,pt=1,l=1,sg=1,ft=0,st=OK:0
    12570 RFM69:SWR:SEND,TO=0,SEQ=14,RETRY=0
    12578 RFM69:CSMA:RSSI=-96
    12643 RFM69:SWR:ACK,FROM=0,SEQ=15,RSSI=-58
    12649 RFM69:ATC:ADJ TXL,cR=-58,tR=-78..-82,TXL=-1
    12660 RFM69:PTX:LEVEL=-2 dBm
    12664 TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK:
    13553 RFM69:SAC:SEND ACK,TO=0,RSSI=-56
    13561 RFM69:CSMA:RSSI=-95
    13567 TSF:MSG:READ,0-0-51,s=255,c=3,t=17,pt=6,l=25,sg=1:<NONCE>
    13626 RFM69:SWR:SEND,TO=0,SEQ=16,RETRY=0
    13634 RFM69:CSMA:RSSI=-94
    13638 RFM69:CSMA:RSSI=-93
    13644 RFM69:CSMA:RSSI=-94
    13648 RFM69:CSMA:RSSI=-94
    13655 RFM69:CSMA:RSSI=-93
    13659 RFM69:CSMA:RSSI=-90
    13663 RFM69:CSMA:RSSI=-92
    13669 RFM69:CSMA:RSSI=-91
    13673 RFM69:CSMA:RSSI=-98
    13739 RFM69:SWR:ACK,FROM=0,SEQ=17,RSSI=-58
    13747 TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=11,pt=0,l=23,sg=1,ft=0,st=OK:RFID Lock & Door sensor
    13763 RFM69:SWR:SEND,TO=0,SEQ=17,RETRY=0
    13771 RFM69:CSMA:RSSI=-96
    13984 !RFM69:SWR:NACK
    13988 RFM69:SWR:SEND,TO=0,SEQ=18,RETRY=1
    13997 RFM69:CSMA:RSSI=-91
    14001 RFM69:CSMA:RSSI=-93
    14005 RFM69:CSMA:RSSI=-91
    14011 RFM69:CSMA:RSSI=-92
    14015 RFM69:CSMA:RSSI=-92
    14021 RFM69:CSMA:RSSI=-91
    14025 RFM69:CSMA:RSSI=-91
    14029 RFM69:CSMA:RSSI=-91
    14036 RFM69:CSMA:RSSI=-93
    14040 RFM69:CSMA:RSSI=-93
    14044 RFM69:CSMA:RSSI=-91
    14050 RFM69:CSMA:RSSI=-89
    14054 RFM69:CSMA:RSSI=-93
    14060 RFM69:CSMA:RSSI=-96
    14271 !RFM69:SWR:NACK
    14275 RFM69:SWR:SEND,TO=0,SEQ=18,RETRY=2
    14283 RFM69:CSMA:RSSI=-91
    14287 RFM69:CSMA:RSSI=-91
    14292 RFM69:CSMA:RSSI=-93
    14298 RFM69:CSMA:RSSI=-89
    14302 RFM69:CSMA:RSSI=-90
    14308 RFM69:CSMA:RSSI=-89
    14312 RFM69:CSMA:RSSI=-91
    14316 RFM69:CSMA:RSSI=-91
    14322 RFM69:CSMA:RSSI=-91
    14326 RFM69:CSMA:RSSI=-52
    14330 RFM69:CSMA:RSSI=-51
    14337 RFM69:CSMA:RSSI=-52
    14341 RFM69:CSMA:RSSI=-94
    14347 RFM69:CSMA:RSSI=-91
    14351 RFM69:CSMA:RSSI=-92
    14355 RFM69:CSMA:RSSI=-94
    14361 RFM69:CSMA:RSSI=-91
    14365 RFM69:CSMA:RSSI=-90
    14369 RFM69:CSMA:RSSI=-93
    14376 RFM69:CSMA:RSSI=-93
    14380 RFM69:CSMA:RSSI=-93
    14386 RFM69:CSMA:RSSI=-91
    14390 RFM69:CSMA:RSSI=-94
    14394 RFM69:CSMA:RSSI=-95
    14400 RFM69:CSMA:RSSI=-90
    14404 RFM69:CSMA:RSSI=-91
    14408 RFM69:CSMA:RSSI=-91
    14414 RFM69:CSMA:RSSI=-91
    14419 RFM69:CSMA:RSSI=-91
    14425 RFM69:CSMA:RSSI=-91
    14429 RFM69:CSMA:RSSI=-96
    14634 !RFM69:SWR:NACK
    14638 RFM69:SWR:SEND,TO=0,SEQ=18,RETRY=3
    14646 RFM69:CSMA:RSSI=-91
    14650 RFM69:CSMA:RSSI=-93
    14654 RFM69:CSMA:RSSI=-93
    14660 RFM69:CSMA:RSSI=-93
    14664 RFM69:CSMA:RSSI=-95
    14670 RFM69:CSMA:RSSI=-93
    14675 RFM69:CSMA:RSSI=-91
    14679 RFM69:CSMA:RSSI=-89
    14685 RFM69:CSMA:RSSI=-93
    14689 RFM69:CSMA:RSSI=-93
    14693 RFM69:CSMA:RSSI=-94
    14699 RFM69:CSMA:RSSI=-95
    14703 RFM69:CSMA:RSSI=-90
    14709 RFM69:CSMA:RSSI=-92
    14713 RFM69:CSMA:RSSI=-90
    14718 RFM69:CSMA:RSSI=-91
    14724 RFM69:CSMA:RSSI=-95
    14935 !RFM69:SWR:NACK
    14939 RFM69:SWR:SEND,TO=0,SEQ=18,RETRY=4
    14947 RFM69:CSMA:RSSI=-93
    14951 RFM69:CSMA:RSSI=-96
    15164 !RFM69:SWR:NACK
    15168 RFM69:SWR:SEND,TO=0,SEQ=18,RETRY=5
    15176 RFM69:CSMA:RSSI=-95
    15387 !RFM69:SWR:NACK
    15391 !TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=NACK:
    15404 !TSF:MSG:SIGN FAIL
    15408 RFM69:SWR:SEND,TO=0,SEQ=18,RETRY=0
    15418 RFM69:CSMA:RSSI=-93
    15422 RFM69:CSMA:RSSI=-93
    15426 RFM69:CSMA:RSSI=-97
    15461 !RFM69:SWR:NACK
    15465 RFM69:SWR:SEND,TO=0,SEQ=19,RETRY=1
    15473 RFM69:CSMA:RSSI=-95
    15494 !RFM69:SWR:NACK
    15498 RFM69:SWR:SEND,TO=0,SEQ=19,RETRY=2
    15506 RFM69:CSMA:RSSI=-93
    15512 RFM69:CSMA:RSSI=-97
    15725 !RFM69:SWR:NACK
    15729 RFM69:SWR:SEND,TO=0,SEQ=19,RETRY=3
    15737 RFM69:CSMA:RSSI=-94
    15742 RFM69:CSMA:RSSI=-93
    15746 RFM69:CSMA:RSSI=-96
    15959 !RFM69:SWR:NACK
    15963 RFM69:SWR:SEND,TO=0,SEQ=19,RETRY=4
    15971 RFM69:CSMA:RSSI=-93
    15975 RFM69:CSMA:RSSI=-94
    15979 RFM69:CSMA:RSSI=-93
    15985 RFM69:CSMA:RSSI=-94
    15989 RFM69:CSMA:RSSI=-94
    15995 RFM69:CSMA:RSSI=-91
    16000 RFM69:CSMA:RSSI=-94
    16004 RFM69:CSMA:RSSI=-93
    16010 RFM69:CSMA:RSSI=-94
    16014 RFM69:CSMA:RSSI=-51
    16018 RFM69:CSMA:RSSI=-52
    16024 RFM69:CSMA:RSSI=-94
    16028 RFM69:CSMA:RSSI=-92
    16034 RFM69:CSMA:RSSI=-96
    16239 !RFM69:SWR:NACK
    16243 RFM69:SWR:SEND,TO=0,SEQ=19,RETRY=5
    16251 RFM69:CSMA:RSSI=-94
    16256 RFM69:CSMA:RSSI=-91
    16260 RFM69:CSMA:RSSI=-91
    16266 RFM69:CSMA:RSSI=-92
    16270 RFM69:CSMA:RSSI=-91
    16276 RFM69:CSMA:RSSI=-89
    16280 RFM69:CSMA:RSSI=-90
    16284 RFM69:CSMA:RSSI=-93
    16290 RFM69:CSMA:RSSI=-93
    16294 RFM69:CSMA:RSSI=-91
    16299 RFM69:CSMA:RSSI=-90
    16305 RFM69:CSMA:RSSI=-94
    16309 RFM69:CSMA:RSSI=-92
    16315 RFM69:CSMA:RSSI=-93
    16319 RFM69:CSMA:RSSI=-92
    16323 RFM69:CSMA:RSSI=-94
    16329 RFM69:CSMA:RSSI=-95
    16516 !RFM69:SWR:NACK
    16520 !TSF:MSG:SEND,51-51-0-0,s=4,c=3,t=16,pt=0,l=0,sg=1,ft=2,st=NACK:
    16532 !TSF:MSG:SIGN FAIL
    16536 RFM69:SWR:SEND,TO=0,SEQ=19,RETRY=0
    16546 RFM69:CSMA:RSSI=-91
    16550 RFM69:CSMA:RSSI=-93
    16555 RFM69:CSMA:RSSI=-92
    16561 RFM69:CSMA:RSSI=-91
    16565 RFM69:CSMA:RSSI=-92
    16571 RFM69:CSMA:RSSI=-92
    16575 RFM69:CSMA:RSSI=-92
    16579 RFM69:CSMA:RSSI=-92
    16585 RFM69:CSMA:RSSI=-92
    16589 RFM69:CSMA:RSSI=-93
    16593 RFM69:CSMA:RSSI=-91
    16600 RFM69:CSMA:RSSI=-93
    16604 RFM69:CSMA:RSSI=-93
    16610 RFM69:CSMA:RSSI=-91
    16614 RFM69:CSMA:RSSI=-92
    16618 RFM69:CSMA:RSSI=-93
    16624 RFM69:CSMA:RSSI=-93
    16628 RFM69:CSMA:RSSI=-95
    16632 RFM69:CSMA:RSSI=-90
    16639 RFM69:CSMA:RSSI=-93
    16643 RFM69:CSMA:RSSI=-93
    16649 RFM69:CSMA:RSSI=-92
    

    That implies bad radio-levels, right?


  • Mod

    @masmat -46 rssi is very good signal.
    Csma measures high noise level. Iā€™m on mobile now but Search the forum for MY_RFM69_CSMA_LIMIT_DBM
    https://www.mysensors.org/apidocs/group__RFM69Newgrp.html#gaa39d55e3916acaee71754c676b6fc048



  • @mfalkvidd OK, I did research that a little bit.
    If the signal is good, why all the NACKs?

    This?

    16329 RFM69:CSMA:RSSI=-95
    16516 !RFM69:SWR:NACK
    16520 !TSF:MSG:SEND,51-51-0-0,s=4,c=3,t=16,pt=0,l=0,sg=1,ft=2,st=NACK:
    16532 !TSF:MSG:SIGN FAIL
    16536 RFM69:SWR:SEND,TO=0,SEQ=19,RETRY=0
    16546 RFM69:CSMA:RSSI=-91
    

  • Mod

    @masmat nack happens either because the receiver is unable to hear the message, or because the ack from the receiver is not heard by the sender.



  • @mfalkvidd What could be causing it? The two are in the same room 2m apart.
    I have "overpowered" gw (wall wart) and node (usb+battery) to make sure power wouldnt again be the typical culprit here. Also re-verified all connections.
    Built extra sensor too but thats not working at all (gotta re-check solders etc again and bootloader&sketch upload).


  • Mod

    @masmat first step would be to check the logs from the gateway to see which part fails.

    The most common cause for problems are unstable power, unstable power and unstable power - in that order šŸ˜‰ See the troubleshooting guide at https://forum.mysensors.org/topic/666/debug-faq-and-how-ask-for-help/ if you haven't already.



  • Try my 100% working testing setup:

    Wemos D1 gateway:

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik EKblad
     * Contribution by a-lurker and Anticimex,
     * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
     * Contribution by Ivo Pullens (ESP8266 support)
     *
     * DESCRIPTION
     * The EthernetGateway sends data received from sensors to the WiFi link.
     * The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
     *
     * VERA CONFIGURATION:
     * Enter "ip-number:port" in the ip-field of the Arduino GW device. This will temporarily override any serial configuration for the Vera plugin.
     * E.g. If you want to use the defualt values in this sketch enter: 192.168.178.66:5003
     *
     * LED purposes:
     * - To use the feature, uncomment any of the MY_DEFAULT_xx_LED_PINs in your sketch, only the LEDs that is defined is used.
     * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
     * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
     * - ERR (red) - fast blink on error during transmission error or recieve crc error
     *
     * See http://www.mysensors.org/build/esp8266_gateway for wiring instructions.
     * nRF24L01+  ESP8266
     * VCC        VCC
     * CE         GPIO4
     * CSN/CS     GPIO15
     * SCK        GPIO14
     * MISO       GPIO12
     * MOSI       GPIO13
     * GND        GND
     *
     * Not all ESP8266 modules have all pins available on their external interface.
     * This code has been tested on an ESP-12 module.
     * The ESP8266 requires a certain pin configuration to download code, and another one to run code:
     * - Connect REST (reset) via 10K pullup resistor to VCC, and via switch to GND ('reset switch')
     * - Connect GPIO15 via 10K pulldown resistor to GND
     * - Connect CH_PD via 10K resistor to VCC
     * - Connect GPIO2 via 10K resistor to VCC
     * - Connect GPIO0 via 10K resistor to VCC, and via switch to GND ('bootload switch')
     *
      * Inclusion mode button:
     * - Connect GPIO5 via switch to GND ('inclusion switch')
     *
     * Hardware SHA204 signing is currently not supported!
     *
     * Make sure to fill in your ssid and WiFi password below for ssid & pass.
     */
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
    #define MY_BAUD_RATE 9600
    
    // Enables and select radio type (if attached)
    //#define MY_RADIO_NRF24
    #define MY_RADIO_RFM69
    
    #define MY_IS_RFM69HW // Omit if your RFM is not "H"
    #define MY_RF69_IRQ_PIN D1
    #define MY_RF69_IRQ_NUM MY_RF69_IRQ_PIN
    #define MY_RFM69_CS_PIN D8 // NSS. Use MY_RF69_SPI_CS for older versions (before 2.2.0)
    //#define MY_RADIO_RFM95
    
    #define MY_GATEWAY_ESP8266
    
    #define MY_ESP8266_SSID "SSID"
    #define MY_ESP8266_PASSWORD "password"
    
    // Enable UDP communication
    //#define MY_USE_UDP  // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS below
    
    // Set the hostname for the WiFi Client. This is the hostname
    // it will pass to the DHCP server if not static.
    //#define MY_ESP8266_HOSTNAME "sensor-gateway"
    
    // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
    #define MY_IP_ADDRESS 192,168,1,252
    
    // If using static ip you can define Gateway and Subnet address as well
    #define MY_IP_GATEWAY_ADDRESS 192,168,1,254
    #define MY_IP_SUBNET_ADDRESS 255,255,255,0
    
    // The port to keep open on node server mode
    #define MY_PORT 5003
    
    // How many clients should be able to connect to this gateway (default 1)
    #define MY_GATEWAY_MAX_CLIENTS 2
    
    // 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, 1, 17
    
    // 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
    // Led pins used if blinking feature is enabled above
    //#define MY_DEFAULT_ERR_LED_PIN 16  // Error led pin
    //#define MY_DEFAULT_RX_LED_PIN  16  // Receive led pin
    //#define MY_DEFAULT_TX_LED_PIN  16  // the PCB, on board LED
    
    #if defined(MY_USE_UDP)
    #include <WiFiUdp.h>
    #endif
    
    #include <ESP8266WiFi.h>
    #include <MySensors.h>
    
    void setup()
    {
    	// Setup locally attached sensors
    }
    
    void presentation()
    {
    	// Present locally attached sensors here
    }
    
    void loop()
    {
    	// Send locally attached sensors data here
    }
    

    Node - motion sensor:

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik Ekblad
     *
     * DESCRIPTION
     * Motion Sensor example using HC-SR501
     * http://www.mysensors.org/build/motion
     *
     */
    
    // Enable debug prints
    #define MY_DEBUG
    
    // RFM69
    #define MY_RADIO_RFM69
    #define MY_IS_RFM69HW
    
    //#define MY_RFM69_NEW_DRIVER   // ATC on RFM69 works only with the new driver (not compatible with old=default driver)
    //#define MY_RFM69_ATC_TARGET_RSSI_DBM (-70)  // target RSSI -70dBm
    //#define MY_RFM69_MAX_POWER_LEVEL_DBM (10)   // max. TX power 10dBm = 10mW
    
    // RFM95
    //#define MY_RADIO_RFM95
    //#define MY_RFM95_ATC_TARGET_RSSI_DBM (-70)  // target RSSI -70dBm
    //#define MY_RFM95_MAX_POWER_LEVEL_DBM (10)   // max. TX power 10dBm = 10mW
    
    #define MY_NODE_ID 20
    #include <MySensors.h>
    
    uint32_t 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 1   // Id of the sensor child
    
    // Initialize motion message
    MyMessage msg(CHILD_ID, V_TRIPPED);
    
    void setup()
    {
    	pinMode(DIGITAL_INPUT_SENSOR, INPUT_PULLUP);      // sets the motion sensor digital pin as input
    }
    
    void presentation()
    {
    	// Send the sketch version information to the gateway and Controller
    	sendSketchInfo("Motion Sensor 2", "1.0");
    
    	// Register all sensors to gw (they will be created as child devices)
    	present(CHILD_ID, S_MOTION);
    }
    
    void loop()
    {
    	// 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);
    }
    

    Antena - piece of wire on both sides.

    0_1557693963319_IMG_20190512_224402.jpg

    Receiving distance - min 60m ( gateway at home, sensor in garden )


Log in to reply
 

Suggested Topics

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts