Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, an initiative of Stroud Water Research Center designed to help people advance knowledge and stewardship of fresh water.
New to EnviroDIY? Start here

Bypassing SDI-12 library to read 8-bits by using high volume binary command

Home Forums Other Data Loggers Bypassing SDI-12 library to read 8-bits by using high volume binary command

Viewing 0 reply threads
  • Author
    Posts
    • #19349

      I’m working with soil moisture sensors and currently using the Acclima TDR-305N, which communicates via the SDI-12 protocol. I’ve successfully interfaced with the sensor using the Arduino SDI-12 library and can retrieve standard measurements without issue.

      However, I’m now trying to access the actual TDR waveform using the High Volume Binary Command described in the SDI-12 v1.4 specification (Section 5.2, <a class=”relative pointer-events-auto a cursor-pointer

      underline
      ” href=”https://sdi-12.org/current_specification/SDI-12_version-1_4-Jan-30-2021.pdf&#8221; target=”_blank” rel=”noopener nofollow noreferrer ugc”>https://sdi-12.org/current_specification/SDI-12_version-1_4-Jan-30-2021.pdf). This command transmits data in 8-bit binary format, which breaks out of the standard SDI-12 framing (normally 7 data bits + 1 parity bit).

      Here’s the issue: when I send the command using the SDI-12 library, I only receive 7 bits per byte — the 8th bit is consistently missing. I suspect this is because the library is still enforcing SDI-12 framing, even though the binary data should be handled differently.

      Has anyone successfully bypassed the SDI-12 library to capture all 8 bits of binary data? My sensor SDI-12 address is 3.

      // Command 1: Start waveform measurement (3HB!)
      myCommand = String(SENSOR_ADDRESS) + “HB!”;
      Serial.println(myCommand);
      mySDI12.sendCommand(myCommand);
      delay(30); // Wait for a response

      sdiResponse = “”;
      while (mySDI12.available()) {
      char c = mySDI12.read();
      if ((c != ‘\n’) && (c != ‘\r’)) {
      sdiResponse += c;
      delay(10);  // 1 character ~ 7.5ms
      }
      }
      if (sdiResponse.length() > 1) {
      Serial.println(sdiResponse);
      }
      mySDI12.clearBuffer();
      delay(1000);

      // Command 2: Request first block of waveform data (3DB1!)
      myCommand = String(SENSOR_ADDRESS) + “DB0!”;
      Serial.println(myCommand);
      //Serial1.println(myCommand);
      mySDI12.sendCommand(myCommand);
      delay(30);
      int count;
      count = 0;
      while (mySDI12.available()) {
      char c = mySDI12.read();
      count = count + 1;
      for (int i = 7; i >= 0; i–) {
      Serial.print(bitRead(c, i));
      }
      Serial.print(“\t”);
      if (count % 2 == 0) {
      Serial.println();
      }

      if ((c != ‘\n’) && (c != ‘\r’)) {
      sdiResponse += c;
      delay(8);
      }

      }

       

Viewing 0 reply threads
  • You must be logged in to reply to this topic.