EnviroDIY / Arduino-SDI-12

An Arduino library for SDI-12 communication with a wide variety of environmental sensors. This library provides a general software solution, without requiring any additional hardware.
https://github.com/EnviroDIY/Arduino-SDI-12/wiki
BSD 3-Clause "New" or "Revised" License
158 stars 100 forks source link

SDI-12 Data error #76

Closed nsecgo closed 3 years ago

nsecgo commented 3 years ago

屏幕截图 2021-05-13 140909

#include <SDI12.h>

#define SERIAL_BAUD 9600 /*!< The baud rate for the output serial port */
#define DATA_PIN 7         /*!< The pin of the SDI-12 data bus */

/** Define the SDI-12 bus */
SDI12 mySDI12(DATA_PIN);

String myCommand = "?I!";

void setup() {
  Serial.begin(SERIAL_BAUD);
  while (!Serial)
    ;

  Serial.println("Opening SDI-12 bus...");
  mySDI12.begin();
  delay(500);  // allow things to settle
}

void loop() {
  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(2000);
}
nsecgo commented 3 years ago

circuit

SRGDamia1 commented 3 years ago

What's the error?

nsecgo commented 3 years ago

What's the error?

屏幕截图 2021-05-13 140909 The place marked in red

nsecgo commented 3 years ago

May be caused by the quality of the DuPont wire The error no longer appears after replacing the Dupont wire

SRGDamia1 commented 3 years ago

Oh, sorry, I didn't even notice those. This library is "bit-banging" for the serial port, so occasional blips in the serial string are more common than is ideal. But low quality wires will definitely make it worse.

nsecgo commented 3 years ago

@SRGDamia1 I found that the longer the ground wire from Arduino's GND to External power supply's GND(The orange line in the image above), the more frequent the errors are. And It doesn't matter how long the Data line is. Any ideas are greatly appreciated.

SRGDamia1 commented 3 years ago

I'm not really great with hardware. I don't have any suggestions other than to use the best quality wire and connections you can and don't have wires any longer than necessary.

neilh10 commented 3 years ago

Ground issues are really tricky. Usually its about having good design practices. Try keeping the ground/power wires as short as possible and keep the two power supplies +5V and +12V together off the same plug. Possibly get a +5V regulator and power it off the +12V. The +5V would power the mayfly

Part of the problem may be figuring out just where is the problem. There is "ground bounce", and then there is noise on the data line. Both could result in corrupted data as seen by the Mayfly.
IMHO the Mayfly SDI-12 description of connecting data wire directly to the processor is really "proto-typing", doing something to be able to get the software to work under ideal conditions. The SDI-12 specification has a defined wire and voltage interface that has more latitude for noise. Ground bounce is a much more technical problem.