Can't upload LMIC example code for ESP8266

Hi,
I’m a beginner at Lora. I got started by using the LMIC library and RFM95 module for testing. I changed some necessary parameters that are respective to my project ( include TTN information like DevEUI, APPEUI, APPKEY, and pins adjustment of NSS,…). I followed the connecting diagram as the image below. The problem came when uploading code for ESP, It continued showing up a window alarming that:
warning: espcomm_sync failed
An error occurred while uploading the sketch
error: espcomm_open failed
error: espcomm_upload_mem failed
I tried uploading without connecting to the Lora module and It was successful but when I reconnected it, It failed with an error was:
ets Jan 8 2013,rst cause:4, boot mode:(1,4)

wdt reset
I really have no idea what the reason was. What should I do with this problem? Anyhelp would be appreciated.
pin

You might want to recheck the pins in use from that diagram - there are two SPI buses on the NodeMCU and D4 isn’t used for either of them.

1 Like

Might want to take another look: D4 is not being used for SPI in the asker’s diagram, but rather as a generic GPIO to interface one of the DIO status pins of the radio.

And anyway, even unworkable pin choices wouldn’t prevent downloading or boot, but only lead to problems with subsequent operation.

Only things that caused issues for power, boot state, or serial communication would cause the reported problem. It’s not evident any of the shown connections should. Edit: comparison with the ESP8266 docs would suggest that “D4” is one of these pins.

1 Like

D8 controls uart0 RTS, so having it connected may affect flashing because firmware arrives via uart0.

Try disconnecting each pin one by one and check when you can upload code again. Try erasing flash as well. I would start with disconnection D0 and D4. I had trouble using D4 since it needs to be in a certain state when booting.

1 Like

Thanks for all your help. I tried releasing D0 and D4 pin when uploading and it worked. It seems to be caused by the need for a certain state of D0 and D4 pin like above answer. However, when i reconnected these two pins after uploading, it came with another error shown on monitor was:

ets Jan 8 2013,rst cause:4, boot mode:(3,6)

wdt reset
*load 0x4010f000, len 1384, room 16 *
tail 8
chksum 0x2d
csum 0x2d
v951aeffa
~ld
Starting
*FAILURE *
C:\Users\Admin\Documents\Arduino\libraries\MCCI_LoRaWAN_LMIC_library\src\lmic\oslmic.c:53
What does this error mean? How can i fix it? Thanks in advance.

I think it means the connection with the RFM95 could not be successfully established. Double check your pin mapping.
Correct me if I am wrong.

Maybe you’re right. Forget to tell that I also encountered this warning:
#pragma message(“Board not supported – use an explicit pinmap”)
when attempting to compile. I think it doesn’t matter so I just ignore it and upload. Then, it failed as you see.

Anyone here used to work on Lora with ESP could help me? Many thanks.

So connect RFM95w DIO0 to NodeMCU D1, RFM95w DIO1 to NodeMCU D2 and keep RFM95w RESET to NodeMCU D0. Then define this pinmap:

const lmic_pinmap lmic_pins = {
  .nss = 15, // Make D8/GPIO15, is nSS on ESP8266
  .rxtx = LMIC_UNUSED_PIN,      // Not needed
  .rst = 16, // Connect to esp8266 RST, or Make D0/GPIO16
  .dio = {5, 4, LMIC_UNUSED_PIN},   // D1/GPIO5; D2/GPIO4, when D4 is actually connected, ESP won't boot
};

And try again.

Thanks. I followed your instruction but it came back to the previous result:
ets Jan 8 2013,rst cause:4, boot mode:(1,7)

wdt reset
I’m considering changing to another mcu because I intend to use D1, D2 for my own purpose. Thanks for your kind.

You should see the ESP8266 documentation on boot mode pins.

You’ll unfortunately then have to translate that through the Arduino pin scheme (which if I recall might have similar nomenclature but mismatch what’s printed on the board silkscreen, as the board isn’t designed for Arduino).

Then pick you DIO pins from whatever pins do not have a role in determining boot mode. As far as LMiC is concerned these can be any available pins, as long as the software selection and wiring match. As far as the ESP8266 is concerned, they need to be pin usages (or at least levels - but how would you ensure that - the ESP8266 could reset while the radio retains state) which do not cause the wrong boot mode…

1 Like