Merge pull request #10351 from jaapgvk/development

Add full support for the 10000 ppm version of the Winsen MH-Z19B Infrared CO2 Sensor Module
This commit is contained in:
Theo Arends 2021-01-02 16:26:00 +01:00 committed by GitHub
commit de299fd87b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -74,7 +74,7 @@ const char kMhzModels[] PROGMEM = "|B";
const char ABC_ENABLED[] = "ABC is Enabled";
const char ABC_DISABLED[] = "ABC is Disabled";
enum MhzCommands { MHZ_CMND_READPPM, MHZ_CMND_ABCENABLE, MHZ_CMND_ABCDISABLE, MHZ_CMND_ZEROPOINT, MHZ_CMND_RESET, MHZ_CMND_RANGE_1000, MHZ_CMND_RANGE_2000, MHZ_CMND_RANGE_3000, MHZ_CMND_RANGE_5000 };
enum MhzCommands { MHZ_CMND_READPPM, MHZ_CMND_ABCENABLE, MHZ_CMND_ABCDISABLE, MHZ_CMND_ZEROPOINT, MHZ_CMND_RESET, MHZ_CMND_RANGE_1000, MHZ_CMND_RANGE_2000, MHZ_CMND_RANGE_3000, MHZ_CMND_RANGE_5000, MHZ_CMND_RANGE_10000 };
const uint8_t kMhzCommands[][4] PROGMEM = {
// 2 3 6 7
{0x86,0x00,0x00,0x00}, // mhz_cmnd_read_ppm
@ -85,7 +85,8 @@ const uint8_t kMhzCommands[][4] PROGMEM = {
{0x99,0x00,0x03,0xE8}, // mhz_cmnd_set_range_1000
{0x99,0x00,0x07,0xD0}, // mhz_cmnd_set_range_2000
{0x99,0x00,0x0B,0xB8}, // mhz_cmnd_set_range_3000
{0x99,0x00,0x13,0x88}}; // mhz_cmnd_set_range_5000
{0x99,0x00,0x13,0x88}, // mhz_cmnd_set_range_5000
{0x99,0x00,0x27,0x10}}; // mhz_cmnd_set_range_10000
uint8_t mhz_type = 1;
uint16_t mhz_last_ppm = 0;
@ -135,7 +136,7 @@ bool MhzCheckAndApplyFilter(uint16_t ppm, uint8_t s)
if (1 == s) {
return false; // S==1 => "A" version sensor bootup, do not use values.
}
if (mhz_last_ppm < 400 || mhz_last_ppm > 5000) {
if (mhz_last_ppm < 400 || mhz_last_ppm > 10000) {
// Prevent unrealistic values during start-up with filtering enabled.
// Just assume the entered value is correct.
mhz_last_ppm = ppm;
@ -269,6 +270,7 @@ void MhzEverySecond(void)
#define D_JSON_RANGE_2000 "2000 ppm range"
#define D_JSON_RANGE_3000 "3000 ppm range"
#define D_JSON_RANGE_5000 "5000 ppm range"
#define D_JSON_RANGE_10000 "10000 ppm range"
bool MhzCommandSensor(void)
{
@ -309,6 +311,10 @@ bool MhzCommandSensor(void)
MhzSendCmd(MHZ_CMND_RANGE_5000);
Response_P(S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, D_JSON_RANGE_5000);
break;
case 10000:
MhzSendCmd(MHZ_CMND_RANGE_10000);
Response_P(S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, D_JSON_RANGE_10000);
break;
default:
if (!Settings.SensorBits1.mhz19b_abc_disable) {
Response_P(S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, ABC_ENABLED);