'CR1000X Series Datalogger 'Example datalogger program for Apogee Instruments S2-411/412 series SDI12 NDVI sensors (1 upward and downward facing sensor pair) 'date: December 11th, 2020 'program author: John Huber, Noah Leclerc 'Wiring: 'White -> Com C1 (Upward) / Com C3 (Downward) (SDI12 signal wire) 'Black -> Ground Port (SDI12 ground wire) 'Red -> 12 V Port (Sensor power wire (4.5-24 V DC)) 'Clear -> Shield ground 'Explanation of Constants, Variables, and Aliases Used in Datalogger Program 'BattV = datalogger battery voltage 'PanelT = datalogger panel temperature 'M1Up = Output of the M1! command for the upward facing sensor 'M1Dn = Output of the M1! command for the downward facing sensor 'LowWaveUp = Calibrated detector reading for the 650 nm detector in upward sensor 'LowWaveDn = Calibrated detector reading for the 650 nm detector in downward sensor 'HighWaveUp = Calibrated detector reading for the 810 nm detector in upward sensor 'HighWaveDn = Calibrated detector reading for the 810 nm detector in downward sensor 'LowReflect = Reflectance at 650 nm 'HighReflect = Reflectance at 810 nm 'NDVI = NDVI Reading 'Declare Public Variables Public BattV, PanelT Public M1Up(2), M1Dn(2), LowReflect, HighReflect, NDVI Alias M1Up(1) = LowWaveUp Alias M1Up(2) = HighWaveUp Alias M1Dn(1) = LowWaveDn Alias M1Dn(2) = HighWaveDn Units LowWaveUp = Watts/m2 Units HighWaveUp = Watts/m2 Units LowWaveDn = Watts/m2 Units HighWaveDn = Watts/m2 'Define Data Tables DataTable (NDVITable,1,-1) DataInterval (0,1,Min,10) Minimum(1,BattV,IEEE4,0,False) Sample(1,PanelT,IEEE4) Average(1,NDVI,IEEE4,False) Average(1,LowReflect,IEEE4,False) Average(1,HighReflect,IEEE4,False) EndTable 'Main Program BeginProg Scan(1,Sec,0,0) Battery(BattV) PanelTemp(PanelT,60) 'Upward Facing Sensor 'Measure detector signals SDI12Recorder(M1Up(),C1,0,"M0!",1.0,0.0) 'Downward Facing Sensor 'Measure detector signals SDI12Recorder(M1Dn(),C3,0,"M0!",1.0,0.0) 'Please consult the sensor manual for a list of commands 'Calculate Reflectance Values HighReflect = (HighWaveDn / HighWaveUp) LowReflect = (LowWaveDn / LowWaveUp) 'Calculate NDVI NDVI = (HighReflect - LowReflect) / (HighReflect + LowReflect) 'Call Output Tables CallTable NDVITable NextScan EndProg