Hello,
I'm working on 5TE (DECAGON device for soil water content) with UNO. I can play one 5TE with UNO, which shows it works well. Now I want to connect two 5TE sensors to UNO. However it doesn't work. Only one line data was showed and then nothing appeared. The code is written below.
I also attaeced SDIserial library. Could you tell me why it doesn't work. Is that because I didn't set correct address?
Hope to get your kind reply
#include <SDISerial.h>
volatile int f_j=0;
char X='+';
int a[]={5,6};
String changer();
SDISerial sdi_serial_connection(a[f_j],a[f_j]); // SDISerial sdi_serial_connection(DATALINE_PIN,INVERTED);
char* get_measurement()
{
char* service_request = sdi_serial_connection.sdi_query("?M!",150);
//you can use the time returned above to wait for the service_request_complete
char* service_request_complete = sdi_serial_connection.wait_for_response(150);
//dont worry about waiting too long it will return once it gets a response
return sdi_serial_connection.sdi_query("?D0!",150);
}
void setup()
{
Serial.begin(57600);
sdi_serial_connection.begin();
delay(1000);
}
void loop()
{
while(f_j<2)
{
SDISerial sdi_serial_connection(a[f_j],a[f_j]);
char* response = get_measurement(); // get measurement data
String FTE=response;
char tmp1='+';
int tmp2=FTE.indexOf(tmp1);
while(tmp2!=1)
{
char* response = get_measurement(); // get measurement data
FTE=response;
tmp2=FTE.indexOf(tmp1);
}
Serial.print(a[f_j]);
Serial.print(" : ");
Serial.println(FTE);
f_j++;
delay(2000);
}
f_j=0;
delay(2000);
}
The SDISerial class has only one constructor. The first argument is the pin number that the instance is to be associated with. The second defines whether to use inverse logic, with respect to the pulses of the input pin.
Why are you calling it with the value of 5 (or 6) for the inverse_logic argument?
That is not how you would create two instances of the class to deal with the two pins.
Hi Pauls,
Thanks for your kind reply.
I test inverse with different numbers which showed on influence on the results.
Now I'm using two different libraries for two 5TE sensors. Each library works well respectively. However there are compiling error when libraries are combined. why do two libraries with the same function in different forms conflict?
You can check the code I attached.
Hope to hear from you soon.
#include <SDISerial1.h>
#include <SDISerial2.h>
SDISerial1 sdi_serial_connection1(6,1); // SDISerial sdi_serial_connection(DATALINE_PIN,INVERTED);
char* get_measurement1()
{
char* service_request = sdi_serial_connection1.sdi_query("?M!",150);
//you can use the time returned above to wait for the service_request_complete
char* service_request_complete = sdi_serial_connection1.wait_for_response(150);
//dont worry about waiting too long it will return once it gets a response
return sdi_serial_connection1.sdi_query("?D0!",150);
}
SDISerial2 sdi_serial_connection2(5,1); // SDISerial sdi_serial_connection(DATALINE_PIN,INVERTED);
char* get_measurement2()
{
char* service_request = sdi_serial_connection2.sdi_query("?M!",150);
//you can use the time returned above to wait for the service_request_complete
char* service_request_complete = sdi_serial_connection2.wait_for_response(150);
//dont worry about waiting too long it will return once it gets a response
return sdi_serial_connection2.sdi_query("?D0!",150);
}
void setup()
{
Serial.begin(57600);
sdi_serial_connection2.begin();
sdi_serial_connection1.begin();
delay(1000);
}
void loop()
{
char* response1 = get_measurement1(); // get measurement data
String FTE1=response1;
Serial.println(FTE1);
delay(2000);
char* response2 = get_measurement2(); // get measurement data
String FTE2=response2;
Serial.println(FTE2);
delay(2000);
}