Signed in as:
filler@godaddy.com
Signed in as:
filler@godaddy.com
<-- Back to Panther Logger Tutorials
In this tutorial we will wire an In-Situ RDO Pro dissolved oxygen sensor to the Panther Logger and program the logger to read the sensor.
Sections in this tutorial
The In-Situ RDO Pro sensor is a standalone sensor for measuring dissolved oxygen in aquatic monitoring applications. The Panther Logger can read the RDO Pro using SDI12 and power it with the 12VS rail. In this tutorial we test sensor communications on the bench top outside of an environmental enclosure. However, in a real field deployment one would need to place the Panther Logger and battery in an enclosure that prevents water and dirt intrusion with the RDO pro cable and wires securely passed through the enclosure.
For this tutorial you will need:
The RDO Pro should have its DO cap installed according to the manual. Go to In-Situ's website to find the manual. You should also configure and test the sensor as indicated by the manufacturer using their software first.
This sensor reports water temperature, dissolved oxygen as mass per volume (mg/L) and percent dissolved oxygen saturation.
The In-Situ RDO Pro dissolved oxygen sensor
There are only three wires needed for SDI12 communication and to power the sensor. These are wires for power, ground, and signal. The Panther Logger D6 or D11 pins (marked on the board) can be used for signal. The RDO Pro sensor requires at least 9V to run, so either of the two switched 12VS power rail pins on the Panther Logger should be used to power this sensor. The ground wire goes to any ground pin on the Panther Logger. Note that terminal block 7 on the Panther Logger has D11, GND, and 12VS altogether in a row so it is the ideal location to attach this sensor's wires to the Panther Logger. Note that SDI12 communication is addressable so multiple SDI12 sensors could be connected here.
Attach the correct wires from the RDO Pro sensor to the corresponding Panther Logger screw terminals (use image at right as a guide). Be sure to check the In-Situ RDO Pro manual for wire color definitions, but last time we looked it was:
At this point the RDO Pro should be wired correctly and ready for programming.
Go to our Github repository here and grab the "RDO_SDI12" example code to program the Panther Logger to read the RDO Pro sensor. Just copy/paste the code to a new Arduino script, save it and upload to the Panther board. This sensor outputs three variables including dissolved oxygen in mg/L, dissolved oxygen percent saturation and water temperature in Celsius. As such the code creates three float variables to hold these data.
The meat of the code is in the function called readRDO(). That function is pasted below:
void readRDO() {
mcp.pinMode(7, OUTPUT);
mcp.digitalWrite(7, HIGH); //Turn on 12VS rail
DO = -9999;
DOS = -9999;
RDOTemp = -9999;
unsigned int RDONowTime = millis();
unsigned int RDOInterval = 10000; //Give sensor 10 seconds to send good data
while(RDONowTime + RDOInterval > millis()){
if(DO == -9999 || DOS == -9999 || RDOTemp == -9999){
sdi12.begin();
sdi12.clearBuffer();
float RDOData[4] = {0};
sdi12.clearBuffer();
String command1 = "4M!"; //Tell sensor to make a measurement
sdi12.sendCommand(command1);
delay(100);
String sdiResponse = sdi12.readStringUntil('\n');
Serial.println(sdiResponse);
delay(3000); //RDO pro needs two seconds to make measurement
sdi12.clearBuffer();
String command2 = "4D0!"; //Tell sensor to send us the data
sdi12.sendCommand(command2);
delay(100);
for (uint8_t i = 0; i <= 3; i++){
RDOData[i] = sdi12.parseFloat();
}
DO = RDOData[1];
DOS = RDOData[2];
RDOTemp = RDOData[3];
sdi12.clearBuffer();
sdi12.end();
}
}
mcp.pinMode(7, OUTPUT);
mcp.digitalWrite(7, LOW); //Turn off 12VS rail
}
The first thing this code does is to fill the float variables with -9999. This way we know that if at the end of the loop those floats are still -9999 then data was most likely not received from the sensor.
The code then enters a while loop that will repeat reading of the sensor for a predetermined time period. This will provide a mechanism for the board to poll the sensor for data again if prior attempts did not yield data (i.e. replace -9999 with new data). Then there is an IF statement such that if sensor data is -9999 then the sensor will be polled for new data, otherwise measurements will not repeat.
To make SDI-12 measurements within the while loop we use functions within the handy Arduino-SDI-12 library from the folks at EnviroDIY, here.
SDI12 data is read from the sensor first by requesting that the sensor take a measurement with the sendCommand() function. Look at the code where the sendCommand() function is used. The function sends commands to the sensor in SDI-12 format. The SDI-12 command consists of the sensor address (in this case it is 4) followed by the M command and all commands ending in exclamation point (!). We read back the sensor response with the sdi12.readStringUntil() function and in this case read until the end of the line or until a new line is given ("\n"). The sensor will return the time it will take before the measurement is complete and data available. For this sensor it is about two seconds.
We give it three seconds with a delay to ensure we give it enough time. Then we send the command to get the data. This command again begins with the sensor address (4) followed by D0 (for data) and exclamation point. We read the data back into a float array (RDOData) with the parseFloat() function. We can then put each array value into the individual float variables for the two dissolved oxygen variables and water temperature.
The three variables are within this "0" segment of data, but if the sensor returned more data then we would need to subsequently issue a "D1" command and then read the data into another float array. See the tutorial on reading the In-Situ Aqua Troll sonde for an example of reading a larger number of variables from an SDI-12 sensor.
Copyright © 2023 ElectroRex - All Rights Reserved.
Powered by GoDaddy
We use cookies to analyze website traffic and optimize your website experience. By accepting our use of cookies, your data will be aggregated with all other user data.