Hi,
I am running two of these:
with these:
http://www.ebay.com/itm/K-Type-10cm-Probe-Thermocouple-Temperature-Measurement-Sensor-70cm-/310570751975?pt=LH_DefaultDomain_0&hash=item484f7597e7
and an SPI OLED display.
The wireing is quite straightforward:
//SPI
const byte SPI_CLK = 13;
const byte SPI_MOSI = 11;
const byte SPI_MISO = 12;
//OLED
const byte OLED_CS = 7;
const byte OLED_DC = 8;
const byte OLED_RESET = 9;
//Thermocouple
const byte TC1_CS = 2;
const byte TC2_CS = 4;
That is, they all share CLK, the two thermocouple amplifiers share MISO. The full code (with some preparations for further functionality) is below.
Now, unfortunately, I get alot of NAN from the thermocouples. Every maybe 30 seconds, a reading is successful, and the temperature is plausible. I would assume that the cheap thermocouples are just garbage, but the strange thing is: successful reading are highly correlated. They haven at the same time or at least within one or two seconds in 95% of the time. That doesn't seem to be something that happens through defective tp ... any idea, anyone?
If I just disconnect one thermocouple, it is not better in any way.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_MAX31855.h>
#include <Servo.h>
#include <CapacitiveSensor.h>
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
//SPI
const byte SPI_CLK = 13;
const byte SPI_MOSI = 11;
const byte SPI_MISO = 12;
//OLED
const byte OLED_CS = 7;
const byte OLED_DC = 8;
const byte OLED_RESET = 9;
//Thermocouple
const byte TC1_CS = 2;
const byte TC2_CS = 4;
//Servo
const byte SERVO = 4;
//Buttons
const byte BUT_SEND = 5;
//Adafruit_SSD1306 display(SPI_MOSI, SPI_CLK, OLED_DC, OLED_RESET, OLED_CS);
Adafruit_SSD1306 display(11, 13, 8, 9, 7);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
static unsigned char PROGMEM logo16_glcd_bmp[] =
{ B00000000, B11000000,
B00000001, B11000000,
B00000001, B11000000,
B00000011, B11100000,
B11110011, B11100000,
B11111110, B11111000,
B01111110, B11111111,
B00110011, B10011111,
B00011111, B11111100,
B00001101, B01110000,
B00011011, B10100000,
B00111111, B11100000,
B00111111, B11110000,
B01111100, B11110000,
B01110000, B01110000,
B00000000, B00110000 };
Adafruit_MAX31855 thermocouple[] = { Adafruit_MAX31855(SPI_CLK, TC1_CS,
SPI_MISO), Adafruit_MAX31855(SPI_CLK, TC2_CS, SPI_MISO) };
double temp[] = {0,0,0,0};
CapacitiveSensor button[] = {CapacitiveSensor(5,A0),\
CapacitiveSensor(5,A1),\
CapacitiveSensor(5,A2),\
CapacitiveSensor(5,A3),\
CapacitiveSensor(5,A4),\
CapacitiveSensor(5,A5)};
boolean buttonState[] = {false,false,false,false,false,false};
boolean buttonAction[] = {false,false,false,false,false,false};
long buttonTime[] = {0, 0, 0, 0, 0, 0};
const byte BUTTON_N = 6;
const byte DEBOUNCE_DELAY = 20;
void setup() {
Serial.begin(9600);
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC);
display.clearDisplay();
}
void loop() {
//controlButtons();
displayTemperatures(0,2);
delay(1000);
}
void displayTemperatures(byte l1, byte l2) {
double tempNow[] = { 0,0,0,0 };
boolean error[]={false,false};
display.setTextSize(1);
display.setTextColor(WHITE);
for(int i=0; i<2; i++)
{
tempNow[2*i] = thermocouple[i].readCelsius();
if(!isnan(tempNow[2*i]))
{
temp[2*i]=tempNow[2*i];
}
else
{
error[i]=true;
}
tempNow[2*i+1] = thermocouple[i].readInternal();
if(!isnan(tempNow[2*i+1]))
{
temp[2*i+1]=tempNow[2*i+1];
}
else
{
error[i]=true;
}
}
display.clearDisplay();
for(int i=0; i<2; i++)
{
display.setCursor(2*10,i*2*10);
display.print(temp[2*i]);
display.print("/");
display.print(temp[2*i+1]);
display.print(" ");
display.setCursor(0, 2*i*10);
if(error[i])
{
display.print("E");
}
else
{
display.print(" ");
}
}
display.display();
}