The code - JosephThomasGit/Arduino-SDI-12-sensor-reading-with-LoRa-transmission GitHub Wiki

Libraries

For this project I needed to use two primary Arduino libraries, one to read the SDI-12 data and the other to transmit the data via LoRa to the reciever.

SDI-12 (SDI12.h)

The best (maybe the only) Arduino library for SDI-12 sensors was created and is maintained by EnviroDIY (located here). One common issue with this library though is that it interferes with any other library that uses interrupts, something that many different libraries use (including some LoRa libraries). This made the project a lot trickier and forced me to pair down the shields I have hoped to connect to simply the LoRa shield. Importantly though! EnviroDIY has created their own Arduino type controller called the Mayfly that can help you get around these issues and incorporate more components (it's also just a great little board).

LoRa (LoRa.h)

While there are several LoRa libraries out there, some that are simple and some that are complex and incorporate LoRaWAN, the one that I chose for this project was the LoRa.h library. One of the key reasons I selected this library (and not the RadioHead one), is because it doesn't have as many interrupt issues (you can turn on and off the interrupts), resulting in far fewer code lockups when combined with the SDI-12 library. Additionally, LoRa.h allows you to send a string as a LoRa message (the string doesn't need to be converted in a char array first) which makes the code even simpler and saves you a step or two. One thing about this library though is that it is very basic. There is no addressing, no encryption built in, you are only sending raw radio packets out, which may or may not work for your specific design.

Node

The node is the fundamental component of the LoRa telemetry system. Nodes collect data and send it over LoRa to gateways (they can also receive data from gateways in more complex LoRa designs).

Check out the node sketch in the repository to see the actual code.