Showing posts with label Modify. Show all posts
Showing posts with label Modify. Show all posts

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();
}