Home › Forums › Environmental Sensors › inconsistent Results › Reply To: inconsistent Results
2017-04-25 at 1:36 AM
#2172
Hello,
Thanks for the quick response.Bellow is the sketch running on the arduino Uno R3. The devices where actually tested on the field(not in a controlled environment).The results shown on the plot is VMC collected every minute from the sensors. Actually the VWC is expected to reduce with time, these results are collected over a period of 3 days. Surprisingly they show a sinusoidal curve and the sensors are places in a sandy loam soil. I am thinking maybe the sketch has some problem. Please do you have any ideas why such results?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
//This is the first code for taking data from the 5TM sensor and showing it on the Arduino serial mornitor #include <SDI12.h> #define DATAPIN 7 // change to the proper pin for sdi-12 data pin, I prefer D7 SDI12 mySDI12(DATAPIN); unsigned long previousMillis = 0; const long interval = 60000; //set the interval (in milliseconds). ex: 60000 = 60 seconds void setup () { pinMode(13, OUTPUT); digitalWrite(13, LOW); //turn off the onboard LED to start with Serial.begin(57600); mySDI12.begin(); Serial.println("Sketch for sampling multiple SDI12 sensors"); delay(1000); } void loop () { unsigned long currentMillis = millis(); if(currentMillis - previousMillis >= interval || previousMillis == 0) { previousMillis = currentMillis; digitalWrite(13, HIGH); //turn on the onboard LED to show that samples are being taken Serial.print("Time: "); Serial.print(currentMillis/1000); //print out the current time, in seconds Serial.print(" ---- "); for (char j = '1'; j <= '2'; j++) { //go through channels 1 to 6 tmMeasurement(j); } Serial.println(); digitalWrite(13, LOW); //turn off the LED to show that samples are done } delay(1000); } void tmMeasurement(char c){ //5TM soil moisture sensor String command = ""; float Ea = 0.0; float temp = 0.0; float VWC = 0.0; command += c; command += "M!"; // SDI-12 measurement command format [address]['M'][!] mySDI12.sendCommand(command); delay(500); // wait a sec mySDI12.flush(); command = ""; command += c; command += "D0!"; // SDI-12 command to get data [address][D][dataOption][!] mySDI12.sendCommand(command); delay(500); if(mySDI12.available() > 0){ int channel = mySDI12.parseInt(); Ea = mySDI12.parseFloat(); temp = mySDI12.parseFloat(); VWC = (4.3e-6*(Ea*Ea*Ea)) - (5.5e-4*(Ea*Ea)) + (2.92e-2 * Ea) - 5.3e-2 ; //the TOPP equation used to calculate VWC Serial.print("Sensor:"); Serial.print(channel); Serial.print(": Ea="); Serial.print(Ea); //apparent dielectric permittivity Serial.print(", VWC="); Serial.print(VWC); //volumetric water content Serial.print("%, Temp="); Serial.print(temp); //Tempeerature Serial.print("degC .... "); } mySDI12.flush(); } |