Compile problem with Temp & humidity sensor SI7021: fatal error: pgmspace.h: No such file or directory

Hi, I am working on a project using the TinyZero board with the TinyShield Combo Sensor which includes the Temperature & humidity sensor SI7021.

Currently I am just playing around with the following code:

#include <Wire.h>
#include <SI7021.h>

SI7021 sensor;

// Make Serial Monitor compatible for all TinyCircuits processors
#if defined(ARDUINO_ARCH_AVR)
  #define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
  #define SerialMonitorInterface SerialUSB
#endif

void setup() {
  SerialMonitorInterface.begin(115200);
  Wire.begin();
  SerialMonitorInterface.print("Initializing sensor... ");
  if(!sensor.begin()){
    SerialMonitorInterface.println("Sensor not found!");
    while(true);
  }
  SerialMonitorInterface.println("Success!");

  // this driver should work for SI7020 and SI7021, this returns 20 or 21
  int deviceid = sensor.getDeviceId();
//    SerialMonitorInterface.println(deviceid);
}

void loop() {
    // read and print temp and humidity
    float temperature = sensor.getCelsiusHundredths() / 100.0;
    SerialMonitorInterface.print(temperature);
    SerialMonitorInterface.print(" deg Celsius\t");
    int humidity = sensor.getHumidityPercent();
    SerialMonitorInterface.print(humidity);
    SerialMonitorInterface.println("% relative humidity");

    // enable internal heater for testing
    sensor.setHeater(true);
    delay(30000);
    sensor.setHeater(false);
    
    // see if heater changed temperature
    // read and print temp and humidity
    temperature = sensor.getCelsiusHundredths() / 100.0;
    SerialMonitorInterface.print(temperature);
    SerialMonitorInterface.print(" deg Celsius\t");
    humidity = sensor.getHumidityPercent();
    SerialMonitorInterface.print(humidity);
    SerialMonitorInterface.println("% relative humidity -- (after heater on)");
    
    //cool down
    delay(30000);

    // get humidity and temperature in one shot, saves power because sensor takes temperature when doing humidity anyway
//    si7021_env data = sensor.getHumidityAndTemperature();
//    delay(5000);
}

When I click on the "upload" button, I receive the following error message:

In file included from /Users/migueljauregui/Documents/Arduino/temp_humedad/temp_humedad.ino:2:0:
/Users/migueljauregui/Documents/Arduino/libraries/SI7021-master/SI7021.h:26:12: fatal error: pgmspace.h: No such file or directory
   #include <pgmspace.h>
            ^~~~~~~~~~~~
compilation terminated.

exit status 1

Compilation error: exit status 1

I do not know how to solve this issue, any help would be really appreciated.

Thanks,
Mike

The library header file shows:

#ifdef __AVR_ATtiny85__
 #include "TinyWireM.h"
 #define Wire TinyWireM
#elif defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
 #include <Wire.h>
#else
 #if (defined(__AVR__)) || defined(ARDUINO_ARCH_NRF5)
  #include <avr/pgmspace.h>
 #else
  #include <pgmspace.h>
 #endif
 #include <Wire.h>
#endif

So if it's gonna include "pgmspace.h" it's because you use none of the listed boards (neither an ATtiny, nor ESPs, and not any AVR-based one). As I don't have ever used a TinyZero board, I can just suspect that library isn't compatible, or it isn't unless you identify what it needs from your board (pgmspace usually handles PROGMEM so give a try looking in your specific board definitions).
Sorry, I can't say more.

1 Like

Thanks a lot, I was able to solve the issue by removing and re-installing the sensor library.

Have a good one!

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.