Node with ESP8266 and RFM95W

Just got the things4u esp8266 sketch working with the Modtronix inair9b here in US915 land, with an esp8266-03 (NOT recommended, just what I had laying around while the Wemos D1 mini is on order) - which took a bit of a hardware trick to use GPIO0&2 for DIO0&1 - namely, power on with GPIO0&2 disconnected, then plug it into DIO0&1, believe it or not that works!

Next, it looks like the LMiC library starts from a random channel 0 thru 63 (902.3 + chnl*0.2 MHz) and walks up to 63 then starts over from 0. Just stuck a horrible hack in lmic.cpp to fix it on channel 57 (913.7) - well, after the first transmission on channel 0, then update my single channel gateway and the temperature node.

Now TTN REST reports:
“data_plain”: “Hello ESP8266 world!”

Learning LoRaWAN and LMiC is going to take me a while :frowning:

You could also add a loop in your own sketch, calling LMIC_disableChannel(i).

(And remember, for a real node, don’t send text.)

In my previous post about the software setup to program an ESP8266, I missed one step.

After installing the Arduino IDE, you have to go to File->Preferences, and next to Additional Boards Manager URLs, add the following URL: http://arduino.esp8266.com/staging/package_esp8266com_index.json

Now in Tools -> Board: -> Boards Manager, search for ESP, and choose to install esp8266 by ESP8266 Community version 2.2.0-rc1


Another issue I encountered was that my ESP module constantly crashed with an exception:

Exception (3):
epc1=0x401003e9 epc2=0x00000000 epc3=0x00000000 excvaddr=0x400248c9 depc=0x00000000

Which translated to:

calloc at /opt/arduino-1.6.7/hardware/esp8266com/esp8266/cores/esp8266/umm_malloc/umm_malloc.c line 1682

After a very long search I found a sollution that worked: http://wifiesp.com/?p=14

Basically I had to add this block of code at the start of my setup function:

uint16_t s,res;

os_printf("Erasing sectors\n");
for (s=0x70;s<=0x7F; s++)
{
  res = spi_flash_erase_sector(s);
  os_printf("Sector erased 0x%02X. Res %d\n",s,res);
}
2 Likes

I just found these 2 items. They look like a match made in heaven (for this particular topic).
Does anyone have experience with this combination?

It is a ESP8266 in an Arduino formfactor with an Arduino-Lora-module.

A combination of:


(the version on Ali is already a newer version mine is 1.1)

Anyone?

1 Like

I was lucky enough to receive the first revision of the Dragino LoRa board: it simply works.

As it is basically an RFM95 breakout it should work together with the ESP, you might want to consider the V1.2 board as that is more flexible w.r.t. the breakouts. It was revised based on inputs from people on this forum to make it more flexible see the dragino wiki for the difference in appearance.

For ESP8266 LMIC stack see messages above.

That actually didn’t work for me.

Huh, turns out the lmic.cpp LMIC_disableChannel(u1_t channel) for CFG_us915 I got from https://github.com/things4u/LoRa-Thing/tree/master/libraries/lmic-v1.5 is broken - for

struct lmic_t {
#elif defined(CFG_us915)
u2_t channelMap[(72+MAX_XCHANNELS+15)/16]; // enabled bits

that should be an array of 5 16 bit values (80 bits, to cover 74 total channels), which when initialized is:
LMIC.channelMap[0] = 0xFFFF 16
LMIC.channelMap[1] = 0xFFFF 32
LMIC.channelMap[2] = 0xFFFF 48
LMIC.channelMap[3] = 0xFFFF 64
LMIC.channelMap[4] = 0x00FF 72 bits

However, LMIC_disableChannel() for CFG_us915 is modulo 4???
LMIC.channelMap[channel/4] &= ~(1<<(channel&0xF));

should be 16. As it is, when you disable channel 4, you actually get 20!
4: channelMap[0]: ffff
channelMap[1]: ffef 1110 1111 wtf??

LMIC_disableChannel(8) turns off the bit for 40, etc. Changed it to:

LMIC.channelMap[channel/16] &= ~(1<<(channel&0xF));

in my little test file and got expected results - will try it out in the actual code later tonight.

See also Matthijs’ version, which also has some more documentation.

Verified it came from IBM like that! http://www.research.ibm.com/labs/zurich/ics/lrsc/lmic.html

Pretty sure that’s a bug from the source.

has the same bug:

void LMIC_disableChannel (u1_t channel) {
if( channel < 72+MAX_XCHANNELS )
LMIC.channelMap[channel/4] &= ~(1<<(channel&0xF));
}

That 4 should be a 16 to get the right byte of the array - only affects CFG_us915.

4 Likes

It looks like the 6 pin connector of the Lora shield might be right on top of the ESP module. Is that an issue or do the boards fit nicely?

Hi Jac,

You are right the connector for SPI is directly above (2mm) the ESP-antenna but they fit nicely.
It seems that I have to do a little bit resoldering of a few “jumpers” ( I have version 1.1 of the Dragino Board so no nice jumpers -bought it 6 weeks ago-)… but then it should fit the Wemos D1 like a glove.

I am taking small steps and at this moment I am trying to test the Dragino with an Arduino Uno first (afterwards I will resolder the jumpers on the Dragino)…

1 Like

Verified - fixed /4 changed to /16 in LMIC_disableChannel() for CFG_us915 and now it works, only sends on my single channel gateway frequency of 913.7:


Disabling channel: 53
Disabling channel: 54
Disabling channel: 55
Disabling channel: 56
Disabling channel: 58
Disabling channel: 59
Disabling channel: 60
Disabling channel: 61
Disabling channel: 62
Disabling channel: 63
Disabling channel: 64
Disabling channel: 65
Disabling channel: 66
Disabling channel: 67
Disabling channel: 68
Disabling channel: 69
Disabling channel: 70
Disabling channel: 71
Disabling channel: 72
Init done
Time: 0
Send, txCnhl: 0
Opmode check: ok
Event EV_TXCOMPLETE, time: 10
Time: 30
Send, txCnhl: 57
Opmode check: ok
Event EV_TXCOMPLETE, time: 40
Time: 60
Send, txCnhl: 57
Opmode check: ok
Event EV_TXCOMPLETE, time: 70
Time: 90
Send, txCnhl: 57
Opmode check: ok
Event EV_TXCOMPLETE, time: 101
Time: 120
Send, txCnhl: 57
Opmode check: ok

Thanks!

1 Like

This seems promissing:


(very small form-factor ESP-Wemos)

Made a shield for the ESP dev Board with the RFM module. Have some testing and soldering to do but should come in handy for small nodes.


1 Like

NICE!
(it is this one: http://www.aliexpress.com/item/ESP8266-serial-WIFI-Witty-cloud-Development-Board-ESP-12F-module-MINI-nodemcu/32566502491.html )

Yep is the same.

Hi all,

Tested the shield and works ok. Made it available on Oshpark. Shield can be used with ESP dev board. Needs two 8pin single row headers (not the ones on the picture;) 8pin headers and a 10K resistor.


Greets,

Ewoud

4 Likes

Hi guys,
I see some reference to my github here, I’m glad of your intereset
For those interested I also done a WeMos ESP8266 shield for Microchip LoraWan RN2483 and WiFi terminal to talk to RN2483
You’ll find information here;
github board shield : https://github.com/hallard/WeMos-RN2483
github firmware Serial/Proxy with websocket en HTML Terminal https://github.com/hallard/WebSocketToSerial

And screenshot of whole working from browser

4 Likes

cswiger: Interested in your use of the inAir9b and WeMos D1. I have almost the same hardware but I can’t get it to work properly. The setup won’t boot up with CS connected to SS (GPIO15) on WeMos D1 R2 board. I can get it to boot up with inAir9b unplugged, When it is booted up the plug the inAri9b in and with works.
If I have CS connected to inAir9b then is doesn’t start at all, doesn’t matter what GPIO0&2 are doing.
Did you get this working with your WeMos D1 mini?
Can’t get even the simple Blinky program to work with the inAir9b plugged in with GPIO15 connected.
Anyone got an idea what the problem might be?

I think GPIO15 must be pulled low at startup…
(use pulldown resistor?)