Getting LoRa (SX1278/XL1278-SMT) Working Via SPI on the WeMos D1 ESP-12F ESP8277 Motherboard Module With OLED

by cndg in Circuits > Arduino

9859 Views, 12 Favorites, 0 Comments

Getting LoRa (SX1278/XL1278-SMT) Working Via SPI on the WeMos D1 ESP-12F ESP8277 Motherboard Module With OLED

20181124_230938.jpg

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.

Check You've Got the Right Hardware

download.jpg
s-l1600.jpg

This Instructable is for using these above 2 things together.

Here Are Notes I Have Made About the Pinouts

Wemos_Battery_OLED_Board.jpg
D7D6D5.jpg
ESP8266_wiring.png

These Are the Pins You Need to Connect

LoRa WeMos D1.jpg

WeMos <=> LoRa

GND ---- GND

3V3 ---- VCC

D6* (io12) ----MISO

D7* (io13)----MOSI

D5* (io14)----SLCK

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]).

Set Up Your Arduino IDE Programming Environment

Screen Shot 2018-11-24 at 10.46.59 pm.png
Screen Shot 2018-11-24 at 10.47.56 pm.png
Screen Shot 2018-11-24 at 10.47.10 pm.png
Screen Shot 2018-11-24 at 10.48.41 pm.png
Screen Shot 2018-11-24 at 10.49.05 pm.png
Screen Shot 2018-11-24 at 10.46.00 pm.png
Screen Shot 2018-11-24 at 10.46.22 pm.png
Monitor.png

Ensure, in your preferences, you've got the "Additional Boards Manager URLs" including this:-

http://arduino.esp8266.com/stable/package_esp8266com_index.json

And ensure you have installed the Libs you need (see all the photos for how to do that)

​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.

Here Is How to Watch It Working!

Screen Shot 2018-11-24 at 10.46.39 pm.png
Monitor.png
pic 2018-11-24 23.06.47_06.png

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.

Enjoy!

Let me know if you have trouble or suggestions etc.