Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

How to get 3 separate variable sets- all variable sets write to the same alias', overwrite each other.


Shanks.J Mar 29, 2020 09:30 PM

I am using a soil moisture probe that give excellent data but does not delive in a very clean way.

the probe is 80cm deep and has a sensor every 10cm, meaning 8 data points, retrieved accross 8 alias'
I aim to collect 3 data sets at each sensor. % of water, Salinity and Temperature.
the probe communicates over SDI12

A simple sdi command brings back the most recent data measured (in this case water %). which i have delivered into the alias 1-8.
command 1 = measure soil moisture,,, command 2 = measure soil salinity,,, command 3 = measure soil temperature.
4 = get measurement.

this means that a repeat of command 4 continues to retrieve the last data type. which continues to be measured within the probe.
at the moment i only use comand 4 which continues to get me soil moisture.

the problem
when i request the next set of data (salinity or temperature) the values are inserted into the same set of alias. which overwrites the data retrieved in the first command.
which means for each scan only on variable can be collected. the probe is not spart enough to deliver each varible set into different alias.
each comand brings back the value into the alias assosiated with each sensor, NOT the variable.

the solution i need

how can i get each, varble set written into a different set of alias. this could be done across say 3 different scans
ie  1-8 soil moisture
     9-16 - soil salinity
     17- 24 - soil temperature

i am stumped and would be grateful for any advice in this area

here is the code that is involved for the probe measurements so far.

'CR6 Prog for the temporary BENCH TEST in field

'1X 80CM ENVIROPROBE C1 ARRESS=6

'########## Declare Variables ###########
Public LoggerName As String * 24 'allows each logger to have a unique site code or name
Public Batt_volt(4) 'the loggers reading of battery voltages
Public PTemp_degC 'the loggers reading of its own internal temp
Public Soil_2_SDI12(8) 'probe #2, Address = 6 , Port C1


'########## output string from Soil moisture probe ##########

Alias Soil_2_SDI12(1)= Soil_2_10cm
Alias Soil_2_SDI12(2)= Soil_2_20cm
Alias Soil_2_SDI12(3)= Soil_2_30cm
Alias Soil_2_SDI12(4)= Soil_2_40cm
Alias Soil_2_SDI12(5)= Soil_2_50cm
Alias Soil_2_SDI12(6)= Soil_2_60cm
Alias Soil_2_SDI12(7)= Soil_2_70cm
Alias Soil_2_SDI12(8)= Soil_2_80cm

'########## Define Data Tables ##########
DataTable(Table1,True,-1)
DataInterval(0,10,Min,10) 'write table every 10 minutes
Sample (1,LoggerName,String)
Sample (1,SupplyVolts,FP2)
Sample (1,LithiumVolts,FP2)
Sample (1,PTemp_degC,FP2)
Sample (1,Soil_2_10cm,FP2)
Sample (1,Soil_2_20cm,FP2)
Sample (1,Soil_2_30cm,FP2)
Sample (1,Soil_2_40cm,FP2)
Sample (1,Soil_2_50cm,FP2)
Sample (1,Soil_2_60cm,FP2)
Sample (1,Soil_2_70cm,FP2)
Sample (1,Soil_2_80cm,FP2)
EndTable


'########## Main Program ###########
BeginProg
LoggerName="soiltestbench" 'ie a unique name for this logger/

'Main Scan
Scan(30,sec,1,0) 'Scan once every 30seconds
Battery(Batt_volt())'Read the supply and lithium voltages
PanelTemp(PTemp_degC,50) 'Read CR6 internal temp

'PROBE2
SDI12Recorder(Soil_2_SDI12(),C1,"6","C!",1,0,-1) 'take measuremt (soil moisture)

CallTable Table1 'Call Data Table and Store Data
NextScan


nsw Mar 31, 2020 11:40 AM

The variable that the SDIRecorder instruction writes to is an array variable. If the sensor sends back 8 values from the command you send to it, then you need an array at least 8 in size. Which is what you have in your program. If you do not say which element to write to in the instruction "Soil_2_SDI12()" it will assume it will write to array element number 1 first and then fill from there upto 8.

So, if you want a variable with 24 elements, the you can fill each one as you want, as shown in program below. I have removed all the un-necesaary lines that you do not need to see how this works.

I do not know what actual command you need to send to the sensor to get each set of values, that is up to the sensor manufacturers definition.

Public Soil_2_SDI12(24)


'########## Define Data Tables ##########
DataTable(Table1,True,-1)
 DataInterval(0,10,Min,10) 'write table every 10 minutes
 Sample (1,LoggerName,String)
 Sample (1,PTemp_degC,FP2)
 Sample (24,Soil_2_SDI12(1),FP2)
EndTable


'########## Main Program ###########
BeginProg

'Main Scan
 Scan(30,sec,1,0) 'Scan once every 30seconds

'PROBE2
 SDI12Recorder(Soil_2_SDI12(1),C1,"6","M1!",1,0,-1) 'take measuremt (soil moisture)
 SDI12Recorder(Soil_2_SDI12(9),C1,"6","M2!",1,0,-1) 'take measuremt (soil salinity)
 SDI12Recorder(Soil_2_SDI12(17),C1,"6","M3!",1,0,-1) 'take measuremt (soil temp)

 CallTable Table1 'Call Data Table and Store Data
 NextScan

EndProg

Log in or register to post/reply in the forum.