Introduction: Getting LoRa (SX1278/XL1278-SMT) Working Via SPI on the WeMos D1 ESP-12F ESP8277 Motherboard Module With OLED
This took me a week to work out - it seems nobody else before me has figured it - so I hope this save you some time!
The awkwardly-named "WeMos D1 ESP-12F ESP8266 Motherboard Module with 0.96 inch OLED Screen" is an $11 development board that contains an ESP8266 Wifi board, a screen, a 5-postion switch, an 18650 Li-ion battery holder and charging circuit with protection, a usb power socket, switch, and serial programming setup.
That's a whole lot of awesome, in a cheap and handy board!
The SX1278 LoRa board is a $4 low power tiny radio, that can send and receive data over very long distances (purportedly 15km, but I read reports of 300+km from some people)
This shows you how to connect them both.
If you want to capture LoRa data and upload it to the internet, this is a $15 solution that's capable of running 24/7 from a solar panel.
Step 1: Check You've Got the Right Hardware
This Instructable is for using these above 2 things together.
Step 2: Here Are Notes I Have Made About the Pinouts
Step 3: These Are the Pins You Need to Connect
WeMos <=> LoRa
GND ---- GND
3V3 ---- VCC
D6* (io12) ----MISO
D8 (io15) ----NSS
D12* (io10) ---- DIO0
D4 (io2) ---- REST (optional - NB: D4 is wired to the blue LED)
* Note that you need to solder D5, D6, D7 and D12 onto the ESP8266 chip on the motherboard, because they have not broken out those pins for you to use on the WeMos D1 header.
NB: There is no possible other pins to use!! Most of the pins that are broken out for you (A0, D3, D4, D8, D9, and D10) will (if used) prevent your board from booting up [D10+-, D8+, D4-, D3-], or will block you from programming it [D9], or will prevent your serial monitor from working [D9, D10]).
Step 4: Set Up Your Arduino IDE Programming Environment
Ensure, in your preferences, you've got the "Additional Boards Manager URLs" including this:-
And ensure you have installed the Libs you need (see all the photos for how to do that)
Step 5: Here Is the Code to Make This Work!
Load this into your Arduino program. If you build 2 complete versions of these - and load the same code in both, you can watch them talking to each other using your Serial Monitor in the Arduino IDE.
Step 6: Here Is How to Watch It Working!
Open your serial monitor.
If you built 2 of these, and if the other one is already turned on an running (thus, it is sending LoRa packets to you), then you will see something like this:-
# /Users/cnd/cd/Downloads/Arduino/WeMos_D1_LoRaDuplexCallback/WeMos_D1_LoRaDuplexCallback.ino Nov 24 2018 22:08:41
LoRa Duplex with callback
LoRa init succeeded.
Rec from:0xbb to:0xff mID:15 l:26 Msg:LeLoRa World 12:40:59 5135 RSSI:-43 Snr:9.50 freqErr:-2239 rnd:18
ss Rec from:0xbb to:0xff mID:17 l:26 Msg:LeLoRa World 12:40:59 5137 RSSI:-50 Snr:10.00 freqErr:-2239 rnd:15
s Rec from:0xbb to:0xff mID:18 l:26 Msg:LeLoRa World 12:40:59 5138 RSSI:-49 Snr:9.25 freqErr:-2239 rnd:15
ss Rec from:0xbb to:0xff mID:19 l:26 Msg:LeLoRa World 12:40:59 5139 RSSI:-43 Snr:9.75 freqErr:-2239 rnd:16
s Rec from:0xbb to:0xff mID:20 l:26 Msg:LeLoRa World 12:40:59 5140 RSSI:-51 Snr:9.50 freqErr:-2239 rnd:17
s Rec from:0xbb to:0xff mID:21 l:26 Msg:LeLoRa World 12:40:59 5141 RSSI:-53 Snr:10.00 freqErr:-2239 rnd:24
You can leave this running, and take your other one for a run around the block, then come back later and put the numbers into a spreadsheet to see how many packets got lost, and how the signal strengths varied etc.
Step 7: Enjoy!
Let me know if you have trouble or suggestions etc.