2016/07/31

Adafruit Max6675 Library For Thermocouple Need To Be Modified To Run On ESP8266

Test the sketch "Wiring Thermocouple Max6675 on ESP8266 12E NodeMCU" of 14Core, and find Adafruit MAX6675 library installed using Library Manager is not compatible with ESP8266.

By replacing max6675.h and max6675.cpp with the ones from SirUli on github, copying other files on the link and commenting out the statements relating display functions, the sketch of 14Core has been compiled and run without fail on NodeMCU Dev Kit 1.0.

Also the serialthermocoupl.pde example sketch runs without fail.

I think the tutorials of 14Core had better specify from where the library they downloaded.

Wiring from 14Core



Output


Sketch

#include <max6675.h>
// #include <Wire.h>
// #include <Adafruit_GFX.h>
// #include <ESP_Adafruit_SSD1306.h>

// #define OLED_RESET 4

int ktcSO = 12;
int ktcCS = 13;
int ktcCLK = 14;

MAX6675 ktc(ktcCLK, ktcCS, ktcSO);
// Adafruit_SSD1306 display(OLED_RESET);
  
void setup() {
  Serial.begin(115200);
  Serial.println("Max6675 test");
  delay(500);
  // display.begin(SSD1306_SWITCHCAPVCC, 0x78>>1);
  // display.display();
  // delay(2000);
  // display.clearDisplay();
}

void loop() {
  // basic readout test
  //  
  //  display.setTextSize(2);
  //  display.setTextColor(WHITE);
  //  display.setCursor(52,10);
  //  display.print((char)223); 
  //  display.print("C = "); 
  //  display.print(ktc.readCelsius());
  //  display.print((char)223); 
  //  display.print("\t F = ");
  //  display.setCursor(52,30);
  //  display.println(ktc.readFahrenheit());

  float DC = ktc.readCelsius();
  // Read temperature as Celsius
  float DF = ktc.readFahrenheit();
  
   Serial.print("C = "); 
   Serial.print(ktc.readCelsius());
   Serial.print("\t F = ");
   Serial.println(ktc.readFahrenheit());
// 

 delay(1000);
 // displayData();
}

void displayData(){
  // display.setTextSize(1);
  // display.setCursor(5,1);
  // display.println("14CORE|THERMOCOUPLE");
  // display.setTextSize(2);
  // display.setTextColor(WHITE);
  // display.setCursor(18,20);
  // display.print((char)248); 
  // display.print("C:"); 
  // display.print(ktc.readCelsius());
  
    
  // display.setCursor(18,40);
  // display.print((char)248); 
  // display.print("F:");
  // display.println(ktc.readFahrenheit());
  // display.display();
  // display.clearDisplay();
}

9 comments:

  1. Doesn't work((
    Try on esp12f
    int ktcSO = 8;
    int ktcCS = 7;
    int ktcCLK = 5;

    ReplyDelete
  2. int ktcSo = D8; // GPIO 15
    int ktcCS = D7; // GPIO 13
    int ktcCLK = D5; // GPIO 14

    ReplyDelete
  3. I've built this, it reads temperatures fine, but the text looks like it's superimposed on itself on the OLED. Any ideas on fixes?

    ReplyDelete
  4. Thanks worked fine for me. This saved me a lot of time

    ReplyDelete
  5. Thanks for sharing, nice post! Post really provice useful information!

    An Thái Sơn chuyên võng điện máy đưa võng hay võng điện cho bé và chia sẻ kinh nghiệm giúp quý khách biết cục điện đưa võng giá bao nhiêu cũng như máy đưa võng loại nào tốt nhất cho giấc ngủ của bé.

    ReplyDelete
  6. Where did you create this schematic? What's the software name?

    ReplyDelete
    Replies
    1. https://www.14core.com/wiring-thermocouple-max6675-on-esp8266-12e-nodemcu/

      Delete
  7. https://www.14core.com/wiring-thermocouple-max6675-on-esp8266-12e-nodemcu/

    ReplyDelete