Always helpful to tell the forum which Arduino you are using and to provide a connection diagram ...................................
So I will guess because of this line assigning pin 53;
#define DATA_PIN 53 /*!< The pin of the SDI-12 data bus */
Your using a Mega 2560 maybe ?
In which case if you look at a pinout diagram you will see pin 53 on a Mega is the default SS pin used by the SPI library ........ so try a different pin for your SDI-12
However, the 50+ Pins from my Mega didn't worked. So I changed the Sender to a Uno as well.
Any Uno Pin is available for SDI12 , sparing the Draguino Pins of coarse.
Now it works. But I don't know why.
I think srnet, you are wright, but what was the exact Problem eliminating the SPI Library?
#include <SDI12.h>
//#include <SPI.h>
#include <LoRa.h>
#define DATA_PIN 4 /*!< The pin of the SDI-12 data bus */
#define POWER_PIN -1
#define SENSOR_ADDRESS 0
int counter = 0;
/** Define the SDI-12 bus */
SDI12 mySDI12(DATA_PIN);
void setup()
{
Serial.begin(9600);
while (!Serial);
Serial.println("LoRa Sender");
if (!LoRa.begin(915E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
Serial.println("Opening SDI-12 bus...");
mySDI12.begin();
delay(500); // allow things to settle
}
void loop()
{
String myData = daten();
Serial.println(myData);
Serial.println(counter);
// send packet
LoRa.beginPacket();
LoRa.print(myData);
LoRa.print(counter);
LoRa.endPacket();
counter++;
delay(5000);
}
//Funktion Sensor daten SDI 12 5TM---------------------------------------------------------------------
String daten() {
String dataString;
mySDI12.sendCommand("0M!");
delay(500);
mySDI12.clearBuffer();
//Command Read
mySDI12.sendCommand("0D0!");
delay(500);
// build response string
while (mySDI12.available()) {
char c = mySDI12.read();
if ((c != 45) && (c != 43)) {
dataString += c;
delay(10); // 1 character ~ 7.5ms
}
else {
dataString += ";";
dataString += c;
}
}
mySDI12.clearBuffer();
if (dataString.length() > 1){
return dataString;
}
}