'CR1000X Series Datalogger 'The datalogger type listed on line 1 determines the default instruction set, 'compiler, and help files used for a program that uses the .DLD or .CRB program 'extension. These options can also be set using the Set Datalogger Type dialog box '(CRBasic Editor|Tools|Set Datalogger Type). 'For programming tips, copy this address to your browser 'search window:https://www.campbellsci.com/videos/datalogger-programming 'To create a different opening program template, type in new 'instructions and select Template | Save as Default Template 'Date: 'Program author: 'Declare Constants 'Example: 'CONST PI = 3.141592654 'Declare Public Variables 'Example: Public NBytesReturned As Long Public PTemp, Batt_volt Public sensor As String * 150 Public array(13) As String Alias array(1) = date Alias array(2) = t Alias array(3) = rh Alias array(4) = pressure Alias array(5) = no2 Alias array(6) = co2 Alias array(7) = o3 Alias array(8) = no Alias array(9) = pm1 Alias array(10) = pm25 Alias array(11) = pm10 Alias array(12) = config Alias array(13) = uptime 'Alias array(11) = config 'Alias array(12) = uptime Public days As String, months As String, years As String Public hours As String, minutes As String, seconds As String Public tanggal As String, waktu As String Public time(9) 'Declare Private Variables 'Example: 'Dim Counter 'Define Data Tables DataTable (satu_min,1,-1) 'Set table size to # of records, or -1 to autoallocate. DataInterval (0,1,Min,10) Sample(1,tanggal,String) Sample(1,waktu,String) Minimum (1,Batt_volt,FP2,False,False) Sample (1,PTemp,FP2) Sample (1,t,FP2) Sample (1,rh,FP2) Sample (1,pressure,FP2) Sample (1,no2,FP2) Sample (1,co2,FP2) Sample (1,o3,FP2) Sample (1,no,FP2) Sample (1,pm1,FP2) Sample (1,pm25,FP2) Sample (1,pm10,FP2) MQTTPublishTable (0,0,1,Min,1) EndTable DataTable (sepuluh_min,1,-1) 'Set table size to # of records, or -1 to autoallocate. DataInterval (0,10,Min,10) Sample(1,tanggal,String) Sample(1,waktu,String) Minimum (1,Batt_volt,FP2,False,False) Sample (1,t,FP2,False) Sample(1,rh,FP2,False) Sample(1,pressure,FP2,False) Average(1,no2,FP2,False) Average(1,co2,FP2,False) Average(1,o3,FP2,False) Average(1,no,FP2,False) Average(1,pm1,FP2,False) Average(1,pm25,FP2,False) Average(1,pm10,FP2,False) Sample(1,pm1,FP2) Sample(1,pm25,FP2) Sample(1,pm10,FP2) MQTTPublishTable (0,0,10,Min,1) EndTable 'Define Subroutines 'Sub 'EnterSub instructions here 'EndSub 'Main Program BeginProg SerialOpen (ComC5,115200,19,0,300,3) Scan (10,Sec,0,0) RealTime (time()) days = FormatFloat (time(3),"%02.0f") months = FormatFloat (time(2),"%02.0f") years = FormatFloat (time(1),"%02.0f") hours = FormatFloat (time(4),"%02.0f") minutes = FormatFloat (time(5),"%02.0f") seconds = FormatFloat (time(6),"%02.0f") tanggal = days&"/"&months&"/"&years waktu = hours&":"&minutes&":"&seconds ' If TimeIntoInterval (1,10,Min) Then ' Delay (0,3,Min) SerialInRecord (ComC5,sensor,00,115,&H0D0A,NBytesReturned,00) SplitStr (array(1),sensor,CHR(44),13,7) 'EndIf PanelTemp (PTemp,15000) Battery (Batt_volt) SW12 (SW12_1,1 ) SW12 (SW12_2,1 ) 'Enter other measurement instructions 'Call Output Tables 'Example: CallTable satu_min CallTable sepuluh_min NextScan EndProg