Merge branch 'master' of mjesec.ffzg.hr:/git/air-quality
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 8 Feb 2020 14:11:06 +0000 (15:11 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 8 Feb 2020 14:11:06 +0000 (15:11 +0100)
dsm501.pl
mh-z19b.pl
system/air-dsm501.service [new file with mode: 0644]
system/air-mh-z19b.service [new file with mode: 0644]
system/air-mq7.service [new file with mode: 0644]
system/air-zph02.service [new file with mode: 0644]

index 8e183c8..0032747 100755 (executable)
--- a/dsm501.pl
+++ b/dsm501.pl
@@ -6,7 +6,7 @@ use Device::SerialPort;
 use Time::HiRes;
 use Data::Dump qw(dump);
 
-my $port = shift @ARGV || '/dev/ttyUSB2';
+my $port = shift @ARGV || '/dev/ttyUSB4';
 my $influx_url = shift @ARGV || 'http://10.13.37.229:8186/write?db=telegraf';
 $influx_url = 'http://10.13.37.92:8086/write?db=rot13';
 my $measurement = $ENV{MEASUREMENT} || 'dsm501';
@@ -27,7 +27,7 @@ while (1) {
        my $t = int( Time::HiRes::time() * 1_000_000_000 );
        die $! if ! defined($len);
        if ( $len > 0 ) {
-               warn "# len=$len ",dump($string);
+               #warn "# len=$len ",dump($string);
                if ( $string !~ m/^#/ ) {
                        $string =~ s/[\r\n]+$//;
                        $string =~ s/\s/,/g;
index 0c3fbd1..94abb05 100755 (executable)
@@ -7,6 +7,7 @@ use Time::HiRes;
 use Data::Dump qw(dump);
 
 my $port = shift @ARGV || '/dev/ttyUSB0';
+$port = '/dev/ttyUSB5';
 my $influx_url = shift @ARGV || 'http://10.13.37.229:8186/write?db=telegraf';
 $influx_url = 'http://10.13.37.92:8086/write?db=rot13';
 
@@ -16,7 +17,7 @@ $s->databits(8);
 $s->parity('none');
 $s->stopbits(1);
 $s->handshake('none');
-$s->read_char_time(0);
+$s->read_char_time(1);
 $s->read_const_time(10);
 $s->debug(1);
 
@@ -30,8 +31,7 @@ while (1) {
        if ( $len > 0 ) {
                my @v = unpack('C*', $string);
                if ( $#v < 8 ) {
-                       warn "# $len ",dump($string), dump( @v ), $/;
-                       next;
+                       die "# $len ",dump($string), dump( @v ), $/;
                }
 
                my $sum = 0;
diff --git a/system/air-dsm501.service b/system/air-dsm501.service
new file mode 100644 (file)
index 0000000..724fe2c
--- /dev/null
@@ -0,0 +1,10 @@
+[Unit]
+Description=Air
+
+[Service]
+User=dpavlin
+ExecStart=/home/dpavlin/air-quality/dsm501.pl
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target
diff --git a/system/air-mh-z19b.service b/system/air-mh-z19b.service
new file mode 100644 (file)
index 0000000..b940431
--- /dev/null
@@ -0,0 +1,10 @@
+[Unit]
+Description=Air
+
+[Service]
+User=dpavlin
+ExecStart=/home/dpavlin/air-quality/mh-z19b.pl
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target
diff --git a/system/air-mq7.service b/system/air-mq7.service
new file mode 100644 (file)
index 0000000..21e8f97
--- /dev/null
@@ -0,0 +1,10 @@
+[Unit]
+Description=Air
+
+[Service]
+User=dpavlin
+ExecStart=/home/dpavlin/air-quality/mq7.sh
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target
diff --git a/system/air-zph02.service b/system/air-zph02.service
new file mode 100644 (file)
index 0000000..c76b5c3
--- /dev/null
@@ -0,0 +1,10 @@
+[Unit]
+Description=Air
+
+[Service]
+User=dpavlin
+ExecStart=/home/dpavlin/air-quality/zph02.pl
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target