Hello, I got my Heltec from aliexpress
and installed the lmic library according to this blog. I’m still not sure which exact heltecversion I got.
I used the following pin mapping:
// Pin mapping
const lmic_pinmap lmic_pins = {
.nss = 18,
.rxtx = LMIC_UNUSED_PIN,
.rst = 14,
.dio = {26, 33, 32},
};
After quite some time I got after the EV_JOINING
the message EV_JOIN_FAILED
Does this mean I do not have signal coverage, or is the pin mapping wrong? I installed the lmic from GitHub - matthijskooijman/arduino-lmic: ⚠ This library is deprecated, see the README for alternatives.
How could i further debug the problem?
Thanks for your help
⸮ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:808
load:0x40078000,len:6084
load:0x40080000,len:6696
entry 0x400802e4
RXMODE_RSSI
36654: engineUpdate, opmode=0x8
Packet queued
39383: EV_JOINING
45145: engineUpdate, opmode=0xc
286339: engineUpdate, opmode=0xc
286381: TXMODE, freq=868300000, len=23, SF=7, BW=125, CR=4/5, IH=0
599738: RXMODE_SINGLE, freq=868300000, SF=7, BW=125, CR=4/5, IH=0
665247: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
681656: engineUpdate, opmode=0xc
4460846: engineUpdate, opmode=0xc
4460881: TXMODE, freq=868500000, len=23, SF=7, BW=125, CR=4/5, IH=0
4774238: RXMODE_SINGLE, freq=868500000, SF=7, BW=125, CR=4/5, IH=0
4839746: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
4856154: engineUpdate, opmode=0xc
9079518: engineUpdate, opmode=0xc
9079552: TXMODE, freq=868100000, len=23, SF=8, BW=125, CR=4/5, IH=0
9396255: RXMODE_SINGLE, freq=868100000, SF=8, BW=125, CR=4/5, IH=0
9461635: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
9478042: engineUpdate, opmode=0xc
16679381: engineUpdate, opmode=0xc
16679416: TXMODE, freq=868300000, len=23, SF=8, BW=125, CR=4/5, IH=0
16996117: RXMODE_SINGLE, freq=868300000, SF=8, BW=125, CR=4/5, IH=0
17061497: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
17077905: engineUpdate, opmode=0xc
25045526: engineUpdate, opmode=0xc
25045560: TXMODE, freq=868500000, len=23, SF=9, BW=125, CR=4/5, IH=0
25368245: RXMODE_SINGLE, freq=868500000, SF=9, BW=125, CR=4/5, IH=0
25433433: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
25449845: engineUpdate, opmode=0xc
39321730: engineUpdate, opmode=0xc
39321764: TXMODE, freq=868100000, len=23, SF=9, BW=125, CR=4/5, IH=0
39644451: RXMODE_SINGLE, freq=868100000, SF=9, BW=125, CR=4/5, IH=0
39709639: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
39726047: engineUpdate, opmode=0xc
53267835: engineUpdate, opmode=0xc
53267869: TXMODE, freq=868300000, len=23, SF=10, BW=125, CR=4/5, IH=0
53601242: RXMODE_SINGLE, freq=868300000, SF=10, BW=125, CR=4/5, IH=0
53666046: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
53682454: engineUpdate, opmode=0xc
80288310: engineUpdate, opmode=0xc
80288345: TXMODE, freq=868500000, len=23, SF=10, BW=125, CR=4/5, IH=0
80621718: RXMODE_SINGLE, freq=868500000, SF=10, BW=125, CR=4/5, IH=0
80686522: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
80702930: engineUpdate, opmode=0xc
107275635: engineUpdate, opmode=0xc
107275670: TXMODE, freq=868100000, len=23, SF=11, BW=125, CR=4/5, IH=0
107638098: RXMODE_SINGLE, freq=868100000, SF=11, BW=125, CR=4/5, IH=0
107702135: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
107718543: engineUpdate, opmode=0xc
159483077: engineUpdate, opmode=0xc
159483112: TXMODE, freq=868300000, len=23, SF=11, BW=125, CR=4/5, IH=0
159845540: RXMODE_SINGLE, freq=868300000, SF=11, BW=125, CR=4/5, IH=0
159909577: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
159925984: engineUpdate, opmode=0xc
219817315: engineUpdate, opmode=0xc
219817350: TXMODE, freq=868500000, len=23, SF=12, BW=125, CR=4/5, IH=0
220222528: RXMODE_SINGLE, freq=868500000, SF=12, BW=125, CR=4/5, IH=0
220285028: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
220301436: engineUpdate, opmode=0xc
325144457: engineUpdate, opmode=0xc
325144491: TXMODE, freq=868100000, len=23, SF=12, BW=125, CR=4/5, IH=0
325549670: RXMODE_SINGLE, freq=868100000, SF=12, BW=125, CR=4/5, IH=0
325612170: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
325628579: EV_JOIN_FAILED
325636016: engineUpdate, opmode=0xc
420703267: engineUpdate, opmode=0xc
420703303: TXMODE, freq=868300000, len=23, SF=12, BW=125, CR=4/5, IH=0
421108482: RXMODE_SINGLE, freq=868300000, SF=12, BW=125, CR=4/5, IH=0
421170982: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
421187395: engineUpdate, opmode=0xc
520868426: engineUpdate, opmode=0xc
520868460: TXMODE, freq=868500000, len=23, SF=12, BW=125, CR=4/5, IH=0
521273639: RXMODE_SINGLE, freq=868500000, SF=12, BW=125, CR=4/5, IH=0
521336139: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
521352548: EV_JOIN_FAILED
521359991: engineUpdate, opmode=0xc
622308730: engineUpdate, opmode=0xc
622308767: TXMODE, freq=868100000, len=23, SF=12, BW=125, CR=4/5, IH=0
622713946: RXMODE_SINGLE, freq=868100000, SF=12, BW=125, CR=4/5, IH=0
622776446: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
622792854: engineUpdate, opmode=0xc
729429457: engineUpdate, opmode=0xc
729429492: TXMODE, freq=868300000, len=23, SF=12, BW=125, CR=4/5, IH=0
729834671: RXMODE_SINGLE, freq=868300000, SF=12, BW=125, CR=4/5, IH=0
729897171: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
729913580: EV_JOIN_FAILED
729921024: engineUpdate, opmode=0xc
837755367: engineUpdate, opmode=0xc
837755404: TXMODE, freq=868500000, len=23, SF=12, BW=125, CR=4/5, IH=0
838160582: RXMODE_SINGLE, freq=868500000, SF=12, BW=125, CR=4/5, IH=0
838223082: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
838239490: engineUpdate, opmode=0xc
935268860: engineUpdate, opmode=0xc
935268895: TXMODE, freq=868100000, len=23, SF=12, BW=125, CR=4/5, IH=0
935674074: RXMODE_SINGLE, freq=868100000, SF=12, BW=125, CR=4/5, IH=0
935736574: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
935752983: EV_JOIN_FAILED
935760423: engineUpdate, opmode=0xc
1030019765: engineUpdate, opmode=0xc
1030019801: TXMODE, freq=868300000, len=23, SF=12, BW=125, CR=4/5, IH=0
1030424981: RXMODE_SINGLE, freq=868300000, SF=12, BW=125, CR=4/5, IH=0
1030487481: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
1030503890: engineUpdate, opmode=0xc
1131636784: engineUpdate, opmode=0xc
1131636819: TXMODE, freq=868500000, len=23, SF=12, BW=125, CR=4/5, IH=0
1132041998: RXMODE_SINGLE, freq=868500000, SF=12, BW=125, CR=4/5, IH=0
1132104498: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
1132120907: EV_JOIN_FAILED
1132128559: engineUpdate, opmode=0xc
1239266735: engineUpdate, opmode=0xc
1239266772: TXMODE, freq=868100000, len=23, SF=12, BW=125, CR=4/5, IH=0
1239671951: RXMODE_SINGLE, freq=868100000, SF=12, BW=125, CR=4/5, IH=0
1239734451: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
1239750863: engineUpdate, opmode=0xc
1344446347: engineUpdate, opmode=0xc
1344446381: TXMODE, freq=868300000, len=23, SF=12, BW=125, CR=4/5, IH=0
1344851561: RXMODE_SINGLE, freq=868300000, SF=12, BW=125, CR=4/5, IH=0
1344914061: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
1344930470: EV_JOIN_FAILED
1344938122: engineUpdate, opmode=0xc
1446683767: engineUpdate, opmode=0xc
1446683804: TXMODE, freq=868500000, len=23, SF=12, BW=125, CR=4/5, IH=0
1447088984: RXMODE_SINGLE, freq=868500000, SF=12, BW=125, CR=4/5, IH=0
1447151484: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
1447167892: engineUpdate, opmode=0xc
1545000557: engineUpdate, opmode=0xc
1545000591: TXMODE, freq=868100000, len=23, SF=12, BW=125, CR=4/5, IH=0
1545405771: RXMODE_SINGLE, freq=868100000, SF=12, BW=125, CR=4/5, IH=0
1545468271: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
1545484680: EV_JOIN_FAILED
1545492332: engineUpdate, opmode=0xc
Here the arduino code:
#include <lmic.h>
#include <hal/hal.h>
#include <SPI.h>
#include <U8x8lib.h>
#define BUILTIN_LED 25
// the OLED used
U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ 15, /* data=*/ 4, /* reset=*/ 16);
// This EUI must be in little-endian format, so least-significant-byte
// first. When copying an EUI from ttnctl output, this means to reverse
// the bytes. For TTN issued EUIs the last bytes should be 0xD5, 0xB3,
// 0x70.
// Set your AppEUI and AppKey
//appEui = "70 B3 D5 7E D0 01 3B 72";
static const u1_t PROGMEM APPEUI[8] = { 0x72, 0x3B, 0x01, 0xD0, 0x7E, 0xD5, 0xB3, 0x70 };
void os_getArtEui (u1_t* buf) {
memcpy_P(buf, APPEUI, 8);
}
//01 23 45 67 89 AA BB CC
// This should also be in little endian format, see above.
static const u1_t PROGMEM DEVEUI[8] = { 0xCC, 0xBB, 0xAA, 0x89, 0x67, 0x45, 0x23, 0x01 };
void os_getDevEui (u1_t* buf) {
memcpy_P(buf, DEVEUI, 8);
}
// This key should be in big endian format (or, since it is not really a
// number but a block of memory, endianness does not really apply). In
// practice, a key taken from ttnctl can be copied as-is.
// The key shown here is the semtech default key.
// appKey = "D9 EB BB 95 63 FC 98 E2 87 5A 67 04 20 09 53 3A";
static const u1_t PROGMEM APPKEY[16] = { 0xD9, 0xEB, 0xBB, 0x95, 0x63, 0xFC, 0x98, 0xE2, 0x87, 0x5A, 0x67, 0x04, 0x20, 0x09, 0x53, 0x3A };
void os_getDevKey (u1_t* buf) {
memcpy_P(buf, APPKEY, 16);
}
static uint8_t mydata[] = "Hi";
static osjob_t sendjob;
// Schedule TX every this many seconds (might become longer due to duty
// cycle limitations).
const unsigned TX_INTERVAL = 30;
// Pin mapping
const lmic_pinmap lmic_pins = {
.nss = 18,
.rxtx = LMIC_UNUSED_PIN,
.rst = 14,
.dio = {26, 33, 32},
};
void onEvent (ev_t ev) {
Serial.print(os_getTime());
u8x8.setCursor(0, 5);
u8x8.printf("TIME %lu", os_getTime());
Serial.print(": ");
u8x8.clearLine(7);
switch (ev) {
case EV_SCAN_TIMEOUT:
Serial.println(F("EV_SCAN_TIMEOUT"));
u8x8.drawString(0, 7, "EV_SCAN_TIMEOUT");
break;
case EV_BEACON_FOUND:
Serial.println(F("EV_BEACON_FOUND"));
u8x8.drawString(0, 7, "EV_BEACON_FOUND");
break;
case EV_BEACON_MISSED:
Serial.println(F("EV_BEACON_MISSED"));
u8x8.drawString(0, 7, "EV_BEACON_MISSED");
break;
case EV_BEACON_TRACKED:
Serial.println(F("EV_BEACON_TRACKED"));
u8x8.drawString(0, 7, "EV_BEACON_TRACKED");
break;
case EV_JOINING:
Serial.println(F("EV_JOINING"));
u8x8.drawString(0, 7, "EV_JOINING");
break;
case EV_JOINED:
Serial.println(F("EV_JOINED"));
u8x8.drawString(0, 7, "EV_JOINED ");
// Disable link check validation (automatically enabled
// during join, but not supported by TTN at this time).
LMIC_setLinkCheckMode(0);
break;
case EV_RFU1:
Serial.println(F("EV_RFU1"));
u8x8.drawString(0, 7, "EV_RFUI");
break;
case EV_JOIN_FAILED:
Serial.println(F("EV_JOIN_FAILED"));
u8x8.drawString(0, 7, "EV_JOIN_FAILED");
break;
case EV_REJOIN_FAILED:
Serial.println(F("EV_REJOIN_FAILED"));
u8x8.drawString(0, 7, "EV_REJOIN_FAILED");
//break;
break;
case EV_TXCOMPLETE:
Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
u8x8.drawString(0, 7, "EV_TXCOMPLETE");
digitalWrite(BUILTIN_LED, LOW);
if (LMIC.txrxFlags & TXRX_ACK) {
Serial.println(F("Received ack"));
u8x8.drawString(0, 7, "Received ACK");
}
if (LMIC.dataLen) {
Serial.println(F("Received "));
u8x8.drawString(0, 6, "RX ");
Serial.println(LMIC.dataLen);
u8x8.setCursor(4, 6);
u8x8.printf("%i bytes", LMIC.dataLen);
Serial.println(F(" bytes of payload"));
u8x8.setCursor(0, 7);
u8x8.printf("RSSI %d SNR %.1d", LMIC.rssi, LMIC.snr);
}
// Schedule next transmission
os_setTimedCallback(&sendjob, os_getTime() + sec2osticks(TX_INTERVAL), do_send);
break;
case EV_LOST_TSYNC:
Serial.println(F("EV_LOST_TSYNC"));
u8x8.drawString(0, 7, "EV_LOST_TSYNC");
break;
case EV_RESET:
Serial.println(F("EV_RESET"));
u8x8.drawString(0, 7, "EV_RESET");
break;
case EV_RXCOMPLETE:
// data received in ping slot
Serial.println(F("EV_RXCOMPLETE"));
u8x8.drawString(0, 7, "EV_RXCOMPLETE");
break;
case EV_LINK_DEAD:
Serial.println(F("EV_LINK_DEAD"));
u8x8.drawString(0, 7, "EV_LINK_DEAD");
break;
case EV_LINK_ALIVE:
Serial.println(F("EV_LINK_ALIVE"));
u8x8.drawString(0, 7, "EV_LINK_ALIVE");
break;
default:
Serial.println(F("Unknown event"));
u8x8.setCursor(0, 7);
u8x8.printf("UNKNOWN EVENT %d", ev);
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"));
u8x8.drawString(0, 7, "OP_TXRXPEND, not sent");
} else {
// Prepare upstream data transmission at the next possible time.
LMIC_setTxData2(1, mydata, sizeof(mydata) - 1, 0);
Serial.println(F("Packet queued"));
u8x8.drawString(0, 7, "PACKET QUEUED");
digitalWrite(BUILTIN_LED, HIGH);
}
// Next TX is scheduled after TX_COMPLETE event.
}
void setup() {
Serial.begin(115200);
u8x8.begin();
u8x8.setFont(u8x8_font_chroma48medium8_r);
u8x8.drawString(0, 1, "LoRaWAN LMiC");
SPI.begin(5, 19, 27);
// LMIC init
os_init();
// Reset the MAC state. Session and pending data transfers will be discarded.
LMIC_reset();
// This tells LMIC to make the receive windows bigger, in case your clock is 1% faster or slower.
LMIC_setClockError(MAX_CLOCK_ERROR * 1 / 100);
// Start job (sending automatically starts OTAA too)
do_send(&sendjob);
pinMode(BUILTIN_LED, OUTPUT);
digitalWrite(BUILTIN_LED, LOW);
}
void loop() {
os_runloop_once();
}