Esp32 + Things Indoor Gateway

"Hello,
I am a newbee :wink: !
I have the following setup:
Things Indoor Gateway
ESP32 with LMIC with library 4.11
I receive frames well on the gateway but never in the application.
I had previously started with an Arduino Nano.
At one point it worked with a message from a variable.
I then recompiled with a DHT11 sensor.
And then, I only received frames in the gateway.
I made a rollback, but without success. no more message in application
The amount of RAM of the Nano does not allow me to debug LMIC, so I went back to an ESP32.
But nothing has changed, I only see frames in the gateway.

Now i have enabled debug:
On platformio terminal i have this output:

145621728: EV_TXSTART
145621808: TXMODE, freq=868500000, len=18, SF=7, BW=125, CR=4/5, IH=0
Packet queued
145686536: setupRx1 txrxFlags 0x20 --> 01
start single rx: now-rxtime: 4
145687170: RXMODE_SINGLE, freq=868500000, SF=7, BW=125, CR=4/5, IH=0
rxtimeout: entry: 145688208 rxtime: 145687160 entry-rxtime: 1048 now-entry: 5 rxtime-txend: 62126
145748785: setupRx2 txrxFlags 0x1 --> 02
start single rx: now-rxtime: 5
145749420: RXMODE_SINGLE, freq=869525000, SF=9, BW=125, CR=4/5, IH=0
rxtimeout: entry: 145752250 rxtime: 145749410 entry-rxtime: 2840 now-entry: 5 rxtime-txend: 124376
145752280: processRx2DnData txrxFlags 0x2 --> 00
145752939: processDnData_norx txrxFlags 00 --> 20
145752953: EV_TXCOMPLETE (includes waiting for RX windows)
145752961: engineUpdate, opmode=0x900
Temperature: 10.00 *C
%RH 10.00
153252979: engineUpdate, opmode=0x908
153253003: EV_TXSTART
153253083: TXMODE, freq=868300000, len=18, SF=7, BW=125, CR=4/5, IH=0
Packet queued

On the gateway i have this frames

{
  "name": "gs.up.receive",
  "time": "2023-01-27T11:52:07.187169085Z",
  "identifiers": [
    {
      "gateway_ids": {
        "gateway_id": "eui-58a0cbfffe804cfd",
        "eui": "58A0CBFFFE804CFD"
      }
    }
  ],
  "data": {
    "@type": "type.googleapis.com/ttn.lorawan.v3.GatewayUplinkMessage",
    "message": {
      "raw_payload": "QPGyCyaAFAABVq5Wwrm6cazs",
      "payload": {
        "m_hdr": {
          "m_type": "UNCONFIRMED_UP"
        },
        "mic": "unGs7A==",
        "mac_payload": {
          "f_hdr": {
            "dev_addr": "260BB2F1",
            "f_ctrl": {
              "adr": true
            },
            "f_cnt": 20
          },
          "f_port": 1,
          "frm_payload": "Vq5Wwrk="
        }
      },
      "settings": {
        "data_rate": {
          "lora": {
            "bandwidth": 125000,
            "spreading_factor": 7,
            "coding_rate": "4/5"
          }
        },
        "frequency": "868300000",
        "timestamp": 2477058291,
        "time": "2023-01-27T11:52:07.094743013Z"
      },
      "rx_metadata": [
        {
          "gateway_ids": {
            "gateway_id": "eui-58a0cbfffe804cfd",
            "eui": "58A0CBFFFE804CFD"
          },
          "time": "2023-01-27T11:52:07.094743013Z",
          "timestamp": 2477058291,
          "rssi": -53,
          "channel_rssi": -53,
          "snr": 9.5,
          "location": {
            "latitude": 43.6987212133099,
            "longitude": 1.02558586746454,
            "altitude": 180,
            "source": "SOURCE_REGISTRY"
          },
          "uplink_token": "CiIKIAoUZXVpLTU4YTBjYmZmZmU4MDRjZmQSCFigy//+gEz9EPPRk50JGgsI5/XOngYQ4KOPWSC46rfhi8IC",
          "received_at": "2023-01-27T11:52:07.040387934Z"
        }
      ],
      "received_at": "2023-01-27T11:52:07.186896864Z",
      "correlation_ids": [
        "gs:conn:01GQS6JC2E8VPMP7F8GCBDDCWD",
        "gs:uplink:01GQSH45RK1KKJVGXPKB6D648E"
      ]
    },
    "band_id": "EU_863_870"
  },
  "correlation_ids": [
    "gs:conn:01GQS6JC2E8VPMP7F8GCBDDCWD",
    "gs:uplink:01GQSH45RK1KKJVGXPKB6D648E"
  ],
  "origin": "ip-10-100-14-194.eu-west-1.compute.internal",
  "context": {
    "tenant-id": "CgN0dG4="
  },
  "visibility": {
    "rights": [
      "RIGHT_GATEWAY_TRAFFIC_READ"
    ]
  },
  "unique_id": "01GQSH45RK7BZ6530Q2X0C7B4B"
}

Could someone give me a clue for investigation? It’s been 2 days that I’ve been working on it without any result.
Thank you !!!

Welcome,

The most common issue are the swapping of the keys (JoinEUI , DevEUI and AppKey) You need to make sure this is in either MSB or LSB as the sketch calls for.

What sketch are you using?

Please also format you post correctly, you need to use the </> tool from the post formatting tools to post text or code, difficult to pick up where you code starts and stop.

Thank you for yor response
Sorry, i have edit my post to modify my post…
My sketch is ttn-abp example modified with DHT payload take from other exemple
I have no JoinEUI
I have only fill NWKSKEY, APPSKEY and DEVADDR.
i have copy / paste values in MSB format.

Hi,
I have change change noting to my code and now it works !
30min ago i have reset session and MAC state on TTN portal device.
I don’t know if this action solve my problem…

You may well have been caught out with the FCount being below what LNS had already seen on earlier sessions/attempts - reseting FCount (ok for testing but not recommended for production due to risk of replay attacks) overcomes that. Best if using OTAA rather than ABP then count is reset each time a new join happens so inherently more secure. By almeans run for a short time on ABP when testing as good/easy way to check RF taths and initial data flow working…

1 Like

I would use OTAA

1 Like

well… I modified the sketch to adjust a sensor, reprogrammed the ESP, and it starts again: no more data :frowning:

Ok, so i’m going to modify my sketch to OTAA…

Now i have change my sketch, and register my device with a joinEUI as 0000000000000001.

{
  "name": "gs.up.receive",
  "time": "2023-01-27T14:32:36.291432243Z",
  "identifiers": [
    {
      "gateway_ids": {
        "gateway_id": "eui-58a0cbfffe804cfd",
        "eui": "58A0CBFFFE804CFD"
      }
    }
  ],
  "data": {
    "@type": "type.googleapis.com/ttn.lorawan.v3.GatewayUplinkMessage",
    "message": {
      "raw_payload": "AAAAAAAAAAABAQAAAAAAAACxV+mDoD0=",
      "payload": {
        "m_hdr": {},
        "mic": "6YOgPQ==",
        "join_request_payload": {
          "join_eui": "0100000000000000",
          "dev_eui": "0000000000000001",
          "dev_nonce": "57B1"
        }
      },
      "settings": {
        "data_rate": {
          "lora": {
            "bandwidth": 125000,
            "spreading_factor": 8,
            "coding_rate": "4/5"
          }
        },
        "frequency": "868500000",
        "timestamp": 1779745684,
        "time": "2023-01-27T14:32:36.198513031Z"
      },
      "rx_metadata": [
        {
          "gateway_ids": {
            "gateway_id": "eui-58a0cbfffe804cfd",
            "eui": "58A0CBFFFE804CFD"
          },
          "time": "2023-01-27T14:32:36.198513031Z",
          "timestamp": 1779745684,
          "rssi": -60,
          "channel_rssi": -60,
          "snr": 8.5,
          "location": {
            "latitude": 43.6987212133099,
            "longitude": 1.02558586746454,
            "altitude": 180,
            "source": "SOURCE_REGISTRY"
          },
          "uplink_token": "CiIKIAoUZXVpLTU4YTBjYmZmZmU4MDRjZmQSCFigy//+gEz9EJSH09AGGgwIhMHPngYQs/HwigEgoPTviOYz",
          "received_at": "2023-01-27T14:32:36.130200615Z"
        }
      ],
      "received_at": "2023-01-27T14:32:36.291256499Z",
      "correlation_ids": [
        "gs:conn:01GQSRKNYAYF1KNZN7W249XJ08",
        "gs:uplink:01GQSTA163KNC38YS738V8VRR2"
      ]
    },
    "band_id": "EU_863_870"
  },
  "correlation_ids": [
    "gs:conn:01GQSRKNYAYF1KNZN7W249XJ08",
    "gs:uplink:01GQSTA163KNC38YS738V8VRR2"
  ],
  "origin": "ip-10-100-7-80.eu-west-1.compute.internal",
  "context": {
    "tenant-id": "CgN0dG4="
  },
  "visibility": {
    "rights": [
      "RIGHT_GATEWAY_TRAFFIC_READ"
    ]
  },
  "unique_id": "01GQSTA163QB4W8FBTNNBYK2Y2"
}

Now my new problem is EV_JOIN_TXCOMPLETE: no JoinAccept

28571280: EV_TXSTART
28571360: TXMODE, freq=868500000, len=23, SF=8, BW=125, CR=4/5, IH=0
start single rx: now-rxtime: 4
28889578: RXMODE_SINGLE, freq=868500000, SF=8, BW=125, CR=4/5, IH=0
rxtimeout: entry: 28893047 rxtime: 28889567 entry-rxtime: 3480 now-entry: 6 rxtime-txend: 311126
start single rx: now-rxtime: 5
28951827: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
rxtimeout: entry: 28968227 rxtime: 28951817 entry-rxtime: 16410 now-entry: 5 rxtime-txend: 373376
28968258: EV_JOIN_TXCOMPLETE: no JoinAccept

Is my joinEUI is correct ?

Re,
I have change my joinEUI and corrected my APP with little endian format !
i have generate JoinEUI with this generator :

https://descartes.co.uk/CreateEUIKey.html

And it work’s !!! :champagne:

load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
entry 0x400805e4
Starting
Temperature: 20.20 *C
%RH 45.20
Packet queued
628236: EV_JOINING
850379: EV_TXSTART
1171476: EV_JOINED
1171505: EV_TXSTART
1490007: EV_TXCOMPLETE 

Thank You for advice !!! :hearts:

Using any EUI or keys that are like default is a bad idea, most probably a 100 other newbee tried it.

Rather use this to generate one

And please make sure you stay within Fair usage limits.

already used :wink:

my payload in 4 bytes : 6F 6E 33 77

i have used this calculator:

Airtime calculator for LoRaWAN (avbentem.github.io)

and i have configure a TX_INTERVAL 150

I think it is good ??

Thats about right for a best case situation, when the node is close to the Gateway.

However if the node is some distance from the Gateway and the spreading factor automatically adjust upwards, to add extra receive sensitivity to cope with the extra distance, a 150 second interval would be a significant breach of the fair access policy.

What are you measuring? Ambient parameters?

You will find if it is 150sec for ambient you are wasting you battery life, as the rate of changes is not that sudden, you can dail it quite a bit back. More i the 10min to 15min region.