Hi everyone,
I'm having difficulties integrating a MAX6675 thermocouple sensor into a Controllino Maxi (Arduino Mega). I've tried multiple sketches and wire configurations and no mater what I get the same result, which is no reading any value from sensor (0° C always).
This sensor is SPI based, and I managed to wire it in the following way:
Controllino (Arduino PIN)|| Sensor
MISO 50 <---- SO
SCK 52 ----> SCK
SS 53 ----> CS
My current code is:
#include <Controllino.h>
#include "MAX6675.h"
#include <SPI.h>
const int dataPin = 50;
const int clockPin = 52;
const int selectPin = 53;
MAX6675 thermoCouple(selectPin, dataPin, clockPin);
uint32_t start, stop;
void setup() {
Serial.begin(115200);
Controllino_RTC_init();
SPI.begin();
thermoCouple.begin();
thermoCouple.setSPIspeed(4000000);
}
void loop() {
int status = thermoCouple.read();
float temp = thermoCouple.getTemperature();
if (status == 0) {
Serial.print("temp: ");
Serial.println(temp);
}
else if (status == 4) {
Serial.println("Revisar termopar");
}
else if (status == 129) {
Serial.println("Sin comunicacion");
}
delay(1500);
}
And I always get this output:
temp: 0.00
This controllino has an integrated RTC RV-2123-C2-TA-QC-020. I've done the initial configurations but still no go:
#include <SPI.h>
#include <Controllino.h>
void setup() {
Serial.begin(9600);
Controllino_RTC_init(0);
Controllino_SetTimeDate(27,6,7,24,01,17,23); // set initial values to the RTC chip
}
void loop() {
int n;
Serial.print("Day: ");n = Controllino_GetDay(); Serial.println(n);
Serial.print("WeekDay: ");n = Controllino_GetWeekDay(); Serial.println(n);
Serial.print("Month: ");n = Controllino_GetMonth(); Serial.println(n);
Serial.print("Year: ");n = Controllino_GetYear(); Serial.println(n);
Serial.print("Hour: ");n = Controllino_GetHour(); Serial.println(n);
Serial.print("Minute: "); n = Controllino_GetMinute(); Serial.println(n);
Serial.print("Second: ");n = Controllino_GetSecond(); Serial.println(n);
delay(5000);
}
Any help will be appreciated.
Thank you