-
Notifications
You must be signed in to change notification settings - Fork 37
module
pip install mh_z19
import mh_z19
Read CO2 concentration and return as following json string: {'co2': 583}
read_all(serial_console_untouched=False)
Read CO2 consentration and undocumented other values.
Read CO2 value from PWM interface, not Serial port.
gpio: The gpio pin number for reading. the numbering is by BCM system. The default value is 12. range: The range value to pass to the sensor module. The default vaule is 5000.
Compute the Checksum for the array of int value and return as packed value for unsigned char
I'm afraid the following functions are not tested due to the lack of necessary devices and apparatus for the test. I'll really appreciate it if some kind person who has the necessary stuff tries following functions and tell me the result as a issue report, thank you!
abc_on(serial_console_untouched=False)
The command 0x79 ON/OFF Auto Calibration on the Software Section on the DataSheet. This function set ABC as ON.
abc_off(serial_console_untouched=False)
The command 0x79 ON/OFF Auto Calibration on the Software Section on the DataSheet. This function set ABC as OFF.
span_point_calibration(span, serial_console_untouched=False)
The command 0x88 Calibrate Span Point (SPAN) on the Software Section on the DataSheet.
zero_point_calibration(serial_console_untouched=False)
The command 0x87 Calibrate Span Point (ZERO) on the Software Section on the DataSheet.
detection_range_10000(serial_console_untouched=False)
The command 0x99 Detection range setting on the Software Section on the DataSheet. This function set range as 10000.
detection_range_5000(serial_console_untouched=False)
The command 0x99 Detection range setting on the Software Section on the DataSheet. This function set range as 5000.
detection_range_2000(serial_console_untouched=False)
The command 0x99 Detection range setting on the Software Section on the DataSheet. This function set range as 2000.
In default, the default serial port on the Raspberry Pi is occupied by the serial console for debugging. To send commands to sensor module via serial port, need to rent serial port from the serial console as stop serial console temporary during send command and read a response, then reopen serial console.
If you are using the serial port, or you've stopped the serial console by yourself, the temporal stopping of the serial console is meaningless or harmful in some cases. In these case, set this param as true
.
In default, serial device selected automatically as follows:
-
/dev/serial0
if exist - or else
-
/dev/ttyS0
in case RPi model is3 Model B
,4 Model B
or "Zero W" - or else
/dev/ttyAMA0
-
-code
Set serial device file passed by parameter to use. Parameter device
is a string of full path device file name like /dev/ttyAMA0
.
-code