Pages: [1] 2   Go Down
Author Topic: Sensor Interfacing: Soil Moisture Sensor using SDI-12  (Read 5749 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I have read the relevant topics about SDI-12 integration and it would seem a SDI-12 to RS232 converter is needed.

I have been given an interfacing guide from the manufacturer for this device.

Below are snippets from this including commands. However i can only assume these will all chance once in RS232??

I'm trying to identify the next steps for development of this system using Arduino as i am new to the platform.

Thanks in advance

Alastair





« Last Edit: August 27, 2012, 11:29:29 am by medium_999 » Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1018
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Welcome to this forum.

We like to see more information.
What is the device ? Who is the manufacturer ?
You can copy url links in your message, like this : http://en.wikipedia.org/wiki/SDI-12

If you use a SDI-12 to RS232 converter, you can hook it up to a (old) computer with RS232 port. If you want that to connect to the Arduino, you have to use yet another converter.

The picture you have uploaded is just about the serial protocol with start-bit, stop-bit and parity. A serial port (and also the Arduino) has that already in hardware.
But if the SDI-12 bus is running at 12V, you can't just connect it to the RX and TX of the Arduino.

Here is information about it : http://whirlyworldblog.blogspot.nl/2011/01/sdi-12-to-arduino.html
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your reply!

Quote from: 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
Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1018
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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: http://www.dfrobot.com/index.php?route=product/product&product_id=599#.UDiS6yOYNko
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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1018
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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



Quote
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.
« Last Edit: August 26, 2012, 04:47:12 pm by medium_999 » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).

Code:
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?
« Last Edit: August 27, 2012, 11:32:04 am by medium_999 » Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1018
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1] 2   Go Up
Jump to: