RPi::PIGPIO::Device::MH_Z14 - Read CO2 concentration from a MH-Z14 CO2 module
Use the GPIO serial interface to read the CO2 concentration from a MM-Z14 module
250-350ppm Normal background concentration in outdoor ambient air
350-1,000ppm Concentrations typical of occupied indoor spaces with good air exchange
1,000-2,000ppm Complaints of drowsiness and poor air.
2,000-5,000 ppm Headaches, sleepiness and stagnant, stale, stuffy air. Poor concentration, loss of attention, increased heart rate and slight nausea may also be present.
5,000 Workplace exposure limit (as 8-hour TWA) in most jurisdictions.
>40,000 ppm Exposure may lead to serious oxygen deprivation resulting in permanent brain damage, coma, even death.
use RPi::PIGPIO; use RPi::PIGPIO::Device::MH_Z14; my $pi = RPi::PIGPIO->connect('192.168.1.10'); my $co2_sensor = RPi::PIGPIO::Device::MH_Z14->new($pi,mode => 'serial', tty => '/dev/ttyAMA0'); $ppm = $co2_sensor->read();
Create a new object
Usage:
my $led = RPi::PIGPIO::Device::MH_Z14->new($pi,mode => 'serial', tty => '/dev/ttyAMA0');
Arguments: $pi - an instance of RPi::PIGPIO %params - Additional params for the sensor
Currently the params must be:
%params = (mode => 'serial', tty => '<serial port>');
There are aditional modes in with you cand read data from this sensor (pwm and analog output), but this modes are not implemnted yet.
Read the CO2 concentration (in ppm - parts per milion)
Usage :
my $ppm = $sensor->read();
To install RPi::PIGPIO, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RPi::PIGPIO
CPAN shell
perl -MCPAN -e shell install RPi::PIGPIO
For more information on module installation, please visit the detailed CPAN module installation guide.