using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
Davy2s
 
Posts: 6
Joined: Sun Aug 04, 2019 9:10 pm

using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

Post by Davy2s »

Hi
I have 2 Adafruit MCP9600 I2C Thermocouple Amplifier - K, J, T, N, S, E, B and R Type T that I'm trying to use with my Arduino Mega 2560 at the same time.
I tested them individually and they work with the sample code but together the signals mix because they are address the same.
My question is how do you set the address?
I suppose it is with the address pin but I can't seam to locate any documentation on how it is used.

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

Post by adafruit_support_bill »

The addressing details of this chip is a little complicated. It is detailed in section 6.3.1 of the data sheet: http://ww1.microchip.com/downloads/en/D ... 05426D.pdf

For two sensors, the simplest thing to do is to connect the ADDR pin on the second sensor to GND. That will give you an address of 0x60.

User avatar
Davy2s
 
Posts: 6
Joined: Sun Aug 04, 2019 9:10 pm

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

Post by Davy2s »

Thank you
So if I’m understanding this correctly it’s saying this can have up to 8 different address ?
Does the address have set each time power is applied or does it remember it?
I’m going to end up with more than 2 i2c devices connected so I need to understand how to use all of them
Can you explain the other addresses?
It says something about using a voltage divider but I don’t know how much I’m diving the voltage ?

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

Post by adafruit_support_bill »

The address is set by the ADDR pin. By default, it is tied to VCC, giving it an address of 0x67. Tied to ground it is 0x60. At voltages in between, it will respond to the other 6 addresses according to the formula in the datasheet. The simplest way to set an in-between voltage is with a voltage divider. Figure 6.4 in the data sheet shows a circuit schematic and gives you the exact resistor values to use to create those 6 addresses.

For general information on voltage dividers, see this page:
https://en.wikipedia.org/wiki/Voltage_divider

There are 2 voltage dividers built into the board. They can be enabled using the 2 jumpers on the right side of the board. By bridging one or both of these jumpers, you should be able to create as many as 3 more addresses.

Image

User avatar
Davy2s
 
Posts: 6
Joined: Sun Aug 04, 2019 9:10 pm

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

Post by Davy2s »

thank you I believe that I understand the wiring now I just got to figured get the code to talk to it.
Im looking at the Adafruit example code, I understand most of it but I'm not sure how the address is being passed to mcp.
I see the I2C_ADDRESS being defined and if I change it to 0x60 it works with the other one but if I try to create a mcp2 and a second address I don't see how to pass the second address to mcp2 they just both keep using the same address. I suppose its using a pointer somehow.

Code: Select all

#include <Wire.h>
#include <Adafruit_I2CDevice.h>
#include <Adafruit_I2CRegister.h>
#include "Adafruit_MCP9600.h"

#define I2C_ADDRESS (0x67)

Adafruit_MCP9600 mcp;
Adafruit_I2CDevice i2c_dev = Adafruit_I2CDevice(I2C_ADDRESS);

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()) {
        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("------------------------------"));
}

void loop()
{
  Serial.print("Hot Junction: "); Serial.println(mcp.readThermocouple());
  Serial.print("Cold Junction: "); Serial.println(mcp.readAmbient());
  Serial.print("ADC: "); Serial.print(mcp.readADC() * 2); Serial.println(" uV");
  delay(1000);
}
Last edited by adafruit_support_bill on Wed Aug 07, 2019 10:21 am, edited 1 time in total.
Reason: Please use [code] tags when submitting code to the forums

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

Post by adafruit_support_bill »

You are passing in the address in the constructor here:

Code: Select all

Adafruit_I2CDevice i2c_dev = Adafruit_I2CDevice(I2C_ADDRESS);
It has previously be defined as 0x67 here:

Code: Select all

#define I2C_ADDRESS (0x67)

User avatar
Davy2s
 
Posts: 6
Joined: Sun Aug 04, 2019 9:10 pm

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

Post by Davy2s »

But how do I tell it to give mcp one address and mcp2 another?
I tried creating a i2c_dev2 but mcp2 just wants to use i2c_dev. I don’t see how to tell mcp2 to use i2c_dev2.

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

Post by adafruit_support_bill »

Code: Select all

Adafruit_I2CDevice i2c_dev1 = Adafruit_I2CDevice(0x67);
Adafruit_I2CDevice i2c_dev2 = Adafruit_I2CDevice(0x60);

User avatar
Davy2s
 
Posts: 6
Joined: Sun Aug 04, 2019 9:10 pm

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

Post by Davy2s »

There has got to be more to it than that because that doesn't seam to work.
I just realized that changing #define I2C_ADDRESS (0x67) to #define I2C_ADDRESS (0x60) doesn't actually change the address.


Code: Select all

#include <Wire.h>
#include <Adafruit_I2CDevice.h>
#include <Adafruit_I2CRegister.h>
#include "Adafruit_MCP9600.h"

//#define I2C_ADDRESS (0x67)

Adafruit_MCP9600 mcp;
Adafruit_MCP9600 mcp2;
//Adafruit_I2CDevice i2c_dev = Adafruit_I2CDevice(I2C_ADDRESS);
Adafruit_I2CDevice i2c_dev1 = Adafruit_I2CDevice(0x67);
Adafruit_I2CDevice i2c_dev2 = Adafruit_I2CDevice(0x60);


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()) {
    Serial.println("Sensor not found. Check wiring!");
    while (1);
  }

  Serial.println("Found MCP9600!");
  if (! mcp2.begin()) {
     Serial.println("Sensor not found. Check wiring!");
     while (1);
  }
  Serial.println("Found 2 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");

  mcp2.setADCresolution(MCP9600_ADCRESOLUTION_18);
  Serial.print("ADC resolution set to ");
  switch (mcp2.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");

  mcp2.setThermocoupleType(MCP9600_TYPE_K);
  Serial.print("Thermocouple type set to ");
  switch (mcp2.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());

  mcp2.setFilterCoefficient(3);
  Serial.print("Filter coefficient value set to: ");
  Serial.println(mcp2.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

  mcp2.setAlertTemperature(1, 30);
  Serial.print("Alert #1 temperature set to ");
  Serial.println(mcp2.getAlertTemperature(1));
  mcp2.configureAlert(1, true, true);  // alert 1 enabled, rising temp


  mcp.enable(true);
  mcp2.enable(true);

  Serial.println(F("------------------------------"));
}

void loop()
{
  Serial.print("Hot Junction: "); Serial.println(mcp.readThermocouple());
  Serial.print("Cold Junction: "); Serial.println(mcp.readAmbient());
  Serial.print("ADC: "); Serial.print(mcp.readADC() * 2); Serial.println(" uV");
  
  Serial.print("Hot Junction: "); Serial.println(mcp2.readThermocouple());
  Serial.print("Cold Junction: "); Serial.println(mcp2.readAmbient());
  Serial.print("ADC: "); Serial.print(mcp2.readADC() * 2); Serial.println(" uV");
  delay(1000);
}

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

Post by adafruit_support_bill »

Yes, the example code is a little misleading. The Adafruit_I2CDevice is not actually used, so that address is irrelevant Addresses for the thermocouple amplifier should be passed in via the begin() statements:

Code: Select all

    /* Initialise the driver with I2C_ADDRESS and the default I2C bus. */
   if (! mcp2.begin(0x60)) 
   {
        Serial.println("Sensor not found. Check wiring!");
        while (1);
    }

User avatar
Davy2s
 
Posts: 6
Joined: Sun Aug 04, 2019 9:10 pm

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

Post by Davy2s »

That works thank you

User avatar
elliottc
 
Posts: 1
Joined: Wed Feb 12, 2014 3:46 pm

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

Post by elliottc »

If you are confident of your soldering skills, you could always do this:
1. De-solder one of the two on-board resistors (43K or 22K ohm)
2. In it's place, solder a suitable resistor ( 13K, 7.5K, 4.3K or 2.2K ohm)
3. Bridge the jumper.

A nice addition to this board might be an empty spot to solder your own resistor. Even a small, through hole radial resistor would be great.

User avatar
markes51
 
Posts: 6
Joined: Tue Jan 03, 2017 9:23 am

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

Post by markes51 »

Hello
I'm having troubles using two of that. Can you send the entire code that is working ,please?
Thank you

User avatar
steg
 
Posts: 1
Joined: Fri Apr 09, 2021 3:44 pm

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

Post by steg »

I wish to use three MCP9600 thermocouples, reading temperatures to a single Arduino Uno. I've soldered in differing resistors, following the recommended values from the MCP9600 datasheet, giving addresses 0x60 and 0x64 and 0x67.

Could anyone assist me in the coding? How do I change the Adafruit mcp9600_test.ino example, to read from more than one thermocouple. Many thanks.

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

Post by adafruit_support_bill »

First you need to define 3 different instances of the device. We'll call them mcp_A, mcp_B and mcp_C.

Code: Select all

Adafruit_MCP9600 mcp_A;
Adafruit_MCP9600 mcp_B;
Adafruit_MCP9600 mcp_C;
Then in your setup, you need to initialize each instance by name with the appropriate address:

Code: Select all

    /* 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(0x64)) {
        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);
    }

  mcp_A.setADCresolution(MCP9600_ADCRESOLUTION_18);
  mcp_B.setADCresolution(MCP9600_ADCRESOLUTION_18);
  mcp_C.setADCresolution(MCP9600_ADCRESOLUTION_18);

  mcp_A.setThermocoupleType(MCP9600_TYPE_K);
  mcp_B.setThermocoupleType(MCP9600_TYPE_K);
  mcp_C.setThermocoupleType(MCP9600_TYPE_K);
And in you loop, you can read from each instance by name as below:

Code: Select all

  Serial.print("Hot Junction A: "); Serial.println(mcp_A.readThermocouple());
  Serial.print("Hot Junction B: "); Serial.println(mcp_B.readThermocouple());
  Serial.print("Hot Junction C: "); Serial.println(mcp_C.readThermocouple());

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”