Multiple Adafruit MCP9600 not working in series

I now have an issue that when I try to run 3 of these MCP9600 at the same time they will not read properly.

I am using an Arduino Rev4 Wifi with the Adafruit MCP9600 Thermocouple Amp and an R Type ceramic thermocouple.

Adafruit MCP9600 -

https://learn.adafruit.com/adafruit-mcp9600-i2c-thermocouple-amplifier/arduino

image

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());

As you can see below, 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?

image

Your code is not complete.
But already from the part that you uploaded, it is clear that the code is not written very well.
Writing code for three sensors by copying blocks of code for one sensor is a very bad programming style, in which it is easy to make mistakes and confuse the sensor you are working with.
For multiple instances of the same code, use arrays, procedures, and functions

Hi, @devolarduino

Have you got code that JUST connects and reads ONE 9600?
If not then it would be a good place to start.
This will prove your hardware connection and communications.

It looks like a lot of code to suddenly find you can't get any data.

Tom... :grinning: :+1: :coffee: :australia:

they are I2C devices. Do you have 3 different addresses for those modules?

see the doc

Changing the I2C Address

By default, the ADDR pin is tied to Vin. This sets the default I2C address to 0x67. To change the I2C address, you can use the provided jumpers, or tie the ADDR pin directly to GND. This breakout supports a total of five I2C addresses, meaning you can connect up to five MCP9600 breakouts on the same I2C bus.

Use the following table to determine what to apply to the ADDR pin to get the desired address. The jumpers are numbered in the image. J1 applies to jumper 1, and J2 appli es to jumper 2. An - in the table means no action needed, and an X in the table means to solder closed a jumper. The final address requires tying the ADDR pin to the GND pin, and in that case, all other changes are ignored.

image

Hi, @TomGeorge

Yes I have used the example code provided with the sensor and configured it to run with a single sensor. From this basis I wanted to create a code to run three sensors but am not entirely sure how to use Functions and Arrays to do so as @b707 mentioned.

Apologies I didn't paste in the final piece of code, here is the full 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);
}

@J-M-L thank you for your reply, I have used the I2C scanner and confirmed I can receive 0x60, 0x65 and 0x67 as the addresses for the 3 different MCP9600 amplifiers I am using.

Might someone be able to help with how I could restructure the code such that it can read properly?

so what does the serial monitor show (copy the text and paste it here within code tags)

may be you need to add pullup resistors on the I2C lines (add a 4.7KΩ resistor going from the SCL pin to 3.3V and another one between SDA and 3.3V)

@J-M-L, thank you for your advice. I'll try the resistors too.

This is what I was getting on the serial monitor -

MCP9600 HW test
Found MCP9600!
ADC A resolution set to 18 bits
ADC B resolution set to 18 bits
ADC C resolution set to 18
'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
Top: nan
Middle: nan
Bottom: nan

Ln 127, Col 70

Arduino NANO 33 IoT

on COM6

Do you have a thermocouples connected to the modules when you run the code?

I went to see in the library what sets the value to NAN (not a number).

it's at the start of the reading function

so it could be just a simple mistake in your code, you forgot to enable the mcps...

just add this at the end of the setup function, may be they are not enabled by default...

  mcp_A.enable(true);
  mcp_B.enable(true);
  mcp_C.enable(true);

Hi @b707, yes I do. They are daisy chained to the same thermocouple using the appropriate wire. Tested In parallel with a pyrometer on the code designed for a single MCP9600 I get the same reading as the pyrometer however when I attempt it with my multi-MCP9600 code it produces a different result.

If you are using one T/C as an input to all three converters you are probably creating ground loops that are causing your issues. If you don’t have individual T/C’s yet you can make temporary ones using your extension wire by twisting the two conductors together.

Or connect your one T/C to each converter, one at a time. You will see an open indication on the two converters without the T/C connected and a proper reading on the one with the T/C connected.

Hi, @devolarduino
Have a look at this, similar problem and a solution;

Tom... :grinning: :+1: :coffee: :australia:

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.