X-Git-Url: http://git.rot13.org/?p=air-quality;a=blobdiff_plain;f=mh-z19b.pl;h=927951b53c709917b65e4afb88915274a7a90eea;hp=8edaa3fa7993834c723b8d7943c62b9697b6fa63;hb=59b28a41e509a3d933d3dac493ad78e60561e1d9;hpb=42b7874fd94e776acce9f6fcbea694474d848368 diff --git a/mh-z19b.pl b/mh-z19b.pl index 8edaa3f..927951b 100755 --- a/mh-z19b.pl +++ b/mh-z19b.pl @@ -6,8 +6,8 @@ use Device::SerialPort; use Time::HiRes; use Data::Dump qw(dump); -my $port = shift @ARGV || '/dev/serial/by-path/pci-0000:00:1a.7-usb-0:5.3.4:1.2'; -my $influx_url = shift @ARGV || 'http://10.13.37.92:8086/write?consistency=any&db=rot13'; +my $port = shift @ARGV || '/dev/serial/by-path/platform-3f980000.usb-usb-0:1.5:1.2'; +my $influx_url = shift @ARGV || 'http://10.60.0.92:8086/write?consistency=any&db=rot13'; my $s = new Device::SerialPort( $port ) || die $!; $s->baudrate(9600); @@ -43,8 +43,11 @@ while (1) { my $co2 = $v[2] * 255 + $v[3]; if ( $v[0] == 0xff && $sum == $checksum ) { my $influx = "mh-z19b,dc=trnjanska co2=$co2 $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/mh-z19b/co2' -m $co2"; + } else { + die "checksum error"; } sleep 1; $s->write("\xFF\x01\x86\x00\x00\x00\x00\x00\x79");