1

Arduino library source: https://github.com/joranbeasley/SDISerial

The problem I'm having is when I'm trying to get the measurement from sensor using SDI12 I only receive first digit which is channel number of the device.

This is how it should work:

Master: 1M! (Measure)
Sonde: 10617[CR][LF] (ch1, 061s to measure,7 sensors).
Sonde: 1[CR][LF] (Measurement ready)
Master: 1D0! (Send data)
Sonde: 1+17.5+12.05+98.7+8.25+6.45[CR][LF]
Master: 1D1! (Send rest of the data)
Sonde: 1-325+10[CR][LF]

The only thing I'm receiving after 1D0! command is "1". I think that it must be because of the + - operator in the measurement data device sends (1+17.5+12.05+98.7+8.25+6.45). I've tried to understand the library code (.cpp and .h), but had no luck with solving this problem. Any thoughts on how this could be fixed?

Arduino code:

#define DATALINE_PIN 2
#define INVERTED 1
#define MAX_TIMEOUT 1000
//see:   http://arduino.cc/en/Reference/attachInterrupt
//for pins that support interupts (2 or 3 typically)


SDISerial connection(DATALINE_PIN, INVERTED);
char b_in[125];
char output_buffer[255];
char tmp_buffer[10];


void wait_for_message(char* buffer,char terminal){
   Serial.println("Waiting For input...");
   int i=0;
   while( true){
     if(!Serial.available())delay(500);
     else{
        buffer[i] = Serial.read();
        if(buffer[i] == terminal){
          buffer[i+1] = '\0';
          return;
        }
        i+=(buffer[i] >= 32 && buffer[i] <= 127);
     } 
   }
   
}

void setup(){
   Serial.begin(9600);
   connection.begin();
   delay(1000);
   Serial.println("Initialization Complete");
   
}
void loop(){

   wait_for_message(b_in,'!');
   sprintf(output_buffer,"[out]:%s",b_in?b_in:"No Output");
   
   Serial.println(output_buffer);
   
   char *response =connection.sdi_query(b_in,MAX_TIMEOUT);
   
   //sprintf(output_buffer,"[in]:%s",response?response:"No Response");
   Serial.println(response);
   Serial.flush();
   delay(1000);
   
}
Ant
  • 11
  • 3
  • what device is this? I have only tested that with Decagon/Meter Group sensors, which also contain the + and - symbols, so i dont think that is the issue ... is it possible you need to wait longer? or is it possible you are getting just the second 1 from the M! command? – Joran Beasley Oct 30 '20 at 19:05
  • 1
    After trying to make it work for many hours I finally made it work, the problem was not in the code or library.. Every time YSI Sonde attempted to make the measurement is switched off and back on this is why I got only 1 and it switched off because of the empty batteries. lol. Thank you for this amazing library! – Ant Oct 31 '20 at 07:43
  • glad to hear it worked out :) – Joran Beasley Oct 31 '20 at 08:01

0 Answers0