projects
/
air-quality
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
don't send 0 values
[air-quality]
/
zph02.pl
diff --git
a/zph02.pl
b/zph02.pl
index
44d35ef
..
10f961e
100755
(executable)
--- a/
zph02.pl
+++ b/
zph02.pl
@@
-7,7
+7,7
@@
use Time::HiRes;
use Data::Dump qw(dump);
my $port = shift @ARGV || '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.5:1.0';
use Data::Dump qw(dump);
my $port = shift @ARGV || '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.5:1.0';
-my $influx_url = shift @ARGV || 'http://1
0.13.37.92
:8086/write?consistency=any&db=rot13';
+my $influx_url = shift @ARGV || 'http://1
92.168.3.40
:8086/write?consistency=any&db=rot13';
my $s = new Device::SerialPort( $port ) || die $!;
$s->baudrate(9600);
my $s = new Device::SerialPort( $port ) || die $!;
$s->baudrate(9600);
@@
-43,10
+43,10
@@
while (1) {
my $checksum = $v[8];
my $pcnt = $v[3] + ( $v[4] / 100 );
my $checksum = $v[8];
my $pcnt = $v[3] + ( $v[4] / 100 );
- if ( $v[0] == 0xff && $sum == $checksum ) {
+ if ( $v[0] == 0xff && $sum == $checksum
&& $pcnt > 0
) {
my $influx = "zph02,dc=trnjanska pm25_pcnt=$pcnt $t";
my $influx = "zph02,dc=trnjanska pm25_pcnt=$pcnt $t";
- print "$influx\n";
- system "curl --silent -XPOST '$influx_url' --data-binary '$influx'";
+ print "$influx\n"
if -e '/dev/shm/air-debug'
;
+ system "curl --
max-time 2 --
silent -XPOST '$influx_url' --data-binary '$influx'";
system "mosquitto_pub -h rpi2 -t 'air/zph02/pm25' -m $pcnt";
}
}
system "mosquitto_pub -h rpi2 -t 'air/zph02/pm25' -m $pcnt";
}
}