Pid.h & DS18B20.h


After getting the DS18B20 to work, I was planning to move forward in my brewing controller.

But as soon as I add the PID library, it will not compile. There might be other copy-paste issues in the code, but my main issue is that it cries “aa_brewcontroll.ino:2:17: pid.h: No such file or directory”
Here is my code:

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

#include <DS18B20.h>
//#include <math.h>

const int      MAXRETRY          = 4;
const uint32_t msSAMPLE_INTERVAL = 1000;
const uint32_t msMETRIC_PUBLISH  = 2000;

DS18B20  ds18b20(D0, true); //Sets Pin D2 for Water Temp Sensor and 
                            // this is the only sensor on bus
char     szInfo[64];
double   celsius = 0;
double   fahrenheit;
uint32_t msLastMetric;
uint32_t msLastSample;

#define RelayPin 1
//Define Variables we'll be connecting to
double Setpoint, Input, Output;

//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint,2,5,1, PID::DIRECT);

int WindowSize = 5000;
unsigned long windowStartTime;

void setup() {;
  Particle.variable("MeshTemp", celsius);
  windowStartTime = millis();
  //initialize the variables we're linked to
  Setpoint = 100;

  //tell the PID to range between 0 and the full window size
  myPID.SetOutputLimits(0, WindowSize);

  //turn the PID on

void loop() {
  if (millis() - msLastSample >= msSAMPLE_INTERVAL){

  if (millis() - msLastMetric >= msMETRIC_PUBLISH){
    Serial.println("Publishing now.");
   * turn the output pin on/off based on pid output
  if(millis() - windowStartTime>WindowSize)
  { //time to shift the Relay Window
    windowStartTime += WindowSize;
  if(Output < millis() - windowStartTime) digitalWrite(RelayPin,HIGH);
  else digitalWrite(RelayPin,LOW);

void publishData(){
  if(!ds18b20.crcCheck()){      //make sure the value is correct
  sprintf(szInfo, "%2.2f", celsius);
  Particle.publish("MeshTemp", szInfo, PRIVATE);
  msLastMetric = millis();

void getTemp(){
  float _temp;
  int   i = 0;

  do {
    _temp = ds18b20.getTemperature();
  } while (!ds18b20.crcCheck() && MAXRETRY > i++);

  if (i < MAXRETRY) {
    celsius = _temp;
    Input = celsius;
    fahrenheit = ds18b20.convertToFahrenheit(_temp);
  else {
    celsius = fahrenheit = NAN;
    Serial.println("Invalid reading");
  msLastSample = millis();

Yup, I’m seeing the same thing with multipe libraries time and time again.
I’m not sure where it’s coming from but I had some discussions with Particle about it, but haven’t yet got anything back about it.
Maybe we can ping @bsatrom to chime in.

At least good to hear that I’m not the only one struggeling with it.

looking at the Raw build output, it looks like it is not touching the second library at all. oneWire is referenced from DS18B20, so that is installed.

Processing  aa_brewcontroll.ino
Checking library DS18B20...
Installing library DS18B20 0.1.5 to lib/DS18B20 ...
Library DS18B20 0.1.5 installed.
Checking library OneWire...
Installing library OneWire 2.0.1 to lib/OneWire ...
Library OneWire 2.0.1 installed.
***-----???  Missing stuff here  ???-----***
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/aa_brewcontroll.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=1.4.4 -DRELEASE_BUILD -I./inc -I../wiring/inc -I../system/inc -I../third_party/miniz/miniz -I../services/inc -I../third_party/nanopb/nanopb -I../communication/inc -I../hal/inc -I../hal/shared -I../hal/src/photon -I../hal/src/stm32f2xx -I../hal/src/stm32 -I../hal/src/photon/api -I../hal/src/photon/include -I../hal/src/photon/wiced/security/BESL/host/WICED/ -I../hal/src/photon/wiced/security/BESL/include -I../hal/src/photon/wiced/security/BESL -I../hal/src/photon/wiced/security/BESL/crypto -I../hal/src/photon/wiced/WWD/include/ -I../hal/src/photon/wiced/platform/include/ -I../hal/src/photon/wiced/platform/GCC/ -I../hal/src/photon/wiced/security/BESL/supplicant/ -I../hal/src/photon/libraries/crypto -I../hal/src/photon/libraries/daemons/DNS_redirect -I../platform/shared/inc -I../platform/MCU/STM32F2xx/STM32_USB_Host_Driver/inc -I../platform/MCU/STM32F2xx/STM32_USB_OTG_Driver/inc -I../platform/MCU/STM32F2xx/STM32_StdPeriph_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 -Ilib/DS18B20/src -Ilib/OneWire/src -I. -MD -MP -MF ../build/target/user/platform-6-msrc/aa_brewcontroll.o.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -Wundef -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DBOOTLOADER_SDK_3_3_0_PARTICLE -DPARTICLE_DCT_COMPATIBILITY -DSPARK_PLATFORM_NET=BCM9WCDUSI09 -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc  -DLOG_INCLUDE_SOURCE_INFO=1 -DPARTICLE_USER_MODULE -DUSER_FIRMWARE_IMAGE_SIZE=0x20000 -DUSER_FIRMWARE_IMAGE_LOCATION=0x80A0000 -DMODULAR_FIRMWARE=1 -DMODULE_VERSION=6 -DMODULE_FUNCTION=5 -DMODULE_INDEX=1 -DMODULE_DEPENDENCY=4,2,1406 -DMODULE_DEPENDENCY2=0,0,0 -D_WINSOCK_H -D_GNU_SOURCE -DLOG_MODULE_CATEGORY="\"app\""  -fno-exceptions -fno-rtti -fcheck-new -std=gnu++14 -c -o ../build/target/user/platform-6-msrc/aa_brewcontroll.o src/aa_brewcontroll.cpp
aa_brewcontroll.ino:2:17: fatal error: pid.h: No such file or directory
compilation terminated.
../build/ recipe for target '../build/target/user/platform-6-msrc/aa_brewcontroll.o' failed
make[2]: *** [../build/target/user/platform-6-msrc/aa_brewcontroll.o] Error 1
make[2]: Leaving directory '/firmware/user'
../../../build/ recipe for target 'user' failed
make[1]: *** [user] Error 2
make[1]: Leaving directory '/firmware/modules/photon/user-part'
../build/ recipe for target 'modules/photon/user-part' failed
make: *** [modules/photon/user-part] Error 2

I tried to download the underlying library binary archive and I can’t extract the file. I think the archive file might be corrupted. However, since the pid library is just two files, pid.h and pid.cpp, I’d manually add the two files to your project.

Then this may affect multiple other libraries too, since that’s not the only library I found this to be the case.
It could be a conicidence but most (but not this pid tho’) the libraries I saw doing this were auto-migrated to Lib2.0 back in the days as their original repos are still Lib1.0.
Maybe the auto-migrated versions have gone missing.

I may have spoken too soon. My new Mac can’t extract the tar file, but that’s because I hadn’t installed GNU tar on it. I can extract it just fine on Linux so that’s probably not the issue. However the workaround still applies.

$ tar tf pid-2.0.0.tar -i --block-number
block 0: .
block 1: .git
block 2: LICENSE
block 72:
block 74: examples
block 75:
block 77: src
block 78: examples/PID_AdaptiveTunings
block 79: examples/PID_Basic
block 80: examples/PID_RelayOutput
block 81: src/keywords.txt
block 84: src/pid.cpp
block 99: src/pid.h
block 107: examples/PID_AdaptiveTunings/PID_AdaptiveTunings.ino
block 111: examples/PID_Basic/PID_Basic.ino
block 114: examples/PID_RelayOutput/PID_RelayOutput.ino
block 119: ** Block of NULs **
block 120: ** Block of NULs **
block 121: ** End of File **

Workaround does work, and thanks for that input. But if it was a bigger library, the usability drops alot.

PS. The samples works out of the box, but try to add another library, and at least I am hooped.

Looks like a semi-dormant library with a few open issues and open PRs. I’ll contact the owner and ask him if he’d like for us to take it over and if, so, I’ll get a fix pushed. Thanks for flagging @Arne and pinging me @ScruffR!


Just a heads up, I contacted the library owner and he’s transferred control of the repo over to us. I’m waiting on an ownership change on our end, and then I’ll push an update to fix this include issue.

1 Like

Thank you @bsatrom! Great respons!

1 Like

My pleasure @Arne. Looking deeper, I was able to reproduce your issue using the shared app link above, but when I create a new project, install both libraries and paste in your code it does compile. I am thinking there’s an issue with that particular project for some reason. :confused: Can you try creating a brand new project and see if that resolves the issue?

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