Sensor Interfacing: Soil Moisture Sensor using SDI-12

Thanks for your reply!

Krodal:
if the SDI-12 bus is running at 12V, you can't just connect it to the RX and TX of the Arduino

I didn't think it was possible to directly interface it directly also becasue the TX and RX are seperate, where as with the sensor there is only 1 data wire?

The sensor is made by a company called Decagon, here it is - http://bit.ly/ObuMPU

The SDI-12 -> RS232 i am looking at is http://bit.ly/T7wDWe

The RS232 -> Arduino converter i am looking at is http://bit.ly/QBgjuP

The MAX3232 is the 3V version of the MAX232. So if your Arduino is running at 5V, I think the MAX232 is a better choice. I don't know if the MAX3232 is 5V tolerant for the digital signals.
A MAX232 version is also cheaper, only 3 or 4 AUD.

If you must use that sensor, using SDI-12 -> RS232 converter with RS232 -> Arduino converter will work. But many sensor can be connected directly to the Arduino.
Like this one: http://www.cheapvegetablegardener.com/2009/08/how-to-use-vegetronix-soil-moisture.html
Or this one: Gravity: Analog Soil Moisture Sensor for Arduino - DFRobot
Many people build their own moisture sensor.
They all seem to measure the resistance between two pins. I think the GS3 sensor is more sophisticated than that. It measures also the electrical conductivity, but (as far as I understand) it uses 70MHz to measure the moisture.

Your GS3 sensor is also capable of TTL level (3.6V) serial communication. So it can be connected directly to the Arduino without SDI-12. But if you need many sensors and meters of wires between them, the SDI-12 is ment for that.

Hi Krodal,

Those are some really good points. The reason I've selected this sensor is because it is designed for the greenhouse environment which is the application.

The other main reason is it measures EC, Temp and Slab Moisture where all those peaces of information are very interesting to me in terms of further control.

There will just be a single sensor per arduino so the purpose of SDI-12 is not really being fufulled in this situation (they designed these sensors primerialiy for data loggers).

When i look at my Arduino Mega 2560 i notice there is a seperate TX and RX line (however the sensor with 1 data line). How would you suggest connecting the sensor the bord?

I belive it needs some kind of excitation signal?

The Arduino Mega has a few serial ports. For example the Arduino Uno has only one.
The RX0 and TX0 of the Arduino Mega is used for the ttl-to-usb on the Arduino Board and is used for the "serial monitor" of the Arduino environment on the computer.

So you can choose any of the other serial ports.
As you can read here : http://arduino.cc/en/Main/ArduinoBoardMega2560
The other ports are : Serial 1: 19 (RX) and 18 (TX); Serial 2: 17 (RX) and 16 (TX); Serial 3: 15 (RX) and 14 (TX)

The GS3 is just sending information, and you can't write something to it. So connect the serial output of the sensor via a resistor of 1k (or 10k, just for protection) to one of the RX lines of the serial ports on the Arduino Mega.

In your sketch you initialize that serial port: http://arduino.cc/en/Serial/Begin
Like: Serial1.begin(1200);

It operates also at 5V, so you could use the +5V of the Arduino to power the sensor.

But I still don't understand the datasheet very well. The signal is TTL level (3.6V) active low. I think you have to invert that signal (a transistor and a few resistors will do). Perhaps you could ask the manufacturer about that.

Oh ok, so perhaps i don't need to send the sensor comands in order to get a response?

This may help explain the timing and signal charactaristics

SDI-12 INTRODUCTION
SDI-12 is a standards-based protocol for interfacing sensors to data loggers and data acquisition equipment. Multiple sensors with unique addresses can share a common 3-wire bus (power, ground, and data). Two-way communication between the sensor and logger are possible by sharing the data line for transmit and receive as defined by the standard. Sensor measurements are triggered by protocol command.

I have now connected the sensor and tested. The method as follows

I connected the sensor to 5V and GND on the board and the "data" to serial 1 [pin 19 (RX) on the mega 2560]

I used the following code to read serial port 1 and print the result back through the USB serial so i could read it with my computer (uncomenting the "test coms" works well).

int incomingByte = 0; 
 
void setup() {
         Serial.begin(1200);
         Serial1.begin(1200);     
 }
 
void loop() {
 
         //Serial.println("Test Coms");
         if (Serial1.available() > 0) {
                 // read the incoming byte:
                 incomingByte = Serial.read();
 
                // say what you got:
                 Serial.print("I received: ");
                 Serial.println(incomingByte, DEC);
         }
 }

I started with a 1k resistor between the "data" and RX Pin 19 and also tried without.

Unfortunately there is no response.

Based on this I'm not sure if it is possible to interface this sensor directly as suggested?

You should ask the manufacturer.
According to the datasheet is it possible. But I'm not certain how it should be done. I also looked at the other documents, but it is still not clear to me.

It's a bit outdated topic, but just recently noticed it. I've succesfully worked with the same combo of Arduino and GS3 (60 in total on the bus), I'd like to add some additional information that might help you.

The reason you don't get a reply, is that SDI-12 is based on a half-duplex master-(many)slave principle. So your master (in this case Arduino) needs to let the sensor know there's work to be done. Let's say the address that's setup in the sensor is 0 (default). Try sending the following characters first "0!", the sensor should directly with just returning "0".

Also check out the www.sdi-12.org website, with a good overview of the protocol and it's specifications

How did you connect the RX/TX lines together on the arduino? Did you use additional level converting hardware?

I am running the same issue by setting the arduino TTL serial communication with the sensor and get no data reply.
The sensor indicating a 0-3.6V logical TTL and arduino has a 0-5V TTL, will that be a problem?
How can I fix it?

I did get it eventually (much, much later). I used a mega to get a hardware serial, I still haven't gotten it working on softserial.

You need 7E1 serial, inverted. I used an inverting buffer chip. The lines are then joined with small resistors. You need to then also give the fixed low and high pulse to wake the device and begin communication. Then you can talk normally.

Thanks Quatch for your quick reply!
I am using an UNO and trying to save the RX TX for Xbee..Did you try the newsoftserial (after Arduino 1.0 version)?
How small the resistors you are using?
"Give the fixed low and high pulse". Do you mean by power the sensor using arduino a pin and change its state periodically from OUTPUT to INPUT?
I noticed you also posted in stack overflow and mentioned 3.3V level shifter. Did you use it currently in your circuit?

You can probably get around the hardwareSerial requirement, but I haven't gone back to try that again as I had a mega lying around. The levelshifting was because the arduino I was trying at the time was 3.3v. I wrote up what I did here: http://www.hexagonalscience.com/word/?p=77 I'll add more details after I get back to the lab. let me know if you need more info.

Hi quatch you are right I tried the softwareSerial method but can not get anything from SDI-12. But I do get data reading using the DDI serial communication protocol, which is based on 8N1 and non-inverted, and I can use other pins (right now Pin 7 as RX to receive data).If you are interested you may try this as well, the disadvantage is that you need a single pin for each sensor (maybe mux can help)..

This is true for decagon devices, I'd forgotten about it as I was also working with a stevens hydra probe (SDI version) which doesn't have a friendly DDI startup. Actually the decagon manuals have a very nice description of SDI12, easier to read I think than the official specification (I do see that the manual for the 5TE and GS3 disagree as to whether DDI is active high[yes] or active low[no]).. Of course they insist on a nonstandard 3.3V, but that can be advantageous nowadays.

As long as you only need the measurements that are pre-programmed for the DDI burst, you're golden. A multiplexer would work great, but you'll also need to be able to supply and remove power to toggle the measurements.

Hi all,

I'm considering of buying GS3 sensor from Decagon as well in order to connect it to Arduino MEGA using serial DDI (not SDI-12). And I am quite concerned about the "active-high logic levels using 0-3.6V", and then I founf this post.

My question is that if I connect the sensor directly to Serial1 in arduino mega I guess that it wont work straightaway, is that correct? And in that case, could you tell me the circuit that I would need??

I would appreciate any help.

Cheers

Yeah, DDI is just normal serial. A real shame the interface isn't completely DDI..

The voltage is high enough that it should be read by a 5V arduino. You won't be able to transmit back (but with DDI there is no reason to).

Hi Guys

Long time lurker first time poster. anyway I just made a Library that does exactly this and I would love some feedback

-Joran

Hi guys,

I am new user of Arduino Mega, is it possible for Mega to read data from different sensor? 3 sensors (soil moisture, soil temperature, ph level) specifically interface to 1 Mega Arduino. i am also thinking to used an rf module to send this data to my PC. Could you recommend what will i used? Thank you so much.