This is an extension for the MagicMirror².
It monitors CO2 level from MH-Z19 sensor and draws a chart for a few last hours.
-
Navigate into your MagicMirror's
modules
folder -
Clone repository
git clone https://github.com/awitwicki/MMM-MHZ19
-
Go to newly created directory
-
Execute
npm install
to install the node dependencies.
If you got error, try to execute
npm install chartjs
- Connect the MH-Z19 to your Raspberry Pi
Raspberry pi | MH-Z19 |
---|---|
GPIO 17 | PWM |
Ground | GND |
5V power | VIN |
Add it to the modules array in the config/config.js
file:
modules: [
...
{
module: 'MMM-MHZ19',
position: 'top_left',
config: {
updateInterval: 100 //seconds
}
},
...
]
Configurations properties
Property | Description |
---|---|
titleText |
Type string , Default value Home weather |
updateInterval |
Type int , Default value 100 , Minimal value 10 , Wait interval between readings of BME280 sensor values in seconds |
For more details about BCM pin numbers check here
-
python3
(should be installed on Raspberry Pi) -
RPi.GPIO
(Python library, should be installed on Raspberry Pi )
- Navigate into your MagicMirror folder
- Run .sh script
./modules/MMM-MHZ19/mh_z19.sh
(If script doesn't run, add exec parameter to it)sudo chmod +x modules/MMM-MHZ19/mh_z19.sh
. - Script should print sensor values like this
566
- that meansCO2 PPM in air
Notice that MH-Z19 module can return small values (<400 PPM) continuously in a few seconds after hardware module was started (by connecting power voltage pin).