You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
11 KiB
Markdown

+++
title = "Interní meteostanice v učebnách"
date = 2021-11-22
[extra]
status = 2
authors = ["David Zálešák", "Emil Miler"]
created = 2019-11-28
+++
Stavy prostředí učeben lze monitorovat na adrese [meteo.microlab.space](https://meteo.microlab.space).
---
Meteostanice jsou IoT zařízení postavené na hardwaru [HARDWARIO Tower](https://shop.hardwario.com/kits/) (dříve BigClown). Ten je vyráběný stejnojmennou českou firmou [HARDWARIO](https://www.hardwario.com/), která se zabývá vývojem vlastní IoT elektroniky. Rozhodli jsme se použít tuto elektroniku nejen proto, že se sama nabízí právě na naše použití, ale i proto, že naše katedra od firmy HARDWARIO získala darem spoustu jejich zařízení.
## Měřící jednotky
Měčící stanice jsou v podstatě postaveny jako oficiální [CO2 Monitor Kit](https://shop.bigclown.com/co2-monitor-kit/). Core modul tedy obsahuje [oficiální firmware pro CO2 Monitor Kit](https://github.com/bigclownlabs/bcf-radio-co2-monitor) a je i stejně zapojen, tj. Battery Module, CO2 module, Tagy pro měření teploty, vlhkosti a tlaku, Core Module a vpředu Cover Module. Vše je uzavřeno ve vytištěné krabičce.
Stanice odesílají data o stavu pomocí rádia.
## Server
Server je zařízení, které přijíma data o stavech měřících stanic a zároveň data zpracovává. Běží na něm MQTT broker a Node-RED, na kterém je postavené i UI.
### Instalace
Instalace proběhla podle [dokumentace](https://www.hardwario.com/academy/how-to-install-playground-on-rpi/).
### Firewall
```
apt install ufw
ufw default deny incoming
ufw allow in from <nginx-reverse-proxy-ip>
ufw enable
```
### Program a UI
Node-RED flow:
```json
[{"id":"7e6bdded.671214","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"6c54c074.21406","type":"mqtt in","z":"7e6bdded.671214","name":"","topic":"node/R013H/hygrometer/0:4/relative-humidity","qos":"2","datatype":"auto","broker":"6f3564ce.64310c","x":270,"y":120,"wires":[["550301cc.92926"]]},{"id":"550301cc.92926","type":"ui_gauge","z":"7e6bdded.671214","name":"","group":"14251a25.aba736","order":5,"width":0,"height":0,"gtype":"gage","title":"Vlhkost","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#b5b5b5","#b1cde6","#4289ca"],"seg1":"","seg2":"","x":620,"y":120,"wires":[]},{"id":"26b00bd4.85bc04","type":"ui_gauge","z":"7e6bdded.671214","name":"","group":"14251a25.aba736","order":4,"width":0,"height":0,"gtype":"gage","title":"Teplota","label":"°C","format":"{{value}}","min":"0","max":"50","colors":["#5789b5","#8fe658","#ca4244"],"seg1":"","seg2":"","x":620,"y":280,"wires":[]},{"id":"3f60372b.a3d628","type":"mqtt in","z":"7e6bdded.671214","name":"","topic":"node/R013H/co2-meter/-/concentration","qos":"2","datatype":"auto","broker":"6f3564ce.64310c","x":290,"y":200,"wires":[["9f76dbb.d4a9328","d6f199.84257e68"]]},{"id":"9f76dbb.d4a9328","type":"ui_gauge","z":"7e6bdded.671214","name":"","group":"14251a25.aba736","order":2,"width":0,"height":0,"gtype":"gage","title":"Koncentrace CO2","label":"ppm","format":"{{value}}","min":"300","max":"2000","colors":["#8fe658","#e6d260","#ca4244"],"seg1":"1000","seg2":"1500","x":650,"y":180,"wires":[]},{"id":"b76af9f2.d19eb8","type":"comment","z":"7e6bdded.671214","name":"R013H","info":"","x":390,"y":60,"wires":[]},{"id":"da1c8890.8a1bd8","type":"mqtt in","z":"7e6bdded.671214","name":"","topic":"node/R013H/thermometer/0:0/temperature","qos":"2","datatype":"auto","broker":"6f3564ce.64310c","x":280,"y":280,"wires":[["26b00bd4.85bc04"]]},{"id":"e9a764d2.7bb0c8","type":"mqtt in","z":"7e6bdded.671214","name":"","topic":"node/R013J/hygrometer/0:4/relative-humidity","qos":"2","datatype":"auto","broker":"6f3564ce.64310c","x":270,"y":460,"wires":[["270bc9ca.373656"]]},{"id":"270bc9ca.373656","type":"ui_gauge","z":"7e6bdded.671214","name":"","group":"76bb0228.e9031c","order":4,"width":0,"height":0,"gtype":"gage","title":"Vlhkost","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#b5b5b5","#b1cde6","#4289ca"],"seg1":"","seg2":"","x":620,"y":460,"wires":[]},{"id":"a920e2c8.636f3","type":"ui_gauge","z":"7e6bdded.671214","name":"","group":"76bb0228.e9031c","order":3,"width":0,"height":0,"gtype":"gage","title":"Teplota","label":"°C","format":"{{value}}","min":"0","max":"50","colors":["#5789b5","#8fe658","#ca4244"],"seg1":"","seg2":"","x":620,"y":620,"wires":[]},{"id":"c11268ab.ed1be8","type":"mqtt in","z":"7e6bdded.671214","name":"","topic":"node/R013J/co2-meter/-/concentration","qos":"2","datatype":"auto","broker":"6f3564ce.64310c","x":290,"y":540,"wires":[["774fc04c.d3757","fb1d2008.2ea4a"]]},{"id":"774fc04c.d3757","type":"ui_gauge","z":"7e6bdded.671214","name":"","group":"76bb0228.e9031c","order":1,"width":0,"height":0,"gtype":"gage","title":"Koncentrace CO2","label":"ppm","format":"{{value}}","min":"300","max":"2000","colors":["#8fe658","#e6d260","#ca4244"],"seg1":"1000","seg2":"1500","x":650,"y":520,"wires":[]},{"id":"ddfd0912.11c438","type":"comment","z":"7e6bdded.671214","name":"R013J","info":"","x":390,"y":400,"wires":[]},{"id":"c3574ac4.8ca128","type":"mqtt in","z":"7e6bdded.671214","name":"","topic":"node/R013J/thermometer/0:0/temperature","qos":"2","datatype":"auto","broker":"6f3564ce.64310c","x":280,"y":620,"wires":[["a920e2c8.636f3"]]},{"id":"24e7a4be.f1d84c","type":"mqtt in","z":"7e6bdded.671214","name":"","topic":"node/R013B/hygrometer/0:4/relative-humidity","qos":"2","datatype":"auto","broker":"6f3564ce.64310c","x":270,"y":800,"wires":[["65407316.59ff0c"]]},{"id":"65407316.59ff0c","type":"ui_gauge","z":"7e6bdded.671214","name":"","group":"50804a81.7f1004","order":5,"width":0,"height":0,"gtype":"gage","title":"Vlhkost","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#b5b5b5","#b1cde6","#4289ca"],"seg1":"","seg2":"","x":620,
```
## Reverzní proxy z Internetu
Na UI, které je v podstatě jen webová aplikace, směřuje z našeho web serveru reverzní http proxy, která aplikaci přesměruje ke klientovi.
```
location / {
proxy_pass http://<address>:<port>/ui/;
}
```
## Zobrazovač
### Konstrukce
Tělo prototypu je vygravírováno z překližky za použití laseru. LCD je z přední části chráněno polyakrilátem také vyřezaného laserem. V původní konstrukci se LCD lepilo na plexisklo, proto byli vytištěny rohové plastové separátory, které odsazují LCD od čelní desky. Všechny výkresy a modely jsou ke stažení na našem ~~[gitu](#)~~.
### Počítač
Jádrem je počítač Raspberry Pi Zero W. To jsme vybrali z důvodu malých rozměrů a integrovaného IEEE 802.11. Díky tomu nemusíme ke každému displeji tahat zvláštní síťové kabely.
#### Operační systém
Na Raspberry PI jsme zvolili systém Alpine Linux, nikoliv běžný Raspbian. Důvodem zvolení Alpine je fakt, že Debian, ze kterého vznikl Raspbian, je podle nás špatně navržený a zbytečně obrovský. Obsahuje i software, který nemáme rádi, tj. *systemd* a podobné věci.
Raspberry PI má otevřený přístup pouze na SSH a ostatní příchozí komunikace jsou blokovány. SSH je autentizováno pomocí asymetrických klíčů.
#### Kiosk mód
```sh
xinit /usr/bin/midori -e Fullscreen -a https://meteo.microlab.space
```
#### Automatické vypínání displeje
Není třeba, aby displej svítil i během doby, kdy je budova uzavřena. Ovládat power management displeje lze pomocí utility *xset*. Do systému je třeba doinstalovat balíček `x11-xserver-utils`.
Záznam v crontabu poté vypadá následovně.
```sh
0 8 * * 1-5 /usr/bin/env DISPLAY=:0 /usr/bin/xset dpms force on
0 16 * * 1-5 /usr/bin/env DISPLAY=:0 /usr/bin/xset dpms force off
```