I can run the code and display thermocouple readings on the IoT advanced graph just fine however the readings are not what I expected. This because the thermocouple amplifier detects the thermocouple as K type when it is R type so applies the wrong amplification. How can I get it to read it as R type?
I am using an Arduino Rev4 Wifi with the Adafruit MCP9600 Thermocouple Amp and an R Type ceramic thermocouple.
#include "arduino_secrets.h"
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/e426cba6-1628-451d-bc6d-69064320a59c
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
float tcouple_temperature;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
#include <Wire.h>
#include <Adafruit_I2CDevice.h>
#include <Adafruit_I2CRegister.h>
#include "Adafruit_MCP9600.h"
#define I2C_ADDRESS (0x67)
Adafruit_MCP9600 mcp;
void setup() {
Serial.begin(115200);
while (!Serial) {
delay(10);
}
Serial.println("MCP9600 HW test");
/* Initialise the driver with I2C_ADDRESS and the default I2C bus. */
if (!mcp.begin(I2C_ADDRESS)) {
Serial.println("Sensor not found. Check wiring!");
while (1)
;
}
Serial.println("Found MCP9600!");
mcp.setADCresolution(MCP9600_ADCRESOLUTION_18);
Serial.print("ADC resolution set to ");
switch (mcp.getADCresolution()) {
case MCP9600_ADCRESOLUTION_18: Serial.print("18"); break;
case MCP9600_ADCRESOLUTION_16: Serial.print("16"); break;
case MCP9600_ADCRESOLUTION_14: Serial.print("14"); break;
case MCP9600_ADCRESOLUTION_12: Serial.print("12"); break;
}
Serial.println(" bits");
mcp.setThermocoupleType(MCP9600_TYPE_K);
Serial.print("Thermocouple type set to ");
switch (mcp.getThermocoupleType()) {
case MCP9600_TYPE_K: Serial.print("K"); break;
case MCP9600_TYPE_J: Serial.print("J"); break;
case MCP9600_TYPE_T: Serial.print("T"); break;
case MCP9600_TYPE_N: Serial.print("N"); break;
case MCP9600_TYPE_S: Serial.print("S"); break;
case MCP9600_TYPE_E: Serial.print("E"); break;
case MCP9600_TYPE_B: Serial.print("B"); break;
case MCP9600_TYPE_R: Serial.print("R"); break;
}
Serial.println(" type");
mcp.setFilterCoefficient(3);
Serial.print("Filter coefficient value set to: ");
Serial.println(mcp.getFilterCoefficient());
mcp.setAlertTemperature(1, 30);
Serial.print("Alert #1 temperature set to ");
Serial.println(mcp.getAlertTemperature(1));
mcp.configureAlert(1, true, true); // alert 1 enabled, rising temp
mcp.enable(true);
Serial.println(F("------------------------------"));
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
tcouple_temperature = mcp.readThermocouple();
Serial.println(tcouple_temperature);
delay(100);
}
I now have an issue that when I try to run 3 of these MCP9600 at the same time they will not read properly. Here is the result from the serial monitor -
MCP9600 HW test
Found MCP9600!
ADC A resolution set to 18 bits
ADC B resolution set to 18 bitsADC C resolution set to 18 bits
'Thermocouple A' type set to R type
'Thermocouple B' type set to R type
'Thermocouple C' type set to R type
Filter coefficient value set to: 7
Filter coefficient value set to: 7
Filter coefficient value set to: 7
Top: nan
Middle: nan
Bottom: nan
Top: nan
Middle: nan
Bottom: nan
Top: nan
Middle: nan
Bottom: nan
Top: nan
Middle: nan
Bottom: nan
Top: nan
Middle: nan
Bottom: nan
Top: nan
Middle: nan
Bottom: nan
And the code -
#include <Wire.h>
#include <Adafruit_I2CDevice.h>
#include <Adafruit_I2CRegister.h>
#include "Adafruit_MCP9600.h"
Adafruit_MCP9600 mcp_A;
Adafruit_MCP9600 mcp_B;
Adafruit_MCP9600 mcp_C;
void setup()
{
Serial.begin(115200);
while (!Serial) {
delay(10);
}
Serial.println("MCP9600 HW test");
/* Initialise the driver with I2C_ADDRESS and the default I2C bus. */
/* Initialise each device with it address and the default I2C bus. */
if (! mcp_A.begin(0x60)) {
Serial.println("Sensor A not found. Check wiring!");
while (1);
}
if (! mcp_B.begin(0x65)) {
Serial.println("Sensor B not found. Check wiring!");
while (1);
}
if (! mcp_C.begin(0x67)) {
Serial.println("Sensor C not found. Check wiring!");
while (1);
}
Serial.println("Found MCP9600!");
mcp_A.setADCresolution(MCP9600_ADCRESOLUTION_18);
Serial.print("ADC A resolution set to ");
switch (mcp_A.getADCresolution()) {
case MCP9600_ADCRESOLUTION_18: Serial.print("18"); break;
case MCP9600_ADCRESOLUTION_16: Serial.print("16"); break;
case MCP9600_ADCRESOLUTION_14: Serial.print("14"); break;
case MCP9600_ADCRESOLUTION_12: Serial.print("12"); break;
}
Serial.println(" bits");
mcp_B.setADCresolution(MCP9600_ADCRESOLUTION_18);
Serial.print("ADC B resolution set to ");
switch (mcp_B.getADCresolution()) {
case MCP9600_ADCRESOLUTION_18: Serial.print("18"); break;
case MCP9600_ADCRESOLUTION_16: Serial.print("16"); break;
case MCP9600_ADCRESOLUTION_14: Serial.print("14"); break;
case MCP9600_ADCRESOLUTION_12: Serial.print("12"); break;
}
Serial.println(" bits");
mcp_C.setADCresolution(MCP9600_ADCRESOLUTION_18);
Serial.print("ADC C resolution set to ");
switch (mcp_C.getADCresolution()) {
case MCP9600_ADCRESOLUTION_18: Serial.print("18"); break;
case MCP9600_ADCRESOLUTION_16: Serial.print("16"); break;
case MCP9600_ADCRESOLUTION_14: Serial.print("14"); break;
case MCP9600_ADCRESOLUTION_12: Serial.print("12"); break;
}
Serial.println(" bits");
mcp_A.setThermocoupleType(MCP9600_TYPE_R);
Serial.print("'Thermocouple A' type set to ");
switch (mcp_A.getThermocoupleType()) {
case MCP9600_TYPE_K: Serial.print("K"); break;
case MCP9600_TYPE_J: Serial.print("J"); break;
case MCP9600_TYPE_T: Serial.print("T"); break;
case MCP9600_TYPE_N: Serial.print("N"); break;
case MCP9600_TYPE_S: Serial.print("S"); break;
case MCP9600_TYPE_E: Serial.print("E"); break;
case MCP9600_TYPE_B: Serial.print("B"); break;
case MCP9600_TYPE_R: Serial.print("R"); break;
}
Serial.println(" type");
mcp_B.setThermocoupleType(MCP9600_TYPE_R);
Serial.print("'Thermocouple B' type set to ");
switch (mcp_B.getThermocoupleType()) {
case MCP9600_TYPE_K: Serial.print("K"); break;
case MCP9600_TYPE_J: Serial.print("J"); break;
case MCP9600_TYPE_T: Serial.print("T"); break;
case MCP9600_TYPE_N: Serial.print("N"); break;
case MCP9600_TYPE_S: Serial.print("S"); break;
case MCP9600_TYPE_E: Serial.print("E"); break;
case MCP9600_TYPE_B: Serial.print("B"); break;
case MCP9600_TYPE_R: Serial.print("R"); break;
}
Serial.println(" type");
mcp_C.setThermocoupleType(MCP9600_TYPE_R);
Serial.print("'Thermocouple C' type set to ");
switch (mcp_C.getThermocoupleType()) {
case MCP9600_TYPE_K: Serial.print("K"); break;
case MCP9600_TYPE_J: Serial.print("J"); break;
case MCP9600_TYPE_T: Serial.print("T"); break;
case MCP9600_TYPE_N: Serial.print("N"); break;
case MCP9600_TYPE_S: Serial.print("S"); break;
case MCP9600_TYPE_E: Serial.print("E"); break;
case MCP9600_TYPE_B: Serial.print("B"); break;
case MCP9600_TYPE_R: Serial.print("R"); break;
}
Serial.println(" type");
mcp_A.setFilterCoefficient(7);
Serial.print("Filter coefficient value set to: ");
Serial.println(mcp_A.getFilterCoefficient());
mcp_B.setFilterCoefficient(7);
Serial.print("Filter coefficient value set to: ");
Serial.println(mcp_B.getFilterCoefficient());
mcp_C.setFilterCoefficient(7);
Serial.print("Filter coefficient value set to: ");
Serial.println(mcp_C.getFilterCoefficient());
Serial.println(F("------------------------------"));
}
void loop()
{
Serial.print("Top: "); Serial.println(mcp_A.readThermocouple());
Serial.print("Middle: "); Serial.println(mcp_B.readThermocouple());
Serial.print("Bottom: "); Serial.println(mcp_C.readThermocouple());
delay(1000);
}
As you can see I soldered a jumper tab on one of the thermocouple amplifiers to change its address output and grounded the addr pin on the other giving me 0x60, 0x64 and 0x67 as my device address list. Please could someone advise why it doesn't feedback any useable data?