>>> Join Us in the Fight Against Air Pollution

AirGradient Forum

Compilation error of DIY_PRO_WITH_SGP40 sketch

I’ve received a DIY PRO kit, and am attempting to compile the DIY_PRO_WITH_SGP40.ino sketch for it. I chose this sketch because my kit has an SGP41 sensor.

I’ve installed the required libraries:

  • WifiManager by tzapu v2.0.11-beta
  • U8g2 by oliver v2.32.15
  • DFRobot_SGP40 by DFRobot v1.0.3
  • AirGradient Air Quality Sensor by AirGradient v2.4.3 (also tried 2.4.1 & 2.4.2)

Compilation fails with:

/Users/roens/Documents/Arduino/libraries/AirGradient_Air_Quality_Sensor/AirGradient.cpp: In member function 'TMP_RH AirGradient::returnError(TMP_RH_ErrorCode)':
/Users/roens/Documents/Arduino/libraries/AirGradient_Air_Quality_Sensor/AirGradient.cpp:684:14: warning: converting to non-pointer type 'float' from NULL [-Wconversion-null]
  684 |   result.t = NULL;
      |              ^~~~
/Users/roens/Documents/Arduino/libraries/AirGradient_Air_Quality_Sensor/AirGradient.cpp:685:15: warning: converting to non-pointer type 'int' from NULL [-Wconversion-null]
  685 |   result.rh = NULL;
      |               ^~~~
/Users/roens/Documents/Arduino/libraries/U8g2/src/clib/mui_u8g2 2.c: In function 'mui_u8g2_u8_bar_mse_msg_handler':
/Users/roens/Documents/Arduino/libraries/U8g2/src/clib/mui_u8g2 2.c:962:24: error: 'MUI_MMS_NO_WRAP' undeclared (first use in this function); did you mean 'MUI_MMS_2X_BAR'?
  962 |           if ( flags & MUI_MMS_NO_WRAP )
      |                        ^~~~~~~~~~~~~~~
      |                        MUI_MMS_2X_BAR
/Users/roens/Documents/Arduino/libraries/U8g2/src/clib/mui_u8g2 2.c:962:24: note: each undeclared identifier is reported only once for each function it appears in
/Users/roens/Documents/Arduino/libraries/U8g2/src/clib/mui_u8g2 2.c: In function 'mui_u8g2_u8_bar_mud_msg_handler':
/Users/roens/Documents/Arduino/libraries/U8g2/src/clib/mui_u8g2 2.c:1026:24: error: 'MUI_MMS_NO_WRAP' undeclared (first use in this function); did you mean 'MUI_MMS_2X_BAR'?
 1026 |           if ( flags & MUI_MMS_NO_WRAP )
      |                        ^~~~~~~~~~~~~~~
      |                        MUI_MMS_2X_BAR

exit status 1

I’m using a MacBook Pro M2, with the Arduino IDE for macOS M1/M2.

1 Like

I’ve found a solution:

Just use ESPHome for firmware for both my Pro & Outdoor air monitors. It reliably works every time (no issues of getting compile environment “just so” in order to even compile a firmware binary).

ESPHome firmware can even be configured to also echo metrics back to AirGradient for whatever that matters.

Which PCB version do you have?
The TVOC code is now also included in the normal sketch.
Please make sure you use the latest version of the Arduino library.

Same issue with V 4.2 using example 4.2 on Win Arduino IDE 2.1.2

Documents\Arduino\libraries\AirGradient_Air_Quality_Sensor\AirGradient.cpp: In member function ‘TMP_RH AirGradient::returnError(TMP_RH_ErrorCode)’:
Documents\Arduino\libraries\AirGradient_Air_Quality_Sensor\AirGradient.cpp:684:14: warning: converting to non-pointer type ‘float’ from NULL [-Wconversion-null]
684 | result.t = NULL;
| ^~~~
c:\Users\Stefan\Documents\Arduino\libraries\AirGradient_Air_Quality_Sensor\AirGradient.cpp:685:15: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
685 | result.rh = NULL;
| ^~~~

Tryed newest libs, and downgraded to recommended versions. No difference

@Stefan_Reinholdt_Jor Which PCB version do you have?

Mine is v4.2.

I’ve always found working with the Arduino IDE a trial in frustration. ESPHome, on the other hand, just works. I’ll keep both my Pro and Open Air monitors going with that, since my primary desire is to feed data into Home Assistant.

I am using the old Arduino editor (not the one they call “IDE”) and find it better -at least on Mac’s.

Please flash the sketch called " DIY_PRO_V4_2". It already contains the SGP41 code.