# Max6675.cpp fatal error: util/delay.h: No such file or directory compilation terminated

**URL:** <https://forum.arduino.cc/t/max6675-cpp-fatal-error-util-delay-h-no-such-file-or-directory-compilation-terminated/963573>\
**Category:** Programming\
**Created:** [February 26, 2022, 2:19am UTC](https://forum.arduino.cc/t/max6675-cpp-fatal-error-util-delay-h-no-such-file-or-directory-compilation-terminated/963573 "2022-02-26T02:19:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![arjfca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/arjfca/32/1129217_2.png) [@arjfca](https://forum.arduino.cc/u/arjfca)\
**Post date:** [February 26, 2022, 2:19am UTC](https://forum.arduino.cc/t/max6675-cpp-fatal-error-util-delay-h-no-such-file-or-directory-compilation-terminated/963573/1 "2022-02-26T02:19:45Z")

</div>

Hello

I moved to Arduino IDE 2.0 and i'm getting this error

Board is ESP32

> c:\Users\Utilisateur\Documents\Arduino\libraries\MAX6675\_library\max6675.cpp:9:24: fatal error: util/delay.h: No such file or directory  
> compilation terminated.

```arduino

I read that the *delay.h* was for AVR processor. How can I resolve this problem?

#include "max6675.h"
 
int thermoDO = 21;
int thermoCS = 19;
int thermoCLK =18;
 
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
 
void setup()
{
Serial.begin(115200);
Serial.println("MAX6675 test");
delay(2000);
}
 
void loop()
{
// basic readout test, just print the current temp
 
Serial.print("C = ");
Serial.print(thermocouple.readCelsius());
Serial.print(" F = ");
Serial.println(thermocouple.readFahrenheit());
 
delay(2000);
}

```

Any help appreciated

Martin

---

<div class="post-metadata">

**Author:** ![in0](https://avatars.discourse-cdn.com/v4/letter/i/77aa72/32.png) [@in0](https://forum.arduino.cc/u/in0)\
**Post date:** [February 26, 2022, 2:25am UTC](https://forum.arduino.cc/t/max6675-cpp-fatal-error-util-delay-h-no-such-file-or-directory-compilation-terminated/963573/2 "2022-02-26T02:25:08Z")

</div>

> [@arjfca](#):
>
> I moved to Arduino IDE 2.0

Is there anything that leads you to think the problem is related to you changing from one Arduino IDE version to another?

---

<div class="post-metadata">

**Author:** ![arjfca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/arjfca/32/1129217_2.png) [@arjfca](https://forum.arduino.cc/u/arjfca)\
**Post date:** [February 26, 2022, 2:48am UTC](https://forum.arduino.cc/t/max6675-cpp-fatal-error-util-delay-h-no-such-file-or-directory-compilation-terminated/963573/3 "2022-02-26T02:48:12Z")

</div>

Can't say what has changed.

I know that the code for this thermocouple was working and running few month ago. Did not play with this sensor since then.

I installed the new IDE few weeks ago. I was able to compile other code with IDE version 2.0. I got the problem when running the exemple for the MAX6675 thermocouple exemple.

I opened the MAX6675.cpp and replaced the line. Same problem  
**#elif defined(ESP8266)**  
for  
**#elif defined(ESP32)**

```cpp
#elif defined(ESP8266)
> // this library is public domain. enjoy!
// www.ladyada.net/learn/sensors/thermocouple

#ifdef __AVR
  #include <avr/pgmspace.h>
**#elif defined(ESP8266)**
  #include <pgmspace.h>
#endif
#include <util/delay.h>
#include <stdlib.h>
#include "max6675.h"

MAX6675::MAX6675(int8_t SCLK, int8_t CS, int8_t MISO) {
  sclk = SCLK;
  cs = CS;
  miso = MISO;

  //define pin modes
  pinMode(cs, OUTPUT);
  pinMode(sclk, OUTPUT); 
  pinMode(miso, INPUT);

  digitalWrite(cs, HIGH);
}
double MAX6675::readCelsius(void) {

  uint16_t v;

  digitalWrite(cs, LOW);
  _delay_ms(1);

  v = spiread();
  v <<= 8;
  v |= spiread();

  digitalWrite(cs, HIGH);

  if (v & 0x4) {
    // uh oh, no thermocouple attached!
    return NAN; 
    //return -100;
  }

  v >>= 3;

  return v*0.25;
}

double MAX6675::readFahrenheit(void) {
  return readCelsius() * 9.0/5.0 + 32;
}

byte MAX6675::spiread(void) { 
  int i;
  byte d = 0;

  for (i=7; i>=0; i--)
  {
    digitalWrite(sclk, LOW);
    _delay_ms(1);
    if (digitalRead(miso)) {
      //set the bit to 0 no matter what
      d |= (1 << i);
    }

    digitalWrite(sclk, HIGH);
    _delay_ms(1);
  }

  return d;
}

```

---

<div class="post-metadata">

**Author:** ![in0](https://avatars.discourse-cdn.com/v4/letter/i/77aa72/32.png) [@in0](https://forum.arduino.cc/u/in0)\
**Post date:** [February 26, 2022, 3:14am UTC](https://forum.arduino.cc/t/max6675-cpp-fatal-error-util-delay-h-no-such-file-or-directory-compilation-terminated/963573/4 "2022-02-26T03:14:26Z")

</div>

I can see you are using an outdated version of the MAX6675 library, which is missing this important change:

> <https://github.com/adafruit/MAX6675-library/commit/e4b95aa5d3098fa5f323411a58334f0d40a6cd08>

Please follow these instructions to update to the latest version of the library:

1. Select **Sketch \> Include Library \> Manage Libraries...** from the Arduino IDE menus to open the " **Boards Manager**" view in the left side panel.

2. In the " **Filter your search**" field, type `max6675 library`

3. Scroll down through the list of libraries until you see " **MAX6675 library by Adafruit**". Click on it.

4. Select " **1.1.0**" from the dropdown version menu.

5. Click the INSTALL button.

6. You will now get a dialog asking:

7. Wait for the installation to finish.

8. Select **Sketch \> Include Library \> Manage Libraries...** from the Arduino IDE menus to close the " **Boards Manager**" view in the left side panel.

Now try compiling your sketch again. It should work without the error. There will be no need to modify the library.

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [February 26, 2022, 11:34am UTC](https://forum.arduino.cc/t/max6675-cpp-fatal-error-util-delay-h-no-such-file-or-directory-compilation-terminated/963573/5 "2022-02-26T11:34:23Z")

</div>

@arjfca, your topic has been moved to a more suitable location on the forum. _Installation and Troubleshooting_ is not for problems with (nor for advise on) your project 😉 See [About the Installation & Troubleshooting category](https://forum.arduino.cc/t/about-the-installation-troubleshooting-category/847458).

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [August 25, 2022, 11:35am UTC](https://forum.arduino.cc/t/max6675-cpp-fatal-error-util-delay-h-no-such-file-or-directory-compilation-terminated/963573/6 "2022-08-25T11:35:19Z")

</div>

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