0

using 2 Adafruit MCP9600 I2C Thermocouple Amplifier
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

by Davy2s on Sun Aug 04, 2019 9:33 pm

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.

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

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

by adafruit_support_bill on Mon Aug 05, 2019 6:03 am

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.

adafruit_support_bill
 
Posts: 74361
Joined: Sat Feb 07, 2009 10:11 am

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

by Davy2s on Mon Aug 05, 2019 9:17 am

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 ?

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

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

by adafruit_support_bill on Mon Aug 05, 2019 10:11 am

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

adafruit_support_bill
 
Posts: 74361
Joined: Sat Feb 07, 2009 10:11 am

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

by Davy2s on Wed Aug 07, 2019 10:08 am

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 | TOGGLE FULL SIZE
#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

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

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

by adafruit_support_bill on Wed Aug 07, 2019 10:22 am

You are passing in the address in the constructor here:
Code: Select all | TOGGLE FULL SIZE
Adafruit_I2CDevice i2c_dev = Adafruit_I2CDevice(I2C_ADDRESS);


It has previously be defined as 0x67 here:
Code: Select all | TOGGLE FULL SIZE
#define I2C_ADDRESS (0x67)

adafruit_support_bill
 
Posts: 74361
Joined: Sat Feb 07, 2009 10:11 am

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

by Davy2s on Wed Aug 07, 2019 11:33 am

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.

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

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

by adafruit_support_bill on Wed Aug 07, 2019 12:57 pm

Code: Select all | TOGGLE FULL SIZE
Adafruit_I2CDevice i2c_dev1 = Adafruit_I2CDevice(0x67);
Adafruit_I2CDevice i2c_dev2 = Adafruit_I2CDevice(0x60);

adafruit_support_bill
 
Posts: 74361
Joined: Sat Feb 07, 2009 10:11 am

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

by Davy2s on Wed Aug 07, 2019 11:10 pm

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 | TOGGLE FULL SIZE
#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);
}

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

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

by adafruit_support_bill on Thu Aug 08, 2019 5:59 am

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 | TOGGLE FULL SIZE
    /* Initialise the driver with I2C_ADDRESS and the default I2C bus. */
   if (! mcp2.begin(0x60))
   {
        Serial.println("Sensor not found. Check wiring!");
        while (1);
    }

adafruit_support_bill
 
Posts: 74361
Joined: Sat Feb 07, 2009 10:11 am

Re: using 2 Adafruit MCP9600 I2C Thermocouple Amplifier

by Davy2s on Thu Aug 08, 2019 11:17 am

That works thank you

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

Please be positive and constructive with your questions and comments.