Please post all relevant information as an issue or discussion on the RadioLib GitHub repo.
Try to include the bare minimum of your code that involves the setup and join, debug information after enabling the DEBUG flag, and some nicely formatted text blocks of what you see on your console.
Need help with setting up LoRa on ESP32 V3 LoRa Dev Board
I can see the join request and acceptance in the Helium Console, repeated over and over. I guess my sensor canât tell he was accepted into the network.
Steven, I am sorry. The join requests were from one of my Heltec cubecell_AB02A boards. I was confused about which board was getting through to the Console.
With this in mind I probably should not post any code on RadioLib github repo as I imagine I still have my configuration incorrect.
Steven, I really want to test the SX1262 code, but still getting a -6 return code.
If you have a minute would you mind looking at my startup method to see if anything jumps out?
I tried adding your addional SPI configuration, but it did not change anything, so I am leaving it out
to keep the config as simple as possible.
#include <RadioLib.h>
//new slave select pin to use, defaults to 18
//new DIO0 pin to use, defaults to 26
//new reset pin to use, defaults to 14
uint32_t csPin = 8;
uint32_t irqPin = 14;
uint32_t rstPin = 12;
uint32_t gpioPin = 13;
SX1262 radio = new Module(csPin, irqPin, rstPin, gpioPin);
LoRaWANNode node(&radio, &US915);
void setup() {
Serial.begin(115200);
Serial.print(F("[SX1262] Initializing ... "));
node.selectSubband(1);
int state = radio.begin();
if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("Lora success!"));
}
else
{
Serial.print(F("Lora failed, code "));
Serial.println(state);
while(true);
}
uint64_t joinEUI = 0x6081F...
uint64_t devEUI = 0x6081F9...
uint8_t nwkKey[] = { 0x15, 0xB1,...
uint8_t appKey[] = {0x21, 0x75, ...
Serial.print(F("[LoRaWAN] Attempting over-the-air activation ... "));
state = node.beginOTAA(joinEUI, devEUI, nwkKey, appKey);
if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while(true);
}
}
The output is the same as above, but will include it here.
[SX1262] Initializing ... Channel UL 0 frequency = 902.299988 MHz
Channel UL 1 frequency = 902.500000 MHz
Channel UL 2 frequency = 902.700012 MHz
Channel UL 3 frequency = 902.899963 MHz
Channel UL 4 frequency = 903.099976 MHz
Channel UL 5 frequency = 903.299988 MHz
Channel UL 6 frequency = 903.500000 MHz
Channel UL 7 frequency = 903.700012 MHz
freq: 915.00
bw: 125.00
sf: 7
cr: 7
syncWord: 18
power: 10
preambleLength: 8
tcxoVoltage: 1.60
useRegulatorLDO: 0
RadioLib Debug Info
Version: 6.2.0.0
Platform: ESP32
Compiled: Nov 12 2023 19:18:01
Found SX126x: RADIOLIB_SX126X_REG_VERSION_STRING:
0000320 53 58 31 32 36 31 20 56 32 44 20 32 44 30 32 00 | SX1261 V2D 2D02.
M SX126x
Lora success!
[LoRaWAN] Attempting over-the-air activation ...
Channel frequency UL = 902.299988 MHz
DR 72: LORA (SF: 10, BW: 125.000000, CR: 5)
Timeout in 556032 us
Join-request sent <-- Rx Delay start
Channel frequency DL = 923.299988 MHz
DR 64: LORA (SF: 10, BW: 500.000000, CR: 5)
Opening Rx1 window (71712 us timeout)... <-- Rx Delay end
closing
DR 96: LORA (SF: 12, BW: 500.000000, CR: 5)
Opening Rx2 window (185888 us timeout)... <-- Rx Delay end
closing
failed, code -6
Is your gateway really configured for subband 1? The default for US is almost always subband 2. So Iâd try that first.
Yes, I have tried all 8 subchannels. I have spent hours trying all kinds of config, but still getting code -6.
My gateway is not working, but there are many in the neighborhood. The Helium Hotspot is typically not configured. You just plug it in and the LoraWan config is already configured.
Thank you for your continued interest in my attempts to use the new RadioLib classes.
Some more things:
- how did you configure your device on the console? LoRaWAN version, regional parameters etc, some screenshot would be nice
- can you enable some sort of verbose output on the console to see if thereâs maybe a problem with keys or so which makes the join-request fail?
When you add a device to the Helium console, it automatically populates the deveui, appeui and appkey.
I have taken those values and inserted them into my code.
I do not see any verbose option.
Interesting, I found and configured a profile which mentions subband.
I set it to 2, and updated my code, but no luck.
Is there any big or little indianness that I need to pay attention to?
What country to you live in Steven? I am in Austin Texas.
Help on Adding a device to Helium Console
Thank you for your help.
What I can see looks OK, but what I canât see may be crucial:
- Did you make sure that the AppEUI on the console is the joinEUI in the code? Since it is close to the devEUI but not exactly the same.
- The console reports an âApp Keyâ, but in the code this should be the âNwkKeyâ - I cannot tell if you configured this correctly.
- Also, I assume that you configured your device as a LoRaWAN v1.1 device? Thatâs also not visible from the screenshot.
Oh, the AppKey should be the NwkKey.
Did not know that. Checking now.
node.selectSubband(2);
Yes, the AppEUI, is the joinEUI.
The NwkKey is now the appKey. (what should the appkey be?)
uint64_t devEUI = 0x6081F9CC292D9FCF; //v3
uint64_t joinEUI = 0x6081F9F682B030A7;
uint8_t appKey[] = { 0xCB, 0x87, 0xFB, 0x88, 0x8A, 0x66, 0x88, 0x25, 0x4B, 0xAA, 0xD0, 0x7B, 0x34, 0xC1, 0xhidden, 0xhidden };
uint8_t nwkKey[] = { 0xCB, 0x87, 0xFB, 0x88, 0x8A, 0x66, 0x88, 0x25, 0x4B, 0xAA, 0xD0, 0x7B, 0x34, 0xC1, 0xhidden, 0xhidden }; but they match the console config.
The AppKey is ignored in LoRaWAN v1.1 sessions, so you can just keep it the same or set to all zeroes - doesnât matter. This now looks good to me, so Iâd say you give it a shot!
Yes, have and its a no go. Still -6 code.
The console has a debut mode and sits âwaiting for dataâ. I launch the sensor and the console never sees anything.
I canât see where I can specify LoRaWAN v1.1, but this next image does not look good.
Steven, I have to leave my house and go to work.
Thank you for the support.
I will look at your reply after I get off this afternoon.
I think youâve defined your homework yourself with that screenshot
Yes, I am trying to find out if the Console was upgraded to 1.1.
Looks like the legacy console.helium.com is LoraWan 1.0.3.
Sorry for taking your time up on this.
Thank again for your help.
No problem, youâre welcome. Useful knowledge!
Now Iâm curious - will you be looking for another stack such as the default LoRaWAN_APP, or another server such as TTN? Thatâs also useful knowledgeâŚ
Well my goal for this board was to use it as a gateway for my other sensors around the property.
I was going to use LoraWan through the Helium network b/c I have a hotspot and there are 100s of them in Austin, TX.
I already have a Flow on the console that accepts msgs and sends them on to AzureIotHub and then on to an Azure Function that sends the data into Azure TableStorage.
So I wanted to use that route.
But it seems it is a no goâŚso far.
So my plan is to use the V3 board to receive Lora msgs and then use the Wifi to send straight to Azure IotHub.
Now I have to see if i can get Lora SX1262 talking to SX1278 radios. I donât think that will be a big deal, but with radios in my experience, everything is a big deal.
Did you ever find a solution to your issue? I am running into a similar problem where Iâve configured a console with an appEUI (JoinEUI), dev(EUI), and appKey. Iâm using Lorawan Mac version 1.0.3 Region B US915 on and canât connect to any gateway around me even when 10 feet away. I tried using your example code and with some debugging got it to compile but not connect to any gateway. Is there a better example template for the LoRa ESP32 WiFi dev board v3 connecting to Helium?
@kempd1 sorry you are having trouble connecting to Helium.
This is a very frustrating hobby, as you know.
October 2023 was a lifetime ago in IOT years. I canât remember how I got it to connect. I have looked over my code projects and found 2 files that look like they might work. I have not tested them as I am not working on these type of projects at this time.
Try this code.
#include "LoRaWan_APP.h"
#include "Arduino.h"
/*
* set LoraWan_RGB to Active,the RGB active in loraWan
* RGB red means sending;
* RGB purple means joined done;
* RGB blue means RxWindow1;
* RGB yellow means RxWindow2;
* RGB green means received done;
*/
/* OTAA para*/
uint8_t devEui[] = { 0x, 0x, 0x, 0x47, 0x56, 0x99, 0xDC, 0x };
uint8_t appEui[] = { 0x, 0xF6, 0x, 0x93, 0x, 0x64, 0x, 0x68 };
uint8_t appKey[] = { 0x, 0x32, 0xD1, 0x, 0x93, 0x, 0xCF, 0x5D, 0x3D, 0x, 0x32, 0x, 0xA5, 0x, 0xCF, 0x37 };
/* ABP para*/
uint8_t nwkSKey[] = { 0x, 0xb1, 0x, 0xef, 0xa4, 0x, 0xdf, 0xbe, 0x, 0x11, 0x, 0x1e, 0x, 0xc7, 0x,0x85 };
uint8_t appSKey[] = { 0x, 0x2c, 0x, 0x75, 0x8c, 0x, 0xca, 0xbf, 0x, 0xee, 0x, 0x77, 0x, 0x16, 0xe, 0x67 };
uint32_t devAddr = ( uint32_t )0x007e6ae1;
/*LoraWan channelsmask, default channels 0-7*/
uint16_t userChannelsMask[6]={ 0xFF00,0x0000,0x0000,0x0000,0x0000,0x0000 };
/*LoraWan region, select in arduino IDE tools*/
LoRaMacRegion_t loraWanRegion = ACTIVE_REGION;
/*LoraWan Class, Class A and Class C are supported*/
DeviceClass_t loraWanClass = LORAWAN_CLASS;
/*the application data transmission duty cycle. value in [ms].*/
uint32_t appTxDutyCycle = 300000;
/*OTAA or ABP*/
bool overTheAirActivation = LORAWAN_NETMODE;
/*ADR enable*/
bool loraWanAdr = LORAWAN_ADR;
/* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */
bool keepNet = LORAWAN_NET_RESERVE;
/* Indicates if the node is sending confirmed or unconfirmed messages */
bool isTxConfirmed = LORAWAN_UPLINKMODE;
/* Application port */
uint8_t appPort = 2;
/*!
* Number of trials to transmit the frame, if the LoRaMAC layer did not
* receive an acknowledgment. The MAC performs a datarate adaptation,
* according to the LoRaWAN Specification V1.0.2, chapter 18.4, according
* to the following table:
*
* Transmission nb | Data Rate
* ----------------|-----------
* 1 (first) | DR
* 2 | DR
* 3 | max(DR-1,0)
* 4 | max(DR-1,0)
* 5 | max(DR-2,0)
* 6 | max(DR-2,0)
* 7 | max(DR-3,0)
* 8 | max(DR-3,0)
*
* Note, that if NbTrials is set to 1 or 2, the MAC will not decrease
* the datarate, in case the LoRaMAC layer did not receive an acknowledgment
*/
uint8_t confirmedNbTrials = 4;
/* Prepares the payload of the frame */
static void prepareTxFrame( uint8_t port )
{
/*appData size is LORAWAN_APP_DATA_MAX_SIZE which is defined in "commissioning.h".
*appDataSize max value is LORAWAN_APP_DATA_MAX_SIZE.
*if enabled AT, don't modify LORAWAN_APP_DATA_MAX_SIZE, it may cause system hanging or failure.
*if disabled AT, LORAWAN_APP_DATA_MAX_SIZE can be modified, the max value is reference to lorawan region and SF.
*for example, if use REGION_CN470,
*the max value for different DR can be found in MaxPayloadOfDatarateCN470 refer to DataratesCN470 and BandwidthsCN470 in "RegionCN470.h".
*/
appDataSize = 4;
appData[0] = 0x00;
appData[1] = 0x01;
appData[2] = 0x02;
appData[3] = 0x03;
}
void setup() {
boardInitMcu();
Serial.begin(115200);
#if(AT_SUPPORT)
enableAt();
#endif
deviceState = DEVICE_STATE_INIT;
LoRaWAN.ifskipjoin();
}
void loop()
{
switch( deviceState )
{
case DEVICE_STATE_INIT:
{
#if(AT_SUPPORT)
getDevParam();
#endif
printDevParam();
LoRaWAN.init(loraWanClass,loraWanRegion);
deviceState = DEVICE_STATE_JOIN;
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:
{
// Schedule next packet transmission
txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND );
LoRaWAN.cycle(txDutyCycleTime);
deviceState = DEVICE_STATE_SLEEP;
break;
}
case DEVICE_STATE_SLEEP:
{
LoRaWAN.sleep();
break;
}
default:
{
deviceState = DEVICE_STATE_INIT;
break;
}
}
}