3 use Device::SerialPort;
7 my $port = Device::SerialPort->new('/dev/ttyUSB0', 0);
8 $port->baudrate(115200);
12 $port->handshake('none');
13 $port->stty_icanon(1);
14 $port->read_char_time(1);
17 my $mqtt = Net::MQTT::Simple->new('micac.vojtech.kobylisy.czf') or die "Cannot connect to MQTT";
19 my @desc = qw(outside-exhaust inside-exhaust outside-intake chilled inside-intake bypass fan-pwm);
22 my $line = $port->read(255);
26 my @fields = split /\s+/, $line;
27 unless (@fields == @desc + 1 && $fields[0] eq '#') {
28 print STDERR "Malformed line: $line\n";
31 # print join("|", @fields), "\n";
34 for my $i (0..$#desc) {
35 $mqtt->retain('burrow/air/' . $desc[$i], join(" ", $fields[$i+1], $now));
36 print $desc[$i], '=', $fields[$i+1], " ";