#include <SDI12.h>
#define SERIAL_BAUD 115200 /*!< The baud rate for the output serial port */
#define DATA_PIN 7 /*!< The pin of the SDI-12 data bus */
#define POWER_PIN 22 /*!< The sensor power pin (or -1 if not switching power) */
#define DATA_PIN1 8 /*!< The pin of the SDI-12 data bus */
String myCommand = "?I!";
SDI12 mySDI12(DATA_PIN);
SDI12 mySDI12(DATA_PIN1);
void setup() {
// put your setup code here, to run once:
Serial.begin(SERIAL_BAUD);
while (!Serial)
;
Serial.println("Opening SDI-12 bus...");
mySDI12.begin();
delay(500); // allow things to settle
// Power the sensors;
if (POWER_PIN > 0) {
Serial.println("Powering up sensors...");
pinMode(POWER_PIN, OUTPUT);
digitalWrite(POWER_PIN, HIGH);
delay(200);
}
}
void loop() {
// put your main code here, to run repeatedly:
mySDI12.sendCommand(myCommand);
delay(300); // wait a while for a response
while (mySDI12.available()) { // write the response to the screen
Serial.write(mySDI12.read());
}
delay(3000); // print again in three seconds
}