MH-Z19 icon indicating copy to clipboard operation
MH-Z19 copied to clipboard

library fails with CORE_DEBUG_LEVEL=3

Open hpsaturn opened this issue 1 year ago • 1 comments

Overview

The library fails when the debug level is increased, when you define CORE_DEBUG_LEVEL=3 for example, its necessary pass the TAG like this: '-D TAG_MHZ19="MHZ19"' on PlatformIO ini file for example.

.pio/libdeps/M5STICKCPLUS/MH-Z19/src/MHZ19.cpp: In member function 'void MHZ19::begin(Stream&)':
.pio/libdeps/M5STICKCPLUS/MH-Z19/src/MHZ19.cpp:37:18: error: 'TAG_MHZ19' was not declared in this scope
         ESP_LOGE(TAG_MHZ19, "Initial communication errorCode recieved");

hpsaturn avatar Jul 28 '22 10:07 hpsaturn

ESP_LOGX and the TAG_MHZ19 definition, both require the ESP32 definition to be set, so that's quite odd.

It might be worth moving the lines below to the top of the .cpp file, just in case they are being compiled differently. https://github.com/WifWaf/MH-Z19/blob/49658e5938669c5a54b6b8456611d0afbb5b90b0/src/MHZ19.h#L8-L11

I'll try and look at this soon if no luck, otherwise I'll push the fix.

WifWaf avatar Jul 28 '22 23:07 WifWaf