No data reception, only join

Hello, I am very doubtful right now, I am sending data with LoRaWAN, Heltec ESP v3, via TTN Gateway, but it only comes that it join. I want to send data from DHT11 and from a load cell. below is my code and below is the payload decorder. Can someone please help? Thank you
I have also read through the topics and the only thing I have found is that the gateway is far away from me, but this is not the case with me (I think, but I have entered the nearest gateway in my city). if I am wrong pls send a link from the topic and sorry for opening a new one :slight_smile:

that’s the only thing i get:

Code:

#include "LoRaWan_APP.h"

uint8_t appEui[] = { something };
uint8_t devEui[] = { something };
uint8_t appKey[] = { something };

uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda, 0x85 };
uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef, 0x67 };
uint32_t devAddr = (uint32_t)0x007e6ae1;

uint16_t userChannelsMask[6] = { 0x00FF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 };

LoRaMacRegion_t loraWanRegion = ACTIVE_REGION;
DeviceClass_t loraWanClass = CLASS_A;

uint32_t appTxDutyCycle = 240000;
bool overTheAirActivation = true;
bool loraWanAdr = true;
bool isTxConfirmed = true;
uint8_t appPort = 2;
uint8_t confirmedNbTrials = 4;

#include "HX711.h"
HX711 scale;

uint8_t dataPin = 26;
uint8_t clockPin = 48;
int int_nestweight = 0;

#define VBAT_PIN 1
#define VBAT_READ_CNTRL_PIN 37
#define ADC_READ_STABILIZE 10

int int_readBatLevel = 0;
float readBatLevel() {
  int analogValue = analogRead(VBAT_PIN);
  float voltage = 0.004376 * analogValue;
  return voltage;
}

#include <DHT.h>

#define DHTPIN 2
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);
int int_readhumidity = 0;
int int_readtemperature = 0;

static void prepareTxFrame(uint8_t port) {
  Serial.begin(115200);
  Serial.println("wakeup scale");
  scale.begin(dataPin, clockPin);
  scale.set_scale(1000.795471);
  scale.set_offset(4294624289);
  delay(5000);

  if (scale.is_ready()) {
    Serial.println("scale is ready");
    Serial.println(scale.get_units(1));
    int_nestweight = (scale.get_units(1) * 10);
    int_nestweight = 890;

    if (int_nestweight > 9000) {
      int_nestweight = 9999;
    }
  } else {
    int_nestweight = 8888;
    Serial.println("scale not ready");
  }

  Serial.println(int_nestweight);

  float v = readBatLevel();
  int_readBatLevel = abs(v * 100);
  Serial.print("Batterielevel ");
  Serial.println(int_readBatLevel);

  float humidity = dht.readHumidity();
  int_readhumidity = abs(humidity * 100);
  float temperature = dht.readTemperature();
  int_readtemperature = abs(temperature * 100);

  if (isnan(humidity) || isnan(temperature)) {
    Serial.println("Error reading DHT sensor!");
    return;
  }

  Serial.print("Humidity: ");
  Serial.println(humidity);
  Serial.print("Temperature: ");
  Serial.println(temperature);

  appDataSize = 16;
  appData[0] = int_nestweight >> 8;
  appData[1] = int_nestweight & 0xFF;
  appData[2] = int_readBatLevel >> 8;
  appData[3] = int_readBatLevel & 0xFF;
  appData[4] = int_readhumidity >> 8;
  appData[5] = int_readhumidity & 0xFF;
  appData[6] = int_readtemperature >> 8;
  appData[7] = int_readtemperature & 0xFF;
}

void setup() {
  Serial.begin(115200);
  Mcu.begin();
  deviceState = DEVICE_STATE_INIT;
  scale.begin(dataPin, clockPin);
  scale.set_scale(1000.795471);
  scale.set_offset(4294624289);
  pinMode(VBAT_READ_CNTRL_PIN, OUTPUT);
  digitalWrite(VBAT_READ_CNTRL_PIN, LOW);
  dht.begin();
}

void loop() {
  switch (deviceState) {
    case DEVICE_STATE_INIT: {
#if (LORAWAN_DEVEUI_AUTO)
      LoRaWAN.generateDeveuiByChipID();
#endif
      LoRaWAN.init(loraWanClass, loraWanRegion);
      break;
    }
    case DEVICE_STATE_JOIN: {
      LoRaWAN.join();
      break;
    }
    case DEVICE_STATE_SEND: {
      prepareTxFrame(appPort);
      LoRaWAN.send();
      deviceState = DEVICE_STATE_CYCLE;
      break;
    }
    case DEVICE_STATE_CYCLE: {
      txDutyCycleTime = appTxDutyCycle + randr(-APP_TX_DUTYCYCLE_RND, APP_TX_DUTYCYCLE_RND);
      LoRaWAN.cycle(txDutyCycleTime);
      deviceState = DEVICE_STATE_SLEEP;
      break;
    }
    case DEVICE_STATE_SLEEP: {
      LoRaWAN.sleep(loraWanClass);
      break;
    }
    default: {
      deviceState = DEVICE_STATE_INIT;
      break;
    }
  }
}

Payload Decorder:

function decodeUplink(input) {
  var nestWeight = (input.bytes[0] << 8) | input.bytes[1];
  var batteryVoltage = (input.bytes[2] << 8) | input.bytes[3];
  var humidity = (input.bytes[4] << 8) | input.bytes[5];
  var temperature = (input.bytes[6] << 8) | input.bytes[7];
  
  var errorMessage = 'measurement_error';
  
  if (nestWeight < 1000) {
    return {
      data: {
        nest_weight_in_grams: nestWeight / 10,
        battery_status_in_volts: batteryVoltage / 100,
        humidity_in_percent: humidity / 100,
        temperature_in_degrees_celsius: temperature / 100
      }
    };
  } else {
    return {
      data: {
        error_message: errorMessage
      } 
    };
  }
}

What is the RSSI?

where and how can I find it?

In the application console, if it is more than -65 → -50 search the forum or the solution

it is -115, what should i do? means that it is too far?

You are on the lower side of the scale.

What is the SNR like?

What LoRaWAN version are your sketch using and what did you set it what did you set it on when you registered your node?

Generally, if you are using something other than a Heltec AB board, I would recommend not using Heltec’s own LoRaWAN stack, but rather RadioLib.

the SNR is -15.5
grafik
that is almost everything

I use following board and this library
do you mean this RadioLib?

Will that help with the signal quality? :crazy_face:

At this point with HellTech I wouldn’t be surprised…

Yup!

OK gentleman, before the OP suffers at the hand of the forum banter:

@dermerten, your device comes with a poor quality antenna and the RSSI & SNR indicate you are at the very edge of the range of the community gateway as well.

You MAY get lucky by using a slightly larger better antenna and ensuring you are in line of sight of the gateways location. Gateways usually have a decent antenna so they can typically hear signals from devices but the devices smaller & potentially lower quality antennas can’t pick up any response that may be required - in this case the join accept.

The reality is (as forum search will reveal) is that anyone going DIY with LoRaWAN needs their own gateway so that you see what’s going on with reception. A TTIG is a good starter gateway.

You are heading to the grass fields of RF.

Read here

You have 3 choices.

  1. Get a gateway closer to your location.
  2. Change you position, better LOS to gateway or closer to the existing gateway.
  3. Better antenna for your node (Heltec antennas are notorious)

thank you, i will now see if i can find another antenna, otherwise it’s annoying

thank you, I’ll see if I can get closer to the gateway

with the new antenna
“rssi”: -116,
“snr”: -5.5

Down on the RSSI and up on the SNR, but somewhat irrelevant, does it blend hear the join accept?

everything is the same with the join

So, I think I’ve got it right. The problem was that the gateway I had was on the hill and the signals didn’t reach it properly. I now have another one that is “flat” or on the same level as my LoRaWAN and now it works.

Can you please not use confirmed links? It bad for the network (limiting the gateways ability to receive other nodes data), and you are using a community gateway.