Compiler Error: Library from Web IDE not being included in compile

Hi Particle Community!

I am trying to create a new piece of code for a Particle Photon via the Web IDE. However, the code will not compile. It appears to be erroring out for the PietteTech_DHT library despite the fact that it was added to the Libraries page on the Web IDE view.

I’ve posted the compiler error below and the code. Looks like the PietteTech library isn’t being included somehow. NOTE: The code below was working fine before I added the components for the DHT22 sensor and the PietteTech_DHT library. You can also get a text file of the code here.

I also tried the clear-cache - logout/login solution with no results.

Any ideas what might be causing this?

Thank you in advance for the help!
Gordon
Boston, MA

Error Message (after hitting “Show Raw” in the Web IDE):

     Processing  smartplant_v4.ino
     Checking library PowerShield...
     Checking library Ubidots...
     Installing library PowerShield 0.0.5 to lib/PowerShield ...
     Installing library Ubidots 2.1.12 to lib/Ubidots ...
     Library PowerShield 0.0.5 installed.
     Library Ubidots 2.1.12 installed.
     make -C ../modules/photon/user-part all
     make[1]: Entering directory '/firmware/modules/photon/user-part'
     make -C ../../../user 
     make[2]: Entering directory '/firmware/user'
     Building cpp file: src/smartplant_v4.cpp
     Invoking: ARM GCC CPP Compiler
     mkdir -p ../build/target/user/platform-6-msrc/
     arm-none-eabi-gcc -DSTM32_DEVICE -DSTM32F2XX -DPLATFORM_THREADING=1 -DPLATFORM_ID=6 -          DPLATFORM_NAME=photon -DUSBD_VID_SPARK=0x2B04 -DUSBD_PID_DFU=0xD006 -DUSBD_PID_CDC=0xC006 -DSPARK_PLATFORM -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb -DINCLUDE_PLATFORM=1 -DPRODUCT_ID=6 -DPRODUCT_FIRMWARE_VERSION=65535 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DSYSTEM_VERSION_STRING=0.6.2 -DRELEASE_BUILD -I./inc -I../wiring/inc -I../system/inc -I../services/inc -I../communication/src -I../hal/inc -I../hal/shared -I../hal/src/photon -I../hal/src/stm32f2xx -I../hal/src/stm32 -I../hal/src/photon/api -I../platform/shared/inc -I../platform/MCU/STM32F2xx/STM32_USB_Host_Driver/inc -I../platform/MCU/STM32F2xx/STM32_StdPeriph_Driver/inc -I../platform/MCU/STM32F2xx/STM32_USB_OTG_Driver/inc -I../platform/MCU/STM32F2xx/STM32_USB_Device_Driver/inc -I../platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc -I../platform/MCU/shared/STM32/inc -I../platform/MCU/STM32F2xx/CMSIS/Include -I../platform/MCU/STM32F2xx/CMSIS/Device/ST/Include -I../dynalib/inc -Isrc -I./libraries -Isrc -Isrc -Isrc -Isrc -Ilib/Ubidots/src -Ilib/PowerShield/src -I. -MD -MP -MF ../build/target/user/platform-6-msrc/smartplant_v4.o.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DSPARK_PLATFORM_NET=BCM9WCDUSI09 -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc  -DLOG_INCLUDE_SOURCE_INFO=1 -DPARTICLE_USER_MODULE -DUSE_THREADING=0 -DUSE_SPI=SPI -DUSE_CS=A2 -DUSE_SPI=SPI -DUSE_CS=A2 -DUSE_THREADING=0 -DUSER_FIRMWARE_IMAGE_SIZE=0x20000 -DUSER_FIRMWARE_IMAGE_LOCATION=0x80A0000 -DMODULAR_FIRMWARE=1 -DMODULE_VERSION=4 -DMODULE_FUNCTION=5 -DMODULE_INDEX=1 -DMODULE_DEPENDENCY=4,2,108 -D_WINSOCK_H -D_GNU_SOURCE -DLOG_MODULE_CATEGORY="\"app\""  -fno-exceptions -fno-rtti -fcheck-new -std=gnu++11 -c -o      ../build/target/user/platform-6-msrc/smartplant_v4.o src/smartplant_v4.cpp
     smartplant_v4.ino:15:76: fatal error: PietteTech_DHT/PietteTech_DHT.h: No such file or directory
     compilation terminated.
     ../build/module.mk:267: recipe for target '../build/target/user/platform-6-msrc/smartplant_v4.o' failed
     make[2]: *** [../build/target/user/platform-6-msrc/smartplant_v4.o] Error 1
     make[2]: Leaving directory '/firmware/user'
     ../../../build/recurse.mk:11: recipe for target 'user' failed
     make[1]: *** [user] Error 2
     make[1]: Leaving directory '/firmware/modules/photon/user-part'

Code for Photon:

    // -----------------------------------------
    // SmartPlant31 - ver 4
    // Created 9/11/17 by Gordon Strodel
    // -----------------------------------------

    #include "PietteTech_DHT/PietteTech_DHT.h"  // Uncomment if building in IDE
    //#include "PietteTech_DHT.h"                 // Uncomment if building using CLI

    #define DHTTYPE DHT22       // Sensor type DHT11/21/22/AM2301/AM2302
    #define DHTPIN 4           // Digital pin for communications

    // This #include statement was automatically added by the Particle IDE.
    #include <Ubidots.h>

    // Particle Ubidots cloud-based dashboard, see Ubidots.h
    #define TOKEN "token removed"
    Ubidots ubidots(TOKEN);

    // This #include statement was automatically added by the Particle IDE.
    #include <PowerShield.h>

    //Pin Definitions
    int boardLed = D7; // blue board LED
    int cap_sensor = A2; //Capacitive Soil Sensor
    int temperature = 0; // DHT Temp in C
    int temperatureF = 0; // DHT Temp in F
    int humidity = 0; // DHT Humidity

    //STARTUP(WiFi.selectAntenna(ANT_EXTERNAL)); // selects the u.FL antenna
    PowerShield batteryMonitor; //Initiates the power shield

    // Initialize Startup Variables
    int cap_sensor_val = 0; 
    int cap_sensor_val_prev = 0; //previously recorded capacitive sensor value
    int cap_sensor_diff = 0; //variable for storing the difference in sensor values
    char cap_sensor_string[128]; //string used to output the cap sensor value to the PUBLISH() function
    int tweet_threashold_val = 2100; //raw sensor value for which you should tweet
    String datetime_str; // string for current time to capture the timestamp of the sensor reading
    String prev_tweet_time_str; //string for when the app last tweeted (or published for the sake of tweeting) about the sensor value

    PietteTech_DHT dht(DHTPIN, DHTTYPE); //initialized the DHT code

    // This wrapper is in charge of calling
    // must be defined like this for the lib work
    void dht_wrapper() {	dht.isrCallback(); }
    void setup() {
     }
        void loop() {

    Particle.process();
    Wire.begin(); 
    Time.zone(-5);  // Set time zone to Eastern USA time
    batteryMonitor.reset();
    batteryMonitor.quickStart();
    delay(1000);
    float cellVoltage = batteryMonitor.getVCell();
    float stateOfCharge = batteryMonitor.getSoC();
    delay(100);
    Particle.publish("ps-voltage", String(cellVoltage), 60, PRIVATE);
    delay(5000);
    Particle.publish("ps-soc", String(stateOfCharge), 60, PRIVATE);
    delay(5000);
	
    // Start DHT sensor
    dht.begin();
	
	pinMode(boardLed,OUTPUT); // Our on-board LED is output as well
    pinMode(cap_sensor, INPUT); //Capacitive Sensor is an input
    cap_sensor_val = analogRead(cap_sensor); // read sensor
    cap_sensor_diff = abs(cap_sensor_val - cap_sensor_val_prev); //Take difference between current reading and previous reading
    datetime_str = Time.timeStr();
    
    // Temperature measurement
    temperature = dht.getCelsius();
    temperatureF = dht.getFahrenheit();     //temperatureF = (9.0/5.0 * temperature) + 32.0;
    // Humidity measurement
    humidity = dht.getHumidity();
    
    // Check if any reads failed and exit early (to try again).
	if (isnan(humidity) || isnan(temperature) || isnan(temperatureF)) {
		Particle.publish("DEBUG","Failed to read from DHT sensor!");
		return;
	}
            
    // Send a publish...for Photon Cloud
    Particle.publish("temperature", String(temperature) + " °C");
    delay(1000);
    Particle.publish("temperature", String(temperatureF) + " °F");
    delay(1000);    
    Particle.publish("humidity", String(humidity) + "%");
    delay(1000);
    Particle.publish("Cap_Sensor_Value",String(cap_sensor_val),60,PRIVATE);
    delay(1000);
    Particle.publish("Cap_Sensor_Prev_Value",String(cap_sensor_val_prev),60,PRIVATE);
    delay(1000);
    Particle.publish("Diff_btw_Values",String(cap_sensor_diff),60,PRIVATE);
    delay(1000);
    Particle.publish("Time_of_Soil_Reading",datetime_str,60,PRIVATE);
    delay(1000);
     
    // Publish a new Event for Tweeting if the plant needs water
    if  (cap_sensor_val >= tweet_threashold_val and cap_sensor_val_prev < tweet_threashold_val /*and cap_sensor_diff >= 10*/) { 
    Particle.publish("Tweet_Notification",String(cap_sensor_val),60,PRIVATE);
    delay(1000);
    Particle.publish("Prev_Tweet_Time",prev_tweet_time_str,60,PRIVATE);
    delay(1000);
    prev_tweet_time_str = datetime_str;
    }
    else {
    Particle.publish("Tweet_Notification_Null","Last tweet at: "+prev_tweet_time_str,60,PRIVATE);
    delay(1000);   
    }
        
	//Reset for Next Run
    cap_sensor_val_prev = cap_sensor_val;   
        
    //Report to Ubidots
    ubidots.add("Cell_Voltage", cellVoltage);
    ubidots.add("State_of_Charge", stateOfCharge);
    ubidots.add("Cap_Sensor_Value", cap_sensor_val);
    ubidots.add("temperature", temperature);
    ubidots.add("temperatureF", temperatureF);
    ubidots.add("humidity", humidity);
    ubidots.sendAll();
    delay(5000);
      
    System.sleep(SLEEP_MODE_DEEP, 1200); // 1200 = 20min, 300 = 5min

}

Thank you again for the help (And for reading this far!)
G

To allow for testing your exact project structure you can use the SHARE THIS REVISION button an post the link.

BTW, the include needs to lose the path portion and your system firmware target should be set to 0.5.2+ (currently best 0.6.2)
For a while now #include "library.h" (or <library.h>) is the way you need to use in both CLI and Web IDE.

Thanks for the quick response Scruff! Here is a shareable link from the Web IDE: https://go.particle.io/shared_apps/59b6db92ce6ba1624b0006b0

Also, I tried both #include "library.h" and #include "PietteTech_DHT/PietteTech_DHT.h" without any change in the compiler error.

And my Photon is running 0.6.2 on the device. :slight_smile:

@macyankee86, the correct syntax is #include <PietteTech_DHT.h>. :wink:

Hi @peekay123-

I tried #include <PietteTech_DHT.h> with no luck. I still get the following error in the Web IDE: :frowning:

Processing  smartplant_v4.ino
Checking library PowerShield...
Checking library Ubidots...
Installing library Ubidots 2.1.12 to lib/Ubidots ...
Library Ubidots 2.1.12 installed.
Installing library PowerShield 0.0.5 to lib/PowerShield ...
Library PowerShield 0.0.5 installed.

Building cpp file: src/smartplant_v4.cpp
Invoking: ARM GCC CPP Compiler
mkdir -p ../build/target/user/platform-6-msrc/
...../build/target/user/platform-6-msrc/smartplant_v4.o src/smartplant_v4.cpp
smartplant_v4.ino:16:79: fatal error: PietteTech_DHT.h: No such file or directory

Thanks for the quick reply!
Gordon

@peekay123, @ScruffR

FYI - I tried the solution from this thread and it worked! Odd.

Thread with solution: Library - No such file or directory error

Steps to resolve:

  1. Create a new project file
  2. Add in the libraries (Ubidots, DHT, Powershield)
  3. Copy and past all code (exact same code)
  4. Compile
  5. Working

Thank you very much for the quick help. Guess a lot more searching was in order… :frowning:

Best,
Gordon

2 Likes