I am trying to use 6 max6675 with UNO board.
I have already used all the digital pins for connecting 4 max6675. But now i am thinking shall I use another board or is there any way to use analog pin as digital what code should I use?
Welcome to the forum
You started a topic in the Uncategorised category of the forum when its description explicitly tells you not to
Your topic has been moved to a relevant category. Please be careful in future when deciding where to start new topics
Just treat them as normal digital pins, using the A* names printed on the Uno. No special code is needed
You only need 8 pins for six MAX6675
I have tried it but it is showing NaN as an output.
Post your full sketch showing what you tried and a schematic of your project
How to do that I am using pin 2 to pin 13. 3 pin for each So CS and sck.
#include "max6675.h"
int thermo1DO = 2;
int thermo1CS = 3;
int thermo1CLK = 4;
int thermo2DO = 5;
int thermo2CS = 6;
int thermo2CLK = 7;
int thermo3DO = 8;
int thermo3CS = 9;
int thermo3CLK = 10;
int thermo4DO = 11;
int thermo4CS = 12;
int thermo4CLK = 13;
int thermo5DO = A0;
int thermo5CS = A1;
int thermo5CLK = A2;
MAX6675 thermocouple1(thermo1CLK, thermo1CS, thermo1DO);
MAX6675 thermocouple2(thermo2CLK, thermo2CS, thermo2DO);
MAX6675 thermocouple3(thermo3CLK, thermo3CS, thermo3DO);
MAX6675 thermocouple4(thermo4CLK, thermo4CS, thermo4DO);
MAX6675 thermocouple5(thermo5CLK, thermo5CS, thermo5DO);
void setup() {
Serial.begin(9600);
Serial.println("MAX6675 test");
// wait for MAX chip to stabilize
delay(500);
Serial.println("C1, C2, C3, C4, C5");
}
void loop() {
// basic readout test, just print the current temp
Serial.print(thermocouple1.readCelsius());
Serial.print(", ");
Serial.print(thermocouple2.readCelsius());
Serial.print(", ");
Serial.print(thermocouple3.readCelsius());
Serial.print(", ");
Serial.print(thermocouple4.readCelsius());
Serial.print(", ");
Serial.println(thermocouple5.readCelsius());
// For the MAX6675 to update, you must delay AT LEAST 250ms between reads!
delay(1000);
}
THis is my output
15:45:29.543 -> 0.00, 31.50, 31.75, 32.00, nan
15:45:30.551 -> 0.00, 31.25, 31.25, 31.75, nan
15:45:31.563 -> 0.00, 31.50, 31.25, 32.00, nan
15:45:32.576 -> 0.00, 31.50, 31.25, 32.25, nan
15:45:33.586 -> 0.00, 31.50, 31.50, 31.50, nan
15:45:34.596 -> 0.00, 31.50, 31.00, 32.25, nan
15:45:35.607 -> 0.00, 31.25, 31.00, 32.25, nan
15:45:36.620 -> 0.00, 31.25, 31.00, 32.25, nan
15:45:37.583 -> 0.00, 31.25, 31.00, 32.25, nan
15:45:38.595 -> 0.00, 31.25, 30.75, 32.25, nan
15:45:39.606 -> 0.00, 31.25, 30.75, 32.00, nan
15:45:40.617 -> 0.00, 31.50, 31.00, 32.25, nan
15:45:41.629 -> 0.00, 31.50, 31.00, 32.25, nan
15:45:42.640 -> 0.00, 31.25, 31.00, 32.00, nan
15:45:43.643 -> 0.00, 31.00, 31.25, 31.75, nan
15:45:44.652 -> 0.00, 31.00, 31.25, 32.00, nan
15:45:45.657 -> 0.00, 31.00, 31.00, 32.50, nan
15:45:46.667 -> 0.00, 31.25, 31.50, 32.00, nan
15:45:47.676 -> 0.00, 31.75, 31.25, 32.50, nan
As all of the outputs do not return a number, hence the nan, I would speculate that the problem is not caused by the use of the analogue pins
Get a single sensor working standard digital pins first
Use this library and you can create an array of 6 thermocuoples
All the SCK and SDO are common. You only need seperate CS for each board
See the array example
How?
Thanks for the help, much appreciated.
Where are you stuck ?
Have you got a single sensor working ?
If not, then do not expect to get multiple sensors working
Yes all the sensors are working on digital pins. but no on analog.
Connect all the SCKs together to pin D13
Connect all the SDs together pin D12
Connect the CSs to pins 2 through 7
Install the library
Run this code
// AUTHOR: Rob Tillaart
// PURPOSE: demo
// URL: https://github.com/RobTillaart/MAX6675
#include "MAX6675.h"
const int ThermoCouplesNum = 6;
MAX6675 ThermoCouples[ThermoCouplesNum] =
{
MAX6675(2, &SPI), // HW SPI
MAX6675(3, &SPI), // HW SPI
MAX6675(4, &SPI), // HW SPI
MAX6675(5, &SPI), // HW SPI
MAX6675(6, &SPI), // HW SPI
MAX6675(7, &SPI), // HW SPI
};
uint32_t start, stop;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("MAX6675_LIB_VERSION: ");
Serial.println(MAX6675_LIB_VERSION);
Serial.println();
delay(250);
SPI.begin();
for (int i = 0; i < ThermoCouplesNum; i++)
{
ThermoCouples[i].begin();
ThermoCouples[i].setSPIspeed(1000000);
}
}
void loop()
{
delay(100);
for (int THCnumber = 0; THCnumber < ThermoCouplesNum; THCnumber++)
{
start = micros();
int status = ThermoCouples[THCnumber].read();
stop = micros();
float temp = ThermoCouples[THCnumber].getTemperature();
Serial.print(millis());
Serial.print("\tID: ");
Serial.print(THCnumber);
Serial.print("\tstatus: ");
Serial.print(status);
Serial.print("\ttemp: ");
Serial.print(temp);
Serial.print("\tus: ");
Serial.println(stop - start);
delay(1000); // time to flush all Serial stuff
}
Serial.println();
}
Thank you.
You are welcome
Hi I uploaded the given code but it is printing garbage values.
17:21:08.843 -> C:\Users\yashe\OneDrive\Documents\Arduino\max6675-1\max6675-1.ino
17:21:08.843 -> MAX6675_LIB_VERSION: 0.3.1
17:21:08.843 ->
17:21:08.843 -> 352 ID: 0 status: 4 temp: 1023.75 us: 52
17:21:08.843 -> 1353 ID: 1 status: 4 temp: 1023.75 us: 52
17:21:08.843 -> 2355 ID: 2 status: 4 temp: 1023.75 us: 56
17:21:08.843 -> 3355 ID: 3 status: 4 temp: 1023.75 us: 52
17:21:08.843 -> 4357 ID: 4 status: 4 temp: 1023.75 us: 52
17:21:08.843 -> 5358 ID: 5 status: 4 temp: 1023.75 us: 52
17:21:08.843 ->
17:21:08.843 -> 6459 ID: 0 status: 4 temp: 1023.75 us: 52
17:21:08.843 -> 7460 ID: 1 status: 4 temp: 1023.75 us: 52
17:21:08.843 -> 8461 ID: 2 status: 4 temp: 1023.75 us: 52
17:21:08.843 -> ⸮e⸮⸮⸮⸮⸮%⸮ ⸮⸮O⸮%⸮⸮ ⸮⸮⸮a%⸮⸮⸮⸮ ⸮p⸮⸮⸮⸮J⸮%⸮⸮KJ⸮⸮⸮p⸮⸮⸮⸮⸮ %⸮J⸮⸮ai⸮⸮J⸮⸮a⸮⸮⸮⸮⸮J⸮O⸮i⸮⸮-K⸮⸮%⸮%⸮J⸮⸮a⸮K⸮ %⸮⸮q⸮⸮G⸮a⸮⸮⸮⸮⸮⸮⸮aJ⸮i⸮⸮q⸮⸮⸮⸮⸮⸮%⸮a⸮J⸮G ⸮⸮KO⸮J⸮⸮⸮⸮⸮%⸮⸮ɏ⸮⸮ %⸮⸮a⸮!⸮⸮-K⸮⸮⸮a⸮%⸮
⸮⸮⸮OO⸮⸮⸮⸮⸮a⸮⸮J⸮!⸮⸮p⸮⸮
⸮G ⸮⸮⸮
⸮⸮⸮K⸮⸮⸮⸮⸮%⸮⸮a⸮⸮⸮%⸮⸮⸮%⸮⸮p⸮⸮⸮⸮J⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮aK⸮%⸮⸮a⸮⸮K⸮⸮⸮⸮%⸮⸮J⸮⸮a⸮⸮⸮⸮K⸮⸮%ɥJ⸮⸮⸮-J⸮⸮⸮⸮J⸮⸮⸮ %ɏ⸮K⸮G⸮⸮⸮⸮%⸮!⸮⸮Jҏ⸮O⸮⸮⸮⸮⸮q
That's odd.
Do you have your serial monitor set to 115200?
Trying changing the delay(1000) to delay(2000)