Hi Guys:
I have several sesonsors SRS from Decagon Devices. This kind of sensors can comunicate using SDI-12 protocol. Ok. I download a library about SDI-12.
This is my code:
#include <SDISerial.h>
#define defino_pin_n2 2
#define INVERTED 1
SDISerial mi_sensor_n2(defino_pin_n2, INVERTED);
char* tomar_medida_n2(){
char* id_sensor = mi_sensor_n2.sdi_query("?M!",1000);//El comando ?M!, genera la dirección o id del sensor
char* mi_sensor_n2_leido = mi_sensor_n2.wait_for_response(1000);
return mi_sensor_n2.sdi_query("?D0!",1000); //El comando ?D0!, toma la medida de los sensores
}
void setup(){
mi_sensor_n2.begin();
Serial.begin(9600); // start our uart
Serial.println("Progra inicializado");
delay(3000);
}
void loop(){
char* lectura_sensor = tomar_medida_n2();
Serial.print(millis()/1000);
Serial.print(";");
Serial.println(lectura_sensor); //just a debug print statement to the serial port
delay(5000);
}
When I execute the code everything it’s ok. However, when program show data sometimes (watch image attached just read adress from sensor) showing a unique value. This is a proble because if I need a data every 20 seconds for example and the program just give me the adress I’m losting a value. Anybody can help me please?