Arduino nano and RFM95 basic test - EV_JOIN_TXCOMPLETE: no JoinAccept

Tell me more about that. I’m using the simplest ttn-abp sketch example. Should I add this in my example? Taken from tutorial
// Use with Arduino Pro Mini ATmega328P 3.3V 8 MHz
// Let LMIC compensate for +/- 1% clock error
LMIC_setClockError(MAX_CLOCK_ERROR * 1 / 100);

On which GPIO should I measure signals to see timings? I can measure only transmit (sending hello world), I’m not receiving anything.

The clock error thing has been poorly understand by many for a long time, and often causes as many problems as it solves. In some cases it may be useful, but needs to be used with a much more detailed understanding of specifics than the usual blindly hopeful “try this…” and may also require adjustment to the duration of the receive window in symbols.

To use a GPIO for checking timing, you’d need a storage scope (or USB logic analyzer) and pick an unused digital pin. Given LMiC is C code, you’d either need to figure out the actual AVR port pin involved and set/clear it by direct access to the appropriate PORTx register, or perhaps better create an extern "C" function in your Arduino code which the LMiC code could call to blip or toggle it. Then you need to find the code that detects the end of transmission, and the code that starts reception, and put the manipulation of the test GPIO there.

Capturing all of the SPI traffic and relevant end-of-transmit DIO with a USB logic analyzer could be another approach, not requiring software changes to support.

(If this sounds complicated and not what one bargained for in choosing an Arduino approach, that’s because it is. If one is going to use LMiC, especially under Arduino, then it really makes sense to chose a board supported by and used for regression tests of a maintained LMiC. Otherwise you’re basically in the complexity territory of a professional embedded development project, with the added complication of a project/library interaction which makes things even harder to work on than usual…)

No problem. I have a logic analyser. One clock pulse width is 0,125us. Is that normal?

It’s unclear if you mean the SPI clock or the analyzer sampling rate. What sampling rate did you use? 1/8 of a uS would suggest you might be looking at the period of 8 MHz sampling, if the SPI clock is really that fast you’d need to run the analyzer faster.

Anyway, what you’d really want to be seeing is a sequence such as:

  • Chip select framed SPI operations to configure radio for transmission
  • tens to hundreds of milliseconds of nothing (matching calculated packet duration)
  • DIO change indicating end of transmission
  • just under 5000 uS of delay for 5 second RX1
  • Chip select framed sequence of SPI operations to set up receive
  • the above completing just before 5000 uS has elapsed from the end of transmit
  • DIO indicating reception… or else failure

One thing you need to make sure is that there’s some electrical activity to mark when the attempt at receiving ends in the case of getting nothing. I forget exactly how LMiC does this - maybe a DIO, maybe polling?

One of the historic issues with the clock error stuff for example is that it sometimes causes the receive attempt to begin early enough, that it then actually gives up before the preamble of the packet is actually due.

Looking at my notes from other support cases on here and elsewhere, the simpler quick things to check are:

  1. The pin map - if you can take some photos that show the Arduino & the RFM95 we can check it for you
  2. The soldering - at least one case the soldering looked OK but it all burst in to life after a quick touch up

This is my first test node:

IMG_5020

This is what I’d suggest for a first node:

45a4710c8d6871b4fd6dc9c0b0fb8cb8359b5c62

The small white PCB is actually an ESP mounting board - a convenient way to making an RFM95 breadboard friendly.

This is the PCB I now use:

P1040726
P1040728

Stick in there, I absolutely know this can work, as you can see, I’ve at least three form factors working.

Pin Map I used:

Table

pinmap2

Schematic

My board

cropboard2

Sketch pinmap

arduinocodepinmap

I know it’s better to use a breadboard, but I don’t have one, so I use my soldering iron.
I checked connections, there is no bad contact or short.

I had an idea to simulate not working rfm module. I unsoldered VCC wire, RFM95 was not powered. In the console I saw:

Starting
FAILURE
C:\Users\lorauser\Documents\Arduino\libraries\arduino-lmic-matthijskooijman\src\lmic\radio.c:545

The message changed. RFM module is working. I soldered the VCC back. I’m back to initial message

Starting
Packet queued
132006: EV_TXCOMPLETE (includes waiting for RX windows)

2 Likes

Really good answer - thanks. All seems in order to me.

The simulation tells us that the library errors correctly when the radio is not connected, but not if there is an issue with it.

I’m presuming you have an appropriate length piece of wire on the antenna that’s cropped top right in the picture - 82mm or 164mm.

Can you try sending a downlink from the TTN console to see if your ABP sketch is receiving as well as sending?

I’m using the antenna that I received with this module.
antena

I sent downlink message. The sketch don’t see nothing.
The packet is queued.
downlink

Frames up 0

Frames down 0

Did you tell the node to send an uplink? It will only get it when it uplinks …

How to do that? Upload raw sketch for listening?

The ABP sketch is just fine - hit the reset button on the Arduino.

Hopefully just after you get the EV_TXCOMPLETE you’ll get a Received x bytes of payload message

I changed the device registration from ABP to OTAA on TTN side. Then uploaded my otta example to arduino. Now I don’t see no JoinAccept. It’s repeating this
Starting
Packet queued
441: EV_JOINING
But with another LMIC MCCI library,
name=MCCI LoRaWAN LMIC library
version=3.2.0
author=IBM, Matthis Kooijman, Terry Moore, ChaeHee Won, Frank Rose
maintainer=Terry Moore tmm@mcci.com
, I see the old message EV_TXCOMPLETE: no join accept. Nothing received from TTN.

The point of my ABP test that I suggested is to check if the device can uplink and then receive the downlink in the simplest possible way.

Changing over to OTAA complicates the test.

Please try the ABP test - takes about 30 seconds - I’ll wait.

1 Like

I misunderstood what I should do. I will correct this late night back to ABP, but not now (I’m working). Thanks for explanation.

  • Switched back to ABP.
  • Updated all keys in the sketch.
  • Sent downlink message from TTN.

Starting
Packet queued
131964: EV_TXCOMPLETE (includes waiting for RX windows)
Packet queued
4013602: EV_TXCOMPLETE (includes waiting for RX windows)
Packet queued
7895244: EV_TXCOMPLETE (includes waiting for RX windows)

status
sched

Firstly I did suggest testing ABP 23 days ago, I cant believe you’ve only just tested it given the length of this thread :slight_smile:

“Status - unseen” , your ABP uplinks are not being received according to the console image you just posted, downlinks will never work until uplink functionality is working.

Something else is wrong, your device logs looks clean (which is good, device hardware is prob working ok) - I’d check the device setup re it being an ABP device, even a small typo and you wont see uplinks, there are dozens of threads here on basic fault finding

Yes, it’s a little bit long this debug. I’ve tried a lot of confings, waiting for 2 new boards, but the problem is somewhere else.

I’m just using standard ttn-abp scketch example, modified only keys. I posted before my full sketch, there were no errors. I’m not lazy to post current config:

ttn-abp sketch from example
/*******************************************************************************
 * Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman
 *
 * Permission is hereby granted, free of charge, to anyone
 * obtaining a copy of this document and accompanying files,
 * to do whatever they want with them without any restriction,
 * including, but not limited to, copying, modification and redistribution.
 * NO WARRANTY OF ANY KIND IS PROVIDED.
 *
 * This example sends a valid LoRaWAN packet with payload "Hello,
 * world!", using frequency and encryption settings matching those of
 * the The Things Network.
 *
 * This uses ABP (Activation-by-personalisation), where a DevAddr and
 * Session keys are preconfigured (unlike OTAA, where a DevEUI and
 * application key is configured, while the DevAddr and session keys are
 * assigned/generated in the over-the-air-activation procedure).
 *
 * Note: LoRaWAN per sub-band duty-cycle limitation is enforced (1% in
 * g1, 0.1% in g2), but not the TTN fair usage policy (which is probably
 * violated by this sketch when left running for longer)!
 *
 * To use this sketch, first register your application and device with
 * the things network, to set or generate a DevAddr, NwkSKey and
 * AppSKey. Each device should have their own unique values for these
 * fields.
 *
 * Do not forget to define the radio type correctly in config.h.
 *
 *******************************************************************************/

#include <lmic.h>
#include <hal/hal.h>
#include <SPI.h>

// LoRaWAN NwkSKey, network session key
// This is the default Semtech key, which is used by the early prototype TTN
// network.
static const PROGMEM u1_t NWKSKEY[16] = { 0x3B, 0x7A, 0xDF, 0x93, 0x80, 0x35, 0xCB, 0x9A, I removed this part here };

// LoRaWAN AppSKey, application session key
// This is the default Semtech key, which is used by the early prototype TTN
// network.
static const u1_t PROGMEM APPSKEY[16] = { 0xF4, 0xD8, 0x88, 0xD1, 0xDC, 0x14, 0x50, 0xE1, 0xAB, I removed this part here };

// LoRaWAN end-device address (DevAddr)
static const u4_t DEVADDR = 0x26011882 ; // <-- Change this address for every node!

// These callbacks are only used in over-the-air activation, so they are
// left empty here (we cannot leave them out completely unless
// DISABLE_JOIN is set in config.h, otherwise the linker will complain).
void os_getArtEui (u1_t* buf) { }
void os_getDevEui (u1_t* buf) { }
void os_getDevKey (u1_t* buf) { }

static uint8_t mydata[] = "Hello, world!";
static osjob_t sendjob;

// Schedule TX every this many seconds (might become longer due to duty
// cycle limitations).
const unsigned TX_INTERVAL = 60;

// Pin mapping
const lmic_pinmap lmic_pins = {
    .nss = 10,
    .rxtx = LMIC_UNUSED_PIN,
    .rst = 5,
    .dio = {2, 3, LMIC_UNUSED_PIN},
};

void onEvent (ev_t ev) {
    Serial.print(os_getTime());
    Serial.print(": ");
    switch(ev) {
        case EV_SCAN_TIMEOUT:
            Serial.println(F("EV_SCAN_TIMEOUT"));
            break;
        case EV_BEACON_FOUND:
            Serial.println(F("EV_BEACON_FOUND"));
            break;
        case EV_BEACON_MISSED:
            Serial.println(F("EV_BEACON_MISSED"));
            break;
        case EV_BEACON_TRACKED:
            Serial.println(F("EV_BEACON_TRACKED"));
            break;
        case EV_JOINING:
            Serial.println(F("EV_JOINING"));
            break;
        case EV_JOINED:
            Serial.println(F("EV_JOINED"));
            break;
        case EV_RFU1:
            Serial.println(F("EV_RFU1"));
            break;
        case EV_JOIN_FAILED:
            Serial.println(F("EV_JOIN_FAILED"));
            break;
        case EV_REJOIN_FAILED:
            Serial.println(F("EV_REJOIN_FAILED"));
            break;
        case EV_TXCOMPLETE:
            Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
            if (LMIC.txrxFlags & TXRX_ACK)
              Serial.println(F("Received ack"));
            if (LMIC.dataLen) {
              Serial.println(F("Received "));
              Serial.println(LMIC.dataLen);
              Serial.println(F(" bytes of payload"));
            }
            // Schedule next transmission
            os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
            break;
        case EV_LOST_TSYNC:
            Serial.println(F("EV_LOST_TSYNC"));
            break;
        case EV_RESET:
            Serial.println(F("EV_RESET"));
            break;
        case EV_RXCOMPLETE:
            // data received in ping slot
            Serial.println(F("EV_RXCOMPLETE"));
            break;
        case EV_LINK_DEAD:
            Serial.println(F("EV_LINK_DEAD"));
            break;
        case EV_LINK_ALIVE:
            Serial.println(F("EV_LINK_ALIVE"));
            break;
         default:
            Serial.println(F("Unknown event"));
            break;
    }
}

void do_send(osjob_t* j){
    // Check if there is not a current TX/RX job running
    if (LMIC.opmode & OP_TXRXPEND) {
        Serial.println(F("OP_TXRXPEND, not sending"));
    } else {
        // Prepare upstream data transmission at the next possible time.
        LMIC_setTxData2(1, mydata, sizeof(mydata)-1, 0);
        Serial.println(F("Packet queued"));
    }
    // Next TX is scheduled after TX_COMPLETE event.
}

void setup() {
    Serial.begin(9600);
    Serial.println(F("Starting"));

    #ifdef VCC_ENABLE
    // For Pinoccio Scout boards
    pinMode(VCC_ENABLE, OUTPUT);
    digitalWrite(VCC_ENABLE, HIGH);
    delay(1000);
    #endif

    // LMIC init
    os_init();
    // Reset the MAC state. Session and pending data transfers will be discarded.
    LMIC_reset();

    // Set static session parameters. Instead of dynamically establishing a session
    // by joining the network, precomputed session parameters are be provided.
    #ifdef PROGMEM
    // On AVR, these values are stored in flash and only copied to RAM
    // once. Copy them to a temporary buffer here, LMIC_setSession will
    // copy them into a buffer of its own again.
    uint8_t appskey[sizeof(APPSKEY)];
    uint8_t nwkskey[sizeof(NWKSKEY)];
    memcpy_P(appskey, APPSKEY, sizeof(APPSKEY));
    memcpy_P(nwkskey, NWKSKEY, sizeof(NWKSKEY));
    LMIC_setSession (0x1, DEVADDR, nwkskey, appskey);
    #else
    // If not running an AVR with PROGMEM, just use the arrays directly
    LMIC_setSession (0x1, DEVADDR, NWKSKEY, APPSKEY);
    #endif

    #if defined(CFG_eu868)
    // Set up the channels used by the Things Network, which corresponds
    // to the defaults of most gateways. Without this, only three base
    // channels from the LoRaWAN specification are used, which certainly
    // works, so it is good for debugging, but can overload those
    // frequencies, so be sure to configure the full frequency range of
    // your network here (unless your network autoconfigures them).
    // Setting up channels should happen after LMIC_setSession, as that
    // configures the minimal channel set.
    // NA-US channels 0-71 are configured automatically
    LMIC_setupChannel(0, 868100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
    LMIC_setupChannel(1, 868300000, DR_RANGE_MAP(DR_SF12, DR_SF7B), BAND_CENTI);      // g-band
    LMIC_setupChannel(2, 868500000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
    LMIC_setupChannel(3, 867100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
    LMIC_setupChannel(4, 867300000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
    LMIC_setupChannel(5, 867500000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
    LMIC_setupChannel(6, 867700000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
    LMIC_setupChannel(7, 867900000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
    LMIC_setupChannel(8, 868800000, DR_RANGE_MAP(DR_FSK,  DR_FSK),  BAND_MILLI);      // g2-band
    // TTN defines an additional channel at 869.525Mhz using SF9 for class B
    // devices' ping slots. LMIC does not have an easy way to define set this
    // frequency and support for class B is spotty and untested, so this
    // frequency is not configured here.
    #elif defined(CFG_us915)
    // NA-US channels 0-71 are configured automatically
    // but only one group of 8 should (a subband) should be active
    // TTN recommends the second sub band, 1 in a zero based count.
    // https://github.com/TheThingsNetwork/gateway-conf/blob/master/US-global_conf.json
    LMIC_selectSubBand(1);
    #endif

    // Disable link check validation
    LMIC_setLinkCheckMode(0);

    // TTN uses SF9 for its RX2 window.
    LMIC.dn2Dr = DR_SF9;

    // Set data rate and transmit power for uplink (note: txpow seems to be ignored by the library)
    LMIC_setDrTxpow(DR_SF7,14);

    // Start job
    do_send(&sendjob);
}

void loop() {
    os_runloop_once();
}

frag

arduino-lmic-matthijskooijman\src\lmic\config.h
#ifndef _lmic_config_h_
#define _lmic_config_h_

// In the original LMIC code, these config values were defined on the
// gcc commandline. Since Arduino does not allow easily modifying the
// compiler commandline, use this file instead.

#define CFG_eu868 1
//#define CFG_us915 1
// This is the SX1272/SX1273 radio, which is also used on the HopeRF
// RFM92 boards.
//#define CFG_sx1272_radio 1
// This is the SX1276/SX1277/SX1278/SX1279 radio, which is also used on
// the HopeRF RFM95 boards.
#define CFG_sx1276_radio 1

// 16 μs per tick
// LMIC requires ticks to be 15.5μs - 100 μs long
#define US_PER_OSTICK_EXPONENT 4
#define US_PER_OSTICK (1 << US_PER_OSTICK_EXPONENT)
#define OSTICKS_PER_SEC (1000000 / US_PER_OSTICK)

// Set this to 1 to enable some basic debug output (using printf) about
// RF settings used during transmission and reception. Set to 2 to
// enable more verbose output. Make sure that printf is actually
// configured (e.g. on AVR it is not by default), otherwise using it can
// cause crashing.
#define LMIC_DEBUG_LEVEL 0

// Enable this to allow using printf() to print to the given serial port
// (or any other Print object). This can be easy for debugging. The
// current implementation only works on AVR, though.
//#define LMIC_PRINTF_TO Serial

// Any runtime assertion failures are printed to this serial port (or
// any other Print object). If this is unset, any failures just silently
// halt execution.
#define LMIC_FAILURE_TO Serial

// Uncomment this to disable all code related to joining
//#define DISABLE_JOIN
// Uncomment this to disable all code related to ping
//#define DISABLE_PING
// Uncomment this to disable all code related to beacon tracking.
// Requires ping to be disabled too
//#define DISABLE_BEACONS

// Uncomment these to disable the corresponding MAC commands.
// Class A
//#define DISABLE_MCMD_DCAP_REQ // duty cycle cap
//#define DISABLE_MCMD_DN2P_SET // 2nd DN window param
//#define DISABLE_MCMD_SNCH_REQ // set new channel
// Class B
//#define DISABLE_MCMD_PING_SET // set ping freq, automatically disabled by DISABLE_PING
//#define DISABLE_MCMD_BCNI_ANS // next beacon start, automatical disabled by DISABLE_BEACON

// In LoRaWAN, a gateway applies I/Q inversion on TX, and nodes do the
// same on RX. This ensures that gateways can talk to nodes and vice
// versa, but gateways will not hear other gateways and nodes will not
// hear other nodes. By uncommenting this macro, this inversion is
// disabled and this node can hear other nodes. If two nodes both have
// this macro set, they can talk to each other (but they can no longer
// hear gateways). This should probably only be used when debugging
// and/or when talking to the radio directly (e.g. like in the "raw"
// example).
//#define DISABLE_INVERT_IQ_ON_RX

// This allows choosing between multiple included AES implementations.
// Make sure exactly one of these is uncommented.
//
// This selects the original AES implementation included LMIC. This
// implementation is optimized for speed on 32-bit processors using
// fairly big lookup tables, but it takes up big amounts of flash on the
// AVR architecture.
// #define USE_ORIGINAL_AES
//
// This selects the AES implementation written by Ideetroon for their
// own LoRaWAN library. It also uses lookup tables, but smaller
// byte-oriented ones, making it use a lot less flash space (but it is
// also about twice as slow as the original).
#define USE_IDEETRON_AES

#endif // _lmic_config_h_

If I did a mistake in the code above, can you show me where please?

I raised the debug level as suggested here. I’ve searched for this from beginning, to see more details.

More details in console:

Starting
RXMODE_RSSI
455: engineUpdate, opmode=0x808
1489: TXMODE, freq=867900000, len=26, SF=7, BW=125, CR=4/5, IH=0
Packet queued
65903: RXMODE_SINGLE, freq=867900000, SF=7, BW=125, CR=4/5, IH=0
128691: RXMODE_SINGLE, freq=869525000, SF=9, BW=125, CR=4/5, IH=0
129888: EV_TXCOMPLETE (includes waiting for RX windows)
132356: engineUpdate, opmode=0x900
3882359: engineUpdate, opmode=0x908
3883419: TXMODE, freq=868100000, len=26, SF=7, BW=125, CR=4/5, IH=0
Packet queued
3948345: RXMODE_SINGLE, freq=868100000, SF=7, BW=125, CR=4/5, IH=0
4011133: RXMODE_SINGLE, freq=869525000, SF=9, BW=125, CR=4/5, IH=0
4012201: EV_TXCOMPLETE (includes waiting for RX windows)
4014799: engineUpdate, opmode=0x900
7764803: engineUpdate, opmode=0x908
7765858: TXMODE, freq=868300000, len=26, SF=7, BW=125, CR=4/5, IH=0
Packet queued
7830784: RXMODE_SINGLE, freq=868300000, SF=7, BW=125, CR=4/5, IH=0
7893572: RXMODE_SINGLE, freq=869525000, SF=9, BW=125, CR=4/5, IH=0
7894768: EV_TXCOMPLETE (includes waiting for RX windows)
7897367: engineUpdate, opmode=0x900
11647370: engineUpdate, opmode=0x908
11648426: TXMODE, freq=868500000, len=26, SF=7, BW=125, CR=4/5, IH=0
Packet queued
11713223: RXMODE_SINGLE, freq=868500000, SF=7, BW=125, CR=4/5, IH=0
11776011: RXMODE_SINGLE, freq=869525000, SF=9, BW=125, CR=4/5, IH=0
11777206: EV_TXCOMPLETE (includes waiting for RX windows)
11779936: engineUpdate, opmode=0x900

I’m quite sure LMIC (certainly the old one you’re using) wants LSB for OTAA, so maybe for ABP as well?

Why maybe? How about this for ABP? We are now testing ABP example.

// LoRaWAN NwkSKey, network session key
// This should be in big-endian (aka msb).
static const PROGMEM u1_t NWKSKEY[16] = { FILLMEIN };

// LoRaWAN AppSKey, application session key
// This should also be in big-endian (aka msb).
static const u1_t PROGMEM APPSKEY[16] = { FILLMEIN };