Is there a way to detect a power outage after my CR1000 comes back online? I have a serial device connected that needs to be recalibrated if the power goes out. I tried putting the calibration command between BeginProg and Scan commands thinking it executes this when power is restored, but it's not working.
It would help if you posted your program so we may be able to see what your code is doing. If it is a long program, post a short version with the problem section included.
Below is a section of a program that executes when the program is compiled at download or at logger restart. In this case there are two data loggers with calibrated sensors attached. Each logger's sensors have different calibrations. However, by using the station name from the status table, one program can run on many loggers but yet each has unique code, in this case different calibration values for the respective transducers.
In the sample code below the first scan/nextscan causes the transducer to be read at what is assumed to be a zero state. Your conditions may be different but in the first scan you can control anything you would in the main scan including setting zero and cal conditions if necessary.
Next section which constants some of which are based on values read in the first scan.
The main scan follows, making measurements and using the results of the scale and offsets determined in the first sections.
BeginProg 'Program begins here
Scan (1,sec0,1)
' voltage read the transducer zero value (Zero_cal)
NextScan
If Status.StationName = 47892 Then
FS_cal=6230
Rated_PSI=5000
EndIf
If Status.StationName = 47891 Then
FS_cal=5990
Rated_PSI=10000
EndIf
Mult=Rated_PSI/(FS_cal-Zero_Cal)
' Main scan follows
Scan(PERIOD,P_UNITS,10,0)
' Read sensor voltage using "mult" as scaling and "Zero_Cal" as offset
Next Scan
I hope this helps or at least gives you a direction to go.