Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. RFM95 RFM95:SWR:NACK

RFM95 RFM95:SWR:NACK

Scheduled Pinned Locked Moved Troubleshooting
3 Posts 2 Posters 393 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    smilvert
    wrote on last edited by
    #1

    Hi

    Im trying to setup a temperature sensor that should be placed at my jetty, 350 meters from my house. So I have chosen RFM95 as my radio, an E-ink display to show the temperature but I have some struggle to this setup. Need some debug help.

    As the controller I have a TTGO LORA.

    I have two of the TTGO LORA, One gateway and one debug sensor, so I can verify that thoose are working with mysensors but when I add my custom sensor I receives a lot of !RFM95:SWR:NACK from the Gateway.

    Sensor code:

    //#define MY_PASSIVE_NODE
    //#define PIN_SERIAL_TX       (8) 
    // Enable debug prints
    #define MY_DEBUG
    #define MY_DEBUG_VERBOSE_RFM95
    
    //#define   MY_DEBUG_VERBOSE_NRF5_ESB
    #define MY_NODE_ID 140
    //#define MY_GATEWAY_SERIAL
    
    
    #define MY_RFM95_RST_PIN 15
    #define MY_RFM95_IRQ_PIN 16
    #define MY_RFM95_IRQ_NUM MY_RFM95_IRQ_PIN
    #define DEFAULT_RFM95_CS_PIN      (SS)
    
    #define MY_RFM95_FREQUENCY (RFM95_434MHZ)
    // #define MY_RFM95_ATC_MODE_DISABLED
    #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 RFM95_RETRY_TIMEOUT_MS 3000ul
    #define MY_TRANSPORT_STATE_TIMEOUT_MS 6*1000ul
    
    // Enable and select radio type attached
    //#define MY_RADIO_NRF24
    //#define MY_RADIO_NRF5_ESB
    //#define MY_RADIO_RFM69
    #define MY_RADIO_RFM95
    
    
    #include <MySensors.h>
    
    #define ENABLE_GxEPD2_GFX 1
    
    #include <GxEPD2_BW.h>
    #include <GxEPD2_3C.h>
    
    #include "Fonts/FreeMonoBold9pt7b.h" 
    #include "Fonts/FreeSerif18pt7b.h" 
    #include "Fonts/FreeSans18pt7b.h" 
    #include "Fonts/FreeSansBold24pt7b.h" 
    
    
    GxEPD2_BW<GxEPD2_154, GxEPD2_154::HEIGHT> display(GxEPD2_154(/*CS=5*/ 22, /*DC=*/ 24, /*RST=*/ -1, /*BUSY=*/ 19));
    
    #include "GxEPD2_boards_added.h"
    #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
    
    
    #define CHILD_ID_TEMP           (0)  
    #define CHILD_ID_HUM            (1)
    
    // ID of the sensor child
    #define CHILD_ID_UPLINK_QUALITY (2)
    #define CHILD_ID_TX_LEVEL       (3)
    #define CHILD_ID_TX_PERCENT     (4)
    #define CHILD_ID_TX_RSSI        (5)
    #define CHILD_ID_RX_RSSI        (6)
    #define CHILD_ID_TX_SNR         (7)
    #define CHILD_ID_RX_SNR         (8)
    
    
    // Initialize general message
    MyMessage msgTxRSSI(CHILD_ID_TX_RSSI, V_DISTANCE);
    MyMessage msgRxRSSI(CHILD_ID_RX_RSSI, V_DISTANCE);
    MyMessage msgTxSNR(CHILD_ID_TX_SNR, V_DISTANCE);
    MyMessage msgRxSNR(CHILD_ID_RX_SNR, V_DISTANCE);
    MyMessage msgTxLevel(CHILD_ID_TX_LEVEL, V_DISTANCE);
    MyMessage msgTxPercent(CHILD_ID_TX_PERCENT, V_DISTANCE);
    MyMessage msgUplinkQuality(CHILD_ID_UPLINK_QUALITY, V_DISTANCE);
    
    #define ledPin LED_BUILTIN
    // Initialize general message
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    
    float batteryVoltage = 0;
    float temperature = 0;
    int humidity = 0;
    int counter = 0;
    int switch_led = 1;
    
    void setup()
    {
      
      Serial.print("Display init");
      sleep(1000);
      hwPinMode(ledPin, OUTPUT_D0H1);
    
      NRF_CLOCK->INTENSET = B11; //enable interrupts for EVENTS_HFCLKSTARTED and  EVENTS_LFCLKSTARTED
      NRF_CLOCK->TASKS_HFCLKSTART = 1; //start the high frequency crystal oscillator clock
      while (!(NRF_CLOCK->EVENTS_HFCLKSTARTED)) {} //wait until high frequency crystal oscillator clock is up to speed and working
    
      pinMode(ledPin, OUTPUT);
      digitalWrite(ledPin, HIGH);
      display.init(115200);
      clearScreen();
    
    }
    
    void presentation()
    {
      // Send the sketch version information to the gateway and controller
      sendSketchInfo("Passive node", "1.1");
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_TEMP, S_TEMP, "Temp");
      present(CHILD_ID_HUM, S_HUM, "Hum");
    
      present(CHILD_ID_UPLINK_QUALITY, S_DISTANCE, "UPLINK QUALITY RSSI");
      present(CHILD_ID_TX_LEVEL, S_DISTANCE, "TX LEVEL DBM");
      present(CHILD_ID_TX_PERCENT, S_DISTANCE, "TX LEVEL PERCENT");
      present(CHILD_ID_TX_RSSI, S_DISTANCE, "TX RSSI");
      present(CHILD_ID_RX_RSSI, S_DISTANCE, "RX RSSI");
      present(CHILD_ID_TX_SNR, S_DISTANCE, "TX SNR");
      present(CHILD_ID_RX_SNR, S_DISTANCE, "RX SNR");
    
    }
    
    void loop()
    {
    
      // generate some random data
      counter ++;
      if (counter == 10 ) {
        temperature = 0;
        humidity = 0;
        counter = 0;
      }
      else
      {
        temperature = 25.0 + random(0, 30) / 10.0;
        humidity = 55.0 + random(-20, 20);
      }
      int16_t uplink = transportGetSignalReport(SR_UPLINK_QUALITY);
      int16_t power_link = transportGetSignalReport(SR_TX_POWER_LEVEL);
      int16_t tx_power_percent = transportGetSignalReport(SR_TX_POWER_PERCENT);
      int16_t tx_rssi = transportGetSignalReport(SR_TX_RSSI);
      int16_t rx_rssi = transportGetSignalReport(SR_RX_RSSI);
      int16_t tx_snr = transportGetSignalReport(SR_TX_SNR);
      int16_t rx_snr = transportGetSignalReport(SR_RX_SNR);
    
      send(msgUplinkQuality.set(uplink));
      send(msgTxLevel.set(power_link));
      send(msgTxPercent.set(tx_power_percent));
      // retrieve RSSI / SNR reports from incoming ACK
      send(msgTxRSSI.set(tx_rssi));
      send(msgRxRSSI.set(rx_rssi));
      send(msgTxSNR.set(tx_snr));
      send(msgRxSNR.set(rx_snr));
      // wait a bit
    
      showDisplay(temperature, humidity, counter, uplink, power_link, tx_power_percent, tx_rssi, rx_rssi);
      send(msgTemp.set(temperature, 2));
      send(msgHum.set(humidity, 2));
      wait(5000);
    
      if (switch_led == 1)
      {
        digitalWrite(ledPin, HIGH);
        switch_led = 0;
      } else {
        digitalWrite(ledPin, LOW);
        switch_led = 1;
      }
    
    }
    
    const char temp[] = "Vattentemp:";
    const char hum[] = "Hum: ";
    const char counter_text[] = "Counter: ";
    const char hello[] = "Hello";
    const char clearText[] = "CLEAR";
    const char UPLINK_QUALITYtext[] = "Uplink_qa: ";
    const char TX_POWER_LEVELtext[] = "Tx power level: ";
    const char TX_RSSItext[] = "Tx rssi: ";
    const char RX_RSSItext[] = "RX rssi";
    const char TX_POWER_PERCENT_text[] = "Tx power:";
    
    
    void clearScreen()
    {
      display.setFullWindow();
      display.setTextColor(GxEPD_BLACK);
      display.fillScreen(GxEPD_WHITE);
      display.setCursor(0, 0);
      display.firstPage();
      do
      {
      }
      while (display.nextPage() );
    }
    
    void showDisplay(float temperature, int humidity, int counter,
                    int UPLINK_QUALITY, int TX_POWER_LEVEL, int TX_POWER_PERCENT,
                    int TX_RSSI, int RX_RSSI)
    {
      display.setRotation(1);
      display.setPartialWindow(0, 0, display.width(), display.height());
      display.setTextColor(GxEPD_BLACK);
      //display.setFullWindow();
      display.setCursor(0, 0);
      display.firstPage();
      // display.fillScreen(GxEPD_WHITE);
      uint16_t x = (display.width() ) ;
      uint16_t y = (display.height() ) ;
      display.setCursor(10, 50);
    
      do
      {
        display.setFont(&FreeSans18pt7b);
        display.println(temp);
        display.setFont(&FreeMonoBold9pt7b);
        display.println();
        display.println();
        display.setFont(&FreeSansBold24pt7b);
        display.print(temperature, 1);
        display.setFont(&FreeMonoBold9pt7b);
        display.println();
    
        display.print(counter_text);
        display.println(counter);
    
    
        display.print(TX_RSSItext);
        display.println(TX_RSSI);
    
        display.print(RX_RSSItext);
        display.println(RX_RSSI);
      }
      while (display.nextPage() );
      Serial.println("showDisplay done");
    }
    
    

    Gateway code:

    /*
     * 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-2019 Sensnology AB
     * Full contributor list: https://github.com/mysensors/MySensors/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 - tekka
     *
     * DESCRIPTION
     * The ESP32 gateway 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.
     *
     * Make sure to fill in your ssid and WiFi password below.
     */
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    #define MY_DEBUG_VERBOSE_RFM95
    #define MY_DEBUG_VERBOSE_TRANSPORT
    #define MY_DEBUG_VERBOSE_GATEWAY
    #define MY_DEBUG_VERBOSE_TRANSPORT_HAL
    
    #define MY_RADIO_RFM95
    
    #define RST     14   // GPIO14 -- SX1278's RESET
    #define DI0     26   // GPIO26 -- SX1278's IRQ(Interrupt Request)
    
    #define MY_RFM95_IRQ_PIN DI0
    #define MY_RFM95_IRQ_NUM MY_RFM95_IRQ_PIN
    #define MY_RFM95_CS_PIN SS
    
    #define MY_RFM95_FREQUENCY (RFM95_434MHZ)
    
    #define MY_GATEWAY_ESP32
    #define MY_GATEWAY_MQTT_CLIENT
    
    // Set this node's subscribe and publish topic prefix
    #define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
    #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
    
    // Set MQTT client id
    #define MY_MQTT_CLIENT_ID "mysensors-1"
    
    // Set WIFI SSID and password
    #define MY_WIFI_SSID "xxxxx"
    #define MY_WIFI_PASSWORD "xxxx"
    
    // Set the hostname for the WiFi Client. This is the hostname
    // passed to the DHCP server if not static.
    #define MY_HOSTNAME "ESP32_MQTT_GW"
    
    // MQTT broker ip address.
    #define MY_CONTROLLER_IP_ADDRESS 10, 0, 0, 3
    
    // The MQTT broker port to to open
    #define MY_PORT 1883
    
    #include <MySensors.h>
    
    void setup()
    {
    	Serial.println("Setup");
    }
    
    void presentation()
    {
    	// Present locally attached sensors here
    }
    
    void loop()
    {
    	// Send locally attech sensors data here
    }
    
    

    Debug log from sensor:

    23 MCO:BGN:INIT NODE,CP=RLNNN---,FQ=16,REL=255,VER=2.3.2
    29 TSM:INIT
    30 TSF:WUR:MS=0
    31 RFM95:INIT
    38 RFM95:INIT:PIN,CS=11,IQP=16,IQN=16,RST=15
    52 RFM95:PTX:LEVEL=13
    54 TSM:INIT:TSP OK
    55 TSM:INIT:STATID=140
    58 TSF:SID:OK,ID=140
    60 TSM:FPAR
    61 RFM95:SWR:SEND,TO=255,SEQ=0,RETRY=0
    7064 ?TSF:MSG:SEND,140-140-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=NACK:
    13071 !TSM:FPAR:NO REPLY
    13073 TSM:FPAR
    13074 RFM95:SWR:SEND,TO=255,SEQ=1,RETRY=0
    20078 ?TSF:MSG:SEND,140-140-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=1,st=NACK:
    26085 !TSM:FPAR:NO REPLY
    26087 TSM:FPAR
    26088 RFM95:SWR:SEND,TO=255,SEQ=2,RETRY=0
    33092 ?TSF:MSG:SEND,140-140-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=2,st=NACK:
    39099 !TSM:FPAR:NO REPLY
    39101 TSM:FPAR
    

    Debug from gateway:

    
    1982032 THA:DATA:AVAIL
    1982084 RFM95:SAC:SEND ACK,TO=10,SEQ=27,RSSI=-17,SNR=9
    1982132 THA:RCV:MSG=0A0A0022810D0500FFFFFF
    1982136 THA:RCV:MSG LEN=11
    1982138 TSF:MSG:READ,10-10-0,s=5,c=1,t=13,pt=4,l=4,sg=0:-256
    1982143 GWT:TPS:TOPIC=mygateway1-out/10/5/1/0/13,MSG SENT
    1982782 THA:DATA:AVAIL
    1982834 RFM95:SAC:SEND ACK,TO=10,SEQ=28,RSSI=-17,SNR=10
    1982882 THA:RCV:MSG=0A0A0022810D0609000000
    1982886 THA:RCV:MSG LEN=11
    1982888 TSF:MSG:READ,10-10-0,s=6,c=1,t=13,pt=4,l=4,sg=0:9
    1982893 GWT:TPS:TOPIC=mygateway1-out/10/6/1/0/13,MSG SENT
    1983582 THA:DATA:AVAIL
    1983634 RFM95:SAC:SEND ACK,TO=10,SEQ=29,RSSI=-18,SNR=9
    1983682 THA:RCV:MSG=0A0A002AE100086666CE4102
    1983686 THA:RCV:MSG LEN=12
    1983688 TSF:MSG:READ,10-10-0,s=8,c=1,t=0,pt=7,l=5,sg=0:25.80
    1983694 GWT:TPS:TOPIC=mygateway1-out/10/8/1/0/0,MSG SENT
    1984382 THA:DATA:AVAIL
    1984434 RFM95:SAC:SEND ACK,TO=10,SEQ=30,RSSI=-18,SNR=9
    1984482 THA:RCV:MSG=0A0A002AE101070000544202
    1984486 THA:RCV:MSG LEN=12
    1984488 TSF:MSG:READ,10-10-0,s=7,c=1,t=1,pt=7,l=5,sg=0:53.00
    1984494 GWT:TPS:TOPIC=mygateway1-out/10/7/1/0/1,MSG SENT
    1988912 THA:DATA:AVAIL
    1988914 THA:RCV:MSG=8C8CFF020307FF
    1988917 THA:RCV:MSG LEN=7
    1988919 TSF:MSG:READ,140-140-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    1988924 TSF:MSG:BC
    1988926 TSF:MSG:FPAR REQ,ID=140
    1988929 TSF:PNG:SEND,TO=0
    1988931 TSF:CKU:OK
    1988933 TSF:MSG:GWL OK
    1989262 THA:SND:MSG=00008C0A2308FF00
    1989265 RFM95:SWR:SEND,TO=140,SEQ=65,RETRY=0
    1989817 !RFM95:SWR:NACK
    1989836 RFM95:SWR:SEND,TO=140,SEQ=66,RETRY=1
    1990388 !RFM95:SWR:NACK
    1990478 RFM95:SWR:SEND,TO=140,SEQ=66,RETRY=2
    1991030 !RFM95:SWR:NACK
    1991062 RFM95:SWR:SEND,TO=140,SEQ=66,RETRY=3
    1991614 !RFM95:SWR:NACK
    1991630 RFM95:SWR:SEND,TO=140,SEQ=66,RETRY=4
    1992182 !RFM95:SWR:NACK
    1992266 THA:SND:MSG LEN=8,RES=0
    1992268 !TSF:MSG:SEND,0-0-140-140,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0
    

    And here I can see that the gateway recieves data from sensor 140 but can't ack :(

    Can someone please help me?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lood29
      wrote on last edited by
      #2

      99% of the nacks are radio/power issues
      You may recheck them carefully

      1 Reply Last reply
      0
      • S Offline
        S Offline
        smilvert
        wrote on last edited by
        #3

        @lood29 When I use TTGO LORA as a dummy sensor (Node 10 in the above log) it always works without any nacks.

        The NACK only appears when I connect my own sensor (Node 140 in the log above).

        So Scenario 1
        Dummy sensor (TTGO LORA) <-> MQTT gateway (TTGO LORA) -> Works

        Scenario 2
        My sensor <-> MQTT gateway (TTGO LORA) -> NACK in the Gateway.

        1 Reply Last reply
        0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        18

        Online

        12.0k

        Users

        11.2k

        Topics

        113.4k

        Posts


        Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • MySensors
        • OpenHardware.io
        • Categories
        • Recent
        • Tags
        • Popular