Adafruit 1-Wire Thermocouple Amplifier - MAX31850K for 3 K-t

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
runnu
 
Posts: 8
Joined: Mon Feb 23, 2015 1:57 pm

Adafruit 1-Wire Thermocouple Amplifier - MAX31850K for 3 K-t

Post by runnu »

Hi i am using Adafruit 1-Wire Thermocouple Amplifier - MAX31850K for 3 thermocouples. the programme is detecting 3 devices in the serial console but it is only giving 2 temperature readings the other one is not appearing. What should i do?
Attachments
Screen Shot 2015-03-07 at 16.24.14.png
Screen Shot 2015-03-07 at 16.24.14.png (612.01 KiB) Viewed 596 times

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit 1-Wire Thermocouple Amplifier - MAX31850K for 3

Post by adafruit_support_mike »

Post the code you're using (between CODE tags please) and we'll take a look.

User avatar
runnu
 
Posts: 8
Joined: Mon Feb 23, 2015 1:57 pm

Re: Adafruit 1-Wire Thermocouple Amplifier - MAX31850K for 3

Post by runnu »

Hi,

Thanks for your help. This is the code I'm using

Code: Select all

[#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 9

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// arrays to hold device addresses
DeviceAddress insideThermometer, outsideThermometer;

void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();

  // locate devices on the bus
  Serial.print("Locating devices...");
  Serial.print("Found ");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" devices.");

  // report parasite power requirements
  Serial.print("Parasite power is: "); 
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");

  // assign address manually.  the addresses below will beed to be changed
  // to valid device addresses on your bus.  device address can be retrieved
  // by using either oneWire.search(deviceAddress) or individually via
  // sensors.getAddress(deviceAddress, index)
  //insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };
  //outsideThermometer   = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 };

  // search for devices on the bus and assign based on an index.  ideally,
  // you would do this to initially discover addresses on the bus and then 
  // use those addresses and manually assign them (see above) once you know 
  // the devices on your bus (and assuming they don't change).
  // 
  // method 1: by index
  if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); 
  if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1");
  if (!sensors.getAddress(insideThermometer, 2)) Serial.println("Unable to find address for Device 2"); 

  // method 2: search()
  // search() looks for the next device. Returns 1 if a new address has been
  // returned. A zero might mean that the bus is shorted, there are no devices, 
  // or you have already retrieved all of them.  It might be a good idea to 
  // check the CRC to make sure you didn't get garbage.  The order is 
  // deterministic. You will always get the same devices in the same order
  //
  // Must be called before search()
  //oneWire.reset_search();
  // assigns the first address found to insideThermometer
  //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");
  // assigns the seconds address found to outsideThermometer
  //if (!oneWire.search(outsideThermometer)) Serial.println("Unable to find address for outsideThermometer");

  // show the addresses we found on the bus
  Serial.print("Device 0 Address: ");
  printAddress(insideThermometer);
  Serial.println();

  Serial.print("Device 1 Address: ");
  printAddress(outsideThermometer);
  Serial.println();
  
  Serial.print("Device 2 Address: ");
  printAddress(outsideThermometer);
  Serial.println();

  // set the resolution to 9 bit
  sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION);
  sensors.setResolution(outsideThermometer, TEMPERATURE_PRECISION);

  Serial.print("Device 0 Resolution: ");
  Serial.print(sensors.getResolution(insideThermometer), DEC); 
  Serial.println();

  Serial.print("Device 1 Resolution: ");
  Serial.print(sensors.getResolution(outsideThermometer), DEC); 
  Serial.println();
  
  Serial.print("Device 2 Resolution: ");
  Serial.print(sensors.getResolution(outsideThermometer), DEC); 
  Serial.println();
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    // zero pad the address if necessary
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}

// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  Serial.print("Temp C: ");
  Serial.print(tempC);
  Serial.print(" Temp F: ");
  Serial.print(DallasTemperature::toFahrenheit(tempC));
}

// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress)
{
  Serial.print("Resolution: ");
  Serial.print(sensors.getResolution(deviceAddress));
  Serial.println();    
}

// main function to print information about a device
void printData(DeviceAddress deviceAddress)
{
  Serial.print("Device Address: ");
  printAddress(deviceAddress);
  Serial.print(" ");
  printTemperature(deviceAddress);
  Serial.println();
}

void loop(void)
{ 
  // call sensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures();
  Serial.println("DONE");

  // print the device information
  printData(insideThermometer);
  printData(outsideThermometer);
}
Last edited by Franklin97355 on Sun Mar 08, 2015 1:36 pm, edited 1 time in total.
Reason: Added missing [/code] closing tag.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit 1-Wire Thermocouple Amplifier - MAX31850K for 3

Post by adafruit_support_mike »

You only have two variables holding sensor ID numbers:

Code: Select all

DeviceAddress insideThermometer, outsideThermometer;
When you get the sensor addresses:

Code: Select all

  if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0"); 
  if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1");
  if (!sensors.getAddress(insideThermometer, 2)) Serial.println("Unable to find address for Device 2"); 
The third line replaces the address collected by the first.

You need different variables to hold the addresses of sensor 0 and sensor 2.

User avatar
runnu
 
Posts: 8
Joined: Mon Feb 23, 2015 1:57 pm

Re: Adafruit 1-Wire Thermocouple Amplifier - MAX31850K for 3

Post by runnu »

So should i name sensor 2 an other number?
Sorry but I'm new to this programming.

It seems that it is finding the the 3 thermocouples, but not plotting the readings of the second thermocouple.
Attachments
Screen Shot 2015-03-08 at 22.39.17.png
Screen Shot 2015-03-08 at 22.39.17.png (71.02 KiB) Viewed 534 times

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit 1-Wire Thermocouple Amplifier - MAX31850K for 3

Post by adafruit_support_mike »

runnu wrote:So should i name sensor 2 an other number?
Yes. Try insideThermometer1, insideThermometer2, and outsideThermometer.

User avatar
runnu
 
Posts: 8
Joined: Mon Feb 23, 2015 1:57 pm

Re: Adafruit 1-Wire Thermocouple Amplifier - MAX31850K for 3

Post by runnu »

Hi i managed to get 3 readings but it seems that the 3 readings are of the same sensor the middle one (sensor 2) the one that it was not working. it seems that the programme also got 3 addresses and are the same.

In this programme i changes all the names of the thermocouples to : 1, 2 and 3 and changes all programme to inside thermometer , inside thermometer and out side thermometer.

Thanks for your help and sorry for the inconvenience

Code: Select all

[printData(insideThermometer);
  printData(insideThermometer);
  printData(outsideThermometer)]


the programme is as follows:

[code][#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 9

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// arrays to hold device addresses
DeviceAddress insideThermometer, outsideThermometer;

void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();

  // locate devices on the bus
  Serial.print("Locating devices...");
  Serial.print("Found ");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" devices.");

  // report parasite power requirements
  Serial.print("Parasite power is: "); 
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");

  // assign address manually.  the addresses below will beed to be changed
  // to valid device addresses on your bus.  device address can be retrieved
  // by using either oneWire.search(deviceAddress) or individually via
  // sensors.getAddress(deviceAddress, index)
  //insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };
  //outsideThermometer   = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 };

  // search for devices on the bus and assign based on an index.  ideally,
  // you would do this to initially discover addresses on the bus and then 
  // use those addresses and manually assign them (see above) once you know 
  // the devices on your bus (and assuming they don't change).
  // 
  // method 1: by index
  if (!sensors.getAddress(insideThermometer, 1)) Serial.println("Unable to find address for Device 1");
  if (!sensors.getAddress(insideThermometer, 2)) Serial.println("Unable to find address for Device 2"); 
  if (!sensors.getAddress(outsideThermometer, 3)) Serial.println("Unable to find address for Device 3");


  // method 2: search()
  // search() looks for the next device. Returns 1 if a new address has been
  // returned. A zero might mean that the bus is shorted, there are no devices, 
  // or you have already retrieved all of them.  It might be a good idea to 
  // check the CRC to make sure you didn't get garbage.  The order is 
  // deterministic. You will always get the same devices in the same order
  //
  // Must be called before search()
  //oneWire.reset_search();
  // assigns the first address found to insideThermometer
  //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");
  // assigns the seconds address found to outsideThermometer
  //if (!oneWire.search(outsideThermometer)) Serial.println("Unable to find address for outsideThermometer");

  // show the addresses we found on the bus
  Serial.print("Device 1 Address: ");
  printAddress(insideThermometer);
  Serial.println();

  Serial.print("Device 2 Address: ");
  printAddress(insideThermometer);
  Serial.println();
  
  Serial.print("Device 3 Address: ");
  printAddress(outsideThermometer);
  Serial.println();

  // set the resolution to 9 bit
  sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION);
  sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION);
  sensors.setResolution(outsideThermometer, TEMPERATURE_PRECISION);

  Serial.print("Device 1 Resolution: ");
  Serial.print(sensors.getResolution(insideThermometer), DEC); 
  Serial.println();

  Serial.print("Device 2 Resolution: ");
  Serial.print(sensors.getResolution(insideThermometer), DEC); 
  Serial.println();
  
  Serial.print("Device 3 Resolution: ");
  Serial.print(sensors.getResolution(outsideThermometer), DEC); 
  Serial.println();
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    // zero pad the address if necessary
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}

// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  Serial.print("Temp C: ");
  Serial.print(tempC);
  Serial.print(" Temp F: ");
  Serial.print(DallasTemperature::toFahrenheit(tempC));
}

// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress)
{
  Serial.print("Resolution: ");
  Serial.print(sensors.getResolution(deviceAddress));
  Serial.println();    
}

// main function to print information about a device
void printData(DeviceAddress deviceAddress)
{
  Serial.print("Device Address: ");
  printAddress(deviceAddress);
  Serial.print(" ");
  printTemperature(deviceAddress);
  Serial.println();
}

void loop(void)
{ 
  // call sensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures();
  Serial.println("DONE");

  // print the device information
  printData(insideThermometer);
  printData(insideThermometer);
  printData(outsideThermometer);
}
Attachments
2.png
2.png (75.44 KiB) Viewed 500 times
Last edited by Franklin97355 on Mon Mar 09, 2015 1:08 pm, edited 1 time in total.
Reason: Added missing closing [/code] tag

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit 1-Wire Thermocouple Amplifier - MAX31850K for 3

Post by adafruit_support_mike »

You don't seem to have the idea of using unique variable names.

How do you tell the difference between 'insideThermometer' and 'insideThermometer'?

User avatar
runnu
 
Posts: 8
Joined: Mon Feb 23, 2015 1:57 pm

Re: Adafruit 1-Wire Thermocouple Amplifier - MAX31850K for 3

Post by runnu »

Yes I named them but still the third sense is not being identified

Code: Select all

[#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 9

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// arrays to hold device addresses
DeviceAddress insideThermometer1, insideThermometer2, outsideThermometer3;

void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();

  // locate devices on the bus
  Serial.print("Locating devices...");
  Serial.print("Found ");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" devices.");

  // report parasite power requirements
  Serial.print("Parasite power is: "); 
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");

  // assign address manually.  the addresses below will beed to be changed
  // to valid device addresses on your bus.  device address can be retrieved
  // by using either oneWire.search(deviceAddress) or individually via
  // sensors.getAddress(deviceAddress, index)
  //insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };
  //outsideThermometer   = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 };

  // search for devices on the bus and assign based on an index.  ideally,
  // you would do this to initially discover addresses on the bus and then 
  // use those addresses and manually assign them (see above) once you know 
  // the devices on your bus (and assuming they don't change).
  // 
  // method 1: by index
  if (!sensors.getAddress(insideThermometer1, 1)) Serial.println("Unable to find address for Device 1");
 if (!sensors.getAddress(insideThermometer2, 2)) Serial.println("Unable to find address for Device 2"); 
  if (!sensors.getAddress(outsideThermometer3, 3)) Serial.println("Unable to find address for Device 3"); 

  // method 2: search()
  // search() looks for the next device. Returns 1 if a new address has been
  // returned. A zero might mean that the bus is shorted, there are no devices, 
  // or you have already retrieved all of them.  It might be a good idea to 
  // check the CRC to make sure you didn't get garbage.  The order is 
  // deterministic. You will always get the same devices in the same order
  //
  // Must be called before search()
  //oneWire.reset_search();
  // assigns the first address found to insideThermometer
  //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");
  // assigns the seconds address found to outsideThermometer
  //if (!oneWire.search(outsideThermometer)) Serial.println("Unable to find address for outsideThermometer");

  // show the addresses we found on the bus
  Serial.print("Device 1 Address: ");
  printAddress(insideThermometer1);
  Serial.println();
  
  Serial.print("Device 2 Address: ");
  printAddress(insideThermometer2);
  Serial.println();

  Serial.print("Device 3 Address: ");
  printAddress(outsideThermometer3);
  Serial.println();

  // set the resolution to 9 bit
  sensors.setResolution(insideThermometer1, TEMPERATURE_PRECISION);
  sensors.setResolution(insideThermometer2, TEMPERATURE_PRECISION);
  sensors.setResolution(outsideThermometer3, TEMPERATURE_PRECISION);

  Serial.print("Device 1 Resolution: ");
  Serial.print(sensors.getResolution(insideThermometer1), DEC); 
  Serial.println();
  
  Serial.print("Device 2 Resolution: ");
  Serial.print(sensors.getResolution(insideThermometer2), DEC); 
  Serial.println();

  Serial.print("Device 3 Resolution: ");
  Serial.print(sensors.getResolution(outsideThermometer3), DEC); 
  Serial.println();
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    // zero pad the address if necessary
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}

// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  Serial.print("Temp C: ");
  Serial.print(tempC);
  Serial.print(" Temp F: ");
  Serial.print(DallasTemperature::toFahrenheit(tempC));
}

// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress)
{
  Serial.print("Resolution: ");
  Serial.print(sensors.getResolution(deviceAddress));
  Serial.println();    
}

// main function to print information about a device
void printData(DeviceAddress deviceAddress)
{
  Serial.print("Device Address: ");
  printAddress(deviceAddress);
  Serial.print(" ");
  printTemperature(deviceAddress);
  Serial.println();
}

void loop(void)
{ 
  // call sensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures();
  Serial.println("DONE");

  // print the device information
  printData(insideThermometer1);
   printData(insideThermometer2);
  printData(outsideThermometer3);
}]

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: Adafruit 1-Wire Thermocouple Amplifier - MAX31850K for 3

Post by Franklin97355 »

Please go back and edit your message to add the closing [/code] tag at the end of your posted code.

User avatar
runnu
 
Posts: 8
Joined: Mon Feb 23, 2015 1:57 pm

Re: Adafruit 1-Wire Thermocouple Amplifier - MAX31850K for 3

Post by runnu »

Code: Select all

[#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 9

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// arrays to hold device addresses
DeviceAddress insideThermometer1, insideThermometer2, outsideThermometer3;

void setup(void)
{
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");

// Start up the library
sensors.begin();

// locate devices on the bus
Serial.print("Locating devices...");
Serial.print("Found ");
Serial.print(sensors.getDeviceCount(), DEC);
Serial.println(" devices.");

// report parasite power requirements
Serial.print("Parasite power is: "); 
if (sensors.isParasitePowerMode()) Serial.println("ON");
else Serial.println("OFF");

// assign address manually. the addresses below will beed to be changed
// to valid device addresses on your bus. device address can be retrieved
// by using either oneWire.search(deviceAddress) or individually via
// sensors.getAddress(deviceAddress, index)
//insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };
//outsideThermometer = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 };

// search for devices on the bus and assign based on an index. ideally,
// you would do this to initially discover addresses on the bus and then 
// use those addresses and manually assign them (see above) once you know 
// the devices on your bus (and assuming they don't change).
// 
// method 1: by index
if (!sensors.getAddress(insideThermometer1, 1)) Serial.println("Unable to find address for Device 1");
if (!sensors.getAddress(insideThermometer2, 2)) Serial.println("Unable to find address for Device 2"); 
if (!sensors.getAddress(outsideThermometer3, 3)) Serial.println("Unable to find address for Device 3"); 

// method 2: search()
// search() looks for the next device. Returns 1 if a new address has been
// returned. A zero might mean that the bus is shorted, there are no devices, 
// or you have already retrieved all of them. It might be a good idea to 
// check the CRC to make sure you didn't get garbage. The order is 
// deterministic. You will always get the same devices in the same order
//
// Must be called before search()
//oneWire.reset_search();
// assigns the first address found to insideThermometer
//if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");
// assigns the seconds address found to outsideThermometer
//if (!oneWire.search(outsideThermometer)) Serial.println("Unable to find address for outsideThermometer");

// show the addresses we found on the bus
Serial.print("Device 1 Address: ");
printAddress(insideThermometer1);
Serial.println();

Serial.print("Device 2 Address: ");
printAddress(insideThermometer2);
Serial.println();

Serial.print("Device 3 Address: ");
printAddress(outsideThermometer3);
Serial.println();

// set the resolution to 9 bit
sensors.setResolution(insideThermometer1, TEMPERATURE_PRECISION);
sensors.setResolution(insideThermometer2, TEMPERATURE_PRECISION);
sensors.setResolution(outsideThermometer3, TEMPERATURE_PRECISION);

Serial.print("Device 1 Resolution: ");
Serial.print(sensors.getResolution(insideThermometer1), DEC); 
Serial.println();

Serial.print("Device 2 Resolution: ");
Serial.print(sensors.getResolution(insideThermometer2), DEC); 
Serial.println();

Serial.print("Device 3 Resolution: ");
Serial.print(sensors.getResolution(outsideThermometer3), DEC); 
Serial.println();
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
for (uint8_t i = 0; i < 8; i++)
{
// zero pad the address if necessary
if (deviceAddress[i] < 16) Serial.print("0");
Serial.print(deviceAddress[i], HEX);
}
}

// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
Serial.print("Temp C: ");
Serial.print(tempC);
Serial.print(" Temp F: ");
Serial.print(DallasTemperature::toFahrenheit(tempC));
}

// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress)
{
Serial.print("Resolution: ");
Serial.print(sensors.getResolution(deviceAddress));
Serial.println(); 
}

// main function to print information about a device
void printData(DeviceAddress deviceAddress)
{
Serial.print("Device Address: ");
printAddress(deviceAddress);
Serial.print(" ");
printTemperature(deviceAddress);
Serial.println();
}

void loop(void)
{ 
// call sensors.requestTemperatures() to issue a global temperature 
// request to all devices on the bus
Serial.print("Requesting temperatures...");
sensors.requestTemperatures();
Serial.println("DONE");

// print the device information
printData(insideThermometer1);
printData(insideThermometer2);
printData(outsideThermometer3);
}

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit 1-Wire Thermocouple Amplifier - MAX31850K for 3

Post by adafruit_support_mike »

The output posted above doesn't seem to be consistent with the most recent version of the code you've posted.

In this section:

Code: Select all

if (!sensors.getAddress(insideThermometer1, 1)) Serial.println("Unable to find address for Device 1");
if (!sensors.getAddress(insideThermometer2, 2)) Serial.println("Unable to find address for Device 2"); 
if (!sensors.getAddress(outsideThermometer3, 3)) Serial.println("Unable to find address for Device 3"); 
the address numbers should be 0, 1, and 2. I'd expect the code to tell you it couldn't find an address for Device 3.

Try changing that section like this:

Code: Select all

if (!sensors.getAddress(insideThermometer1, 0)) Serial.println("Unable to find address for Device 1");
if (!sensors.getAddress(insideThermometer2, 1)) Serial.println("Unable to find address for Device 2"); 
if (!sensors.getAddress(outsideThermometer3, 2)) Serial.println("Unable to find address for Device 3"); 
and post the output you get.

User avatar
runnu
 
Posts: 8
Joined: Mon Feb 23, 2015 1:57 pm

Re: Adafruit 1-Wire Thermocouple Amplifier - MAX31850K for 3

Post by runnu »

Hi, thanks a lot it seems that it has worked perfectly. this is the code for three k-Type thermocouples. The sensors are not plotted one after the other but one can easily identify the sensors readings.

Code: Select all

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 9

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// arrays to hold device addresses
DeviceAddress insideThermometer1, insideThermometer2, outsideThermometer3;

void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();

  // locate devices on the bus
  Serial.print("Locating devices...");
  Serial.print("Found ");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" devices.");

  // report parasite power requirements
  Serial.print("Parasite power is: "); 
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");

  // assign address manually.  the addresses below will beed to be changed
  // to valid device addresses on your bus.  device address can be retrieved
  // by using either oneWire.search(deviceAddress) or individually via
  // sensors.getAddress(deviceAddress, index)
  //insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };
  //outsideThermometer   = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 };

  // search for devices on the bus and assign based on an index.  ideally,
  // you would do this to initially discover addresses on the bus and then 
  // use those addresses and manually assign them (see above) once you know 
  // the devices on your bus (and assuming they don't change).
  // 
  // method 1: by index
  if (!sensors.getAddress(insideThermometer1, 0)) Serial.println("Unable to find address for Device 1");
 if (!sensors.getAddress(insideThermometer2, 1)) Serial.println("Unable to find address for Device 2"); 
  if (!sensors.getAddress(outsideThermometer3, 2)) Serial.println("Unable to find address for Device 3"); 

  // method 2: search()
  // search() looks for the next device. Returns 1 if a new address has been
  // returned. A zero might mean that the bus is shorted, there are no devices, 
  // or you have already retrieved all of them.  It might be a good idea to 
  // check the CRC to make sure you didn't get garbage.  The order is 
  // deterministic. You will always get the same devices in the same order
  //
  // Must be called before search()
  //oneWire.reset_search();
  // assigns the first address found to insideThermometer
  //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");
  // assigns the seconds address found to outsideThermometer
  //if (!oneWire.search(outsideThermometer)) Serial.println("Unable to find address for outsideThermometer");

  // show the addresses we found on the bus
  Serial.print("Device 1 Address: ");
  printAddress(insideThermometer1);
  Serial.println();
  
  Serial.print("Device 2 Address: ");
  printAddress(insideThermometer2);
  Serial.println();

  Serial.print("Device 3 Address: ");
  printAddress(outsideThermometer3);
  Serial.println();

  // set the resolution to 9 bit
  sensors.setResolution(insideThermometer1, TEMPERATURE_PRECISION);
  sensors.setResolution(insideThermometer2, TEMPERATURE_PRECISION);
  sensors.setResolution(outsideThermometer3, TEMPERATURE_PRECISION);

  Serial.print("Device 1 Resolution: ");
  Serial.print(sensors.getResolution(insideThermometer1), DEC); 
  Serial.println();
  
  Serial.print("Device 2 Resolution: ");
  Serial.print(sensors.getResolution(insideThermometer2), DEC); 
  Serial.println();

  Serial.print("Device 3 Resolution: ");
  Serial.print(sensors.getResolution(outsideThermometer3), DEC); 
  Serial.println();
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    // zero pad the address if necessary
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}

// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  Serial.print("Temp C: ");
  Serial.print(tempC);
  Serial.print(" Temp F: ");
  Serial.print(DallasTemperature::toFahrenheit(tempC));
}

// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress)
{
  Serial.print("Resolution: ");
  Serial.print(sensors.getResolution(deviceAddress));
  Serial.println();    
}

// main function to print information about a device
void printData(DeviceAddress deviceAddress)
{
  Serial.print("Device Address: ");
  printAddress(deviceAddress);
  Serial.print(" ");
  printTemperature(deviceAddress);
  Serial.println();
}

void loop(void)
{ 
  // call sensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures();
  Serial.println("DONE");

  // print the device information
  printData(insideThermometer1);
  printData(insideThermometer2);
  printData(outsideThermometer3);
}
Attachments
3.png
3.png (89.27 KiB) Viewed 422 times

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit 1-Wire Thermocouple Amplifier - MAX31850K for 3

Post by adafruit_support_mike »

Yeah, that shows different addresses for each of the three sensors.

Glad to see that it's working!

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

Return to “Arduino”