WeMos D1 R2 + MAX6675

This error appears to me.

libraries\MAX6675_library\max6675.cpp:5:24: fatal error: util/delay.h: No such file or directory

 #include <util/delay.h>


compilation terminated.

exit status 1
Błąd kompilacji dla płytki LOLIN(WEMOS) D1 R2 & mini.


// this example is public domain. enjoy!
// www.ladyada.net/learn/sensors/thermocouple

#include "max6675.h"

int thermoDO = 4;
int thermoCS = 5;
int thermoCLK = 6;

MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
int vccPin = 3;
int gndPin = 2;
void setup() {
  // use Arduino pins 
  pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
  pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
  Serial.println("MAX6675 test");
  // wait for MAX chip to stabilize

void loop() {
  // basic readout test, just print the current temp
   Serial.print("C = "); 
   Serial.print("F = ");

I’m guessing that you haven’t tried googling “max6675 util/delay.h” ?

This isn’t a Blynk issue although your void loop will cause Blynk issues. Read this:


I read on google but nothing solves my problem and I do not know how to do it.

It’s a problem with the MAX6675 library.
Do you have the latest version installed, and is that version the one that’s being used when you compile the code (Turn on verbose compiler messages).


It works.
The correct library max6675.cpp

// this library is public domain. enjoy!
// www.ladyada.net/learn/sensors/thermocouple

#include <avr/pgmspace.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);
  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);
    if (digitalRead(miso)) {
      //set the bit to 0 no matter what
      d |= (1 << i);

    digitalWrite(sclk, HIGH);

  return d;
1 Like