As I mentioned in my previous post, I also had a number of software issues to sort out before my ESP+RFM95 node worked. Here is a step-by-step guide of the steps I was able to reproduce to get a working node.
Go to https://github.com/things4u/LoRa-Thing and download zip file.
Unzip.
Copy “esp-lmic-v1.5” to your Arduino sketch folder.
Copy “libraries/base64” to the libraries folder in your Arduino sketch folder.
Go to https://github.com/tftelkamp/arduino-lmic-v1.5 and download zip file.
Unzip.
Copy folder to the libraries folder in your Arduino sketch folder.
Inside this folder go to src/lmic/config.h
and comment out line 10 (//#define CFG_sx1272_radio 1
) and uncomment line 11 (#define CFG_sx1276_radio 1
).
Open Arduino IDE 1.6.7
Go to Tools, Board, Boards Manager. Install “esp8266 by ESP8266 Community”.
(Arduino IDE may need a restart)
Go to Tools, Board and choose Generic ESP8266 module
Open esp-lmic-v1.5.ino from the folder which you copied to your Arduino sketch folder in the first step.
Comment out line 32: //#include <ESP.h>
Line 33 should not start with a capital letter: #include <base64.h>
Change line 59 to your device address.
The sketch should now compile without errors.
Follow the procedure in my previous post to program and reset the ESP8266 module.
If you open the Arduino serial monitor at 115200, you should see the following messages (or similar) after a couple of seconds:
Starting
os_init() finished
LMIC_reet() finished
LMIC_setSession() finished
LMICsetAddrMode() finished
Init done
Time: 21
Send, txCnhl: 0
Opmode check: ok
Event EV_TXCOMPLETE, time: 34
After about two minutes you should see the following text (or similar) appear:
Time: 141
Send, txCnhl: 7
Opmode check: ok
Event EV_TXCOMPLETE, time: 154
Every two minutes a packet is sent to TTN. You can check on the TTN API if this is the case.
Some observations and guesses why the code does not work out of the box:
- It seems like there are multiple Arduino libraries for the ESP family of modules. I chose the one that is listed in the boards manager, as it is the easiest to find/install/update and thus the most likely one for a beginner to use. The original author of the esp-lmic example sketch likely used a different version, and therefore had to include
ESP.h
. - There are numerous LMIC libraries around. I tested quite a few, but the only one I could get to compile was the one linked to in step 2. Some of the newer versions of the library does not handle the ESP correctly in their precompiler directives. Some are also using a different ESP-Arduino library.