Skip to content

arduino sample sketch for ESP32 (here: LILYGO TTGO-T w. color oled) to measure CO2 concentration

License

Notifications You must be signed in to change notification settings

lefty01/ESP32_TTGO_CO2_Ampel

Repository files navigation

ESP32 TTGO CO2-Ampel

arduino sample sketch for ESP32 (here: LILYGO TTGO-T w. color oled) to measure CO2 concentration and display value on TFT, as well as use an 8-Bit RGB-LED-Ring to show/indicate CO2 concentration (ppm). In addition the value is published to an mqtt broker (using tls/ssl).

The LED-ring indicates green as good, yellow is warning level and red is critical.

It uses MH_Z19 sensor. During pre-heating (3 minutes) the LEDs show some spinning blue "wheel".

CO2 Thresholds (ppm).

Recommendation from REHVA (Federation of European Heating, Ventilation and Air Conditioning associations, rehva.eu) for preventing COVID-19 aerosol spread especially in schools:

General air quality recommendation by the German Federal Environmental Agency (2008):

Requirements / Dependencies / Parts used

Parts

Arduino Libraries

  • arduinoota.h
  • fastled.h
  • tft_espi.h
  • wifi.h
  • pubsubclient.h
  • softwareserial.h
  • mhz.h

Features / Ideas

On-Screen (mqtt published) value display

On a Linux Desktop one could use a command like the following to have the co2 value displayed "on-screen" and even swith color (via mqtt) using osd_cat.

threshold_val=1000
threshold=0

while read co2val; do
    color='#0F0'
    if [ $co2val -gt $threshold_val -a $threshold -eq 0 ]; then
    color='#F00'
    fi
    if [ $co2val -lt $threshold_val -a $threshold -eq 1 ]; then
    color='#0F0'
    fi
    echo $co2val | osd_cat -p top -A center -o 25 -i -50 -f '-*-liberation mono-*-*-*-*-40-*-*-*-*-*-*-*' -s 2 -c $color;
done < <(mosquitto_sub -h yourhost.de -p 8883 -u username -P passw0rd --cafile myCA.pem --cert client.crt --key client.key -t co2_ampel1/co2ppm)

OTA

Issue

OTA failed: no response from device (icmp type 3, code 13)

Fix

could be related to firewall rules, try either one of

$ sudo iptables -I INPUT  -s 192.168.1.123 -j ACCEPT
$ sudo iptables -I OUTPUT -d 192.168.1.123 -j ACCEPT

or

$ firewall-cmd --zone=trusted --add-source=192.168.1.123

I read that people also have similar issues (destination unreachable) when on different wifi networks (2.4GHz vs 4GHz) but at least here that is not a problem (esp on 2.4GHz and laptop on 5GHz)

Pictures

CO2 Ampel pre-heating CO2 Ampel green

About

arduino sample sketch for ESP32 (here: LILYGO TTGO-T w. color oled) to measure CO2 concentration

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published