I want to connect 4 MAX6675 thermocouple to Arduino. MAX 6675 description.
It comes with its own Arduino library. library link.
I tested the example code for one sensor and it works perfectly. Now I want to connect all the four sensors to Arduino using minimum GPIO pins possible.
I connected - (for 2 sensors only for initial testing):
D7 -> clk (slave 1) ->clk (slave 2)
D3 -> so (slave 1) ->so (slave 2)
D4 -> cs (slave 1)
D5 -> cs (slave 2)
My code (I modified the original example code a bit):
// this example is public domain. enjoy!
// www.ladyada.net/learn/sensors/thermocouple
#include "max6675.h"
int thermoCLK = 7;
int thermoDO = 3;
int thermoCS = 4;
int thermoCS2 = 5;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
MAX6675 thermocouple2(thermoCLK, thermoCS2, thermoDO);
void setup() {
Serial.begin(9600);
Serial.println("MAX6675 test");
// wait for MAX chip to stabilize
delay(500);
}
void loop() {
// basic readout test, just print the current temp
Serial.print("C = ");
Serial.println(thermocouple.readCelsius());
Serial.print("F = ");
Serial.println(thermocouple.readFahrenheit());
Serial.print("C 2= ");
Serial.println(thermocouple2.readCelsius());
Serial.print("F 2= ");
Serial.println(thermocouple2.readFahrenheit());
delay(1000);
}
I am able to read only one sensor information correctly. The other output is nan. Am I wiring the circuit wrong or is my code incorrect or both?