$temp = nearest(0.1, f2c(unpack("s", substr $blk,12,2) / 10));
$h{Temp_Out} = $temp;
+ if ($temp > 75 || $temp < -75) {
+ dbg "LOOP Temperature out of range ($temp), record ignored";
+ return;
+ }
$tmp = unpack("C", substr $blk,14,1);
$h{Wind} = nearest(0.1, mph2mps($tmp));
$h{Dir} = unpack("s", substr $blk,16,2)+0;
my $wind = {w => $h{Wind}, d => $h{Dir}};
+ $wind = 0 if $wind == 255;
push @{$ld->{wind_min}}, $wind;
- $h{Humidity_Out} = unpack("C", substr $blk,33,1)+0;
- $h{Humidity_In} = unpack("C", substr $blk,11,1)+0;
+ $tmp = int(unpack("C", substr $blk,33,1)+0);
+ if ($tmp > 100) {
+ dbg "LOOP Outside Humidity out of range ($tmp), record ignored";
+ return;
+ }
+ $h{Humidity_Out} = $tmp;
+ $tmp = int(unpack("C", substr $blk,11,1)+0);
+ if ($tmp > 100) {
+ dbg "LOOP Inside Humidity out of range ($tmp), record ignored";
+ return;
+ }
+ $h{Humidity_In} = $tmp;
+
$tmp = unpack("C", substr $blk,43,1)+0;
$h{UV} = $tmp unless $tmp >= 255;
$ld->{Temp_Out_Max} = $temp if $temp > $ld->{Temp_Out_Max};
$ld->{Temp_Out_Min} = $temp if $temp < $ld->{Temp_Out_Min};
- if ($ts >= $ld->{last_hour} + 3600) {
+ if ($ts >= $ld->{last_hour} + 1800) {
$h{Pressure_Trend} = unpack("C", substr $blk,3,1);
$h{Pressure_Trend_txt} = $bar_trend{$h{Pressure_Trend}};
$h{Batt_TX_OK} = (unpack("C", substr $blk,86,1)+0) ^ 1;
$s = genstr($ts, 'h', \%h);
- $ld->{last_hour} = int($ts/3600)*3600;
+ $ld->{last_hour} = int($ts/1800)*1800;
$ld->{last_min} = int($ts/60)*60;
@{$ld->{wind_hour}} = ();
@{$ld->{wind_min}} = ();