Hola exelente paguina

Peter maybe you can to help me (no it so important, but if you know or is easy I would like to do it).

Is about the temperature sensor, I found in internet two arduino codes to programing the sensors MLX90614, the first one use Adafruit library, I like this code because offer two temperatures, the ambient temperature and the object temperature (by sensor). But this code not works for more of one sensor.

I found other code that works with more o one sensor, but only offer the object temperature. This is the code that I’m using because I need to get differents object temperatures at same time.

So, I would like to have two temperatures by sensor.
The specific question is, Do you know how to do for get both temperatures by sensor with the last code (code that I’m using).

I do not know much about arduino, practically all of things that I use, are really a colash of several parts, until I get that I want or I’m looking for in the same code.

Thanks.

This are the codes:

With Adafruit library

/***************************************************
This is a library example for the MLX90614 Temp Sensor

Designed specifically to work with the MLX90614 sensors in the
adafruit shop
----> https://www.adafruit.com/products/1748
----> https://www.adafruit.com/products/1749

These sensors use I2C to communicate, 2 pins are required to
interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/

#include <Wire.h>
#include <Adafruit_MLX90614.h>

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

void setup() {
Serial.begin(9600);

Serial.println(“Adafruit MLX90614 test”);

mlx.begin();

}

void loop() {
Serial.print(“Ambient-NT = “); Serial.print(mlx.readAmbientTempC());
Serial.print(”*C\tLeaf-NT = “); Serial.print(mlx.readObjectTempC()); Serial.println(”*C”);

Serial.println();
delay(500);
}

And the other one with i2cmaster.h librery:

/**

  • Dos termómetros infrarrojos MLX906114
  • por Jaime Patarroyo
  • basado en ‘Is it hot? Arduino + MLX90614 IR Thermometer’ por bildr.blog
  • Devuelve la temperatura en Celcius y Fahrenheit de dos termómetros
  • infrarrojos MLX90614, conectados a los pines TWI/I²C (en la tarjeta
  • Wiring v1: 0 (SCL) y 1 (SDA) y en la tarjeta Wiring S: 8 (SCL) y 9 (SDA)).

*/
#include <Wire.h>
#include <i2cmaster.h>

int device1Address = 0x2A<<1; // 0x50 es la dirección asignada para
// comunicación I²C del sensor 1.
// Corra la dirección 1 bit a la derecha, la
// librería I²Cmaster solo necesita los 7 bits
// mas significativos para la dirección.
int device2Address = 0x34<<1; // 0x55 es la dirección asignada para
// comunicación I²C del sensor 1.
// Corra la dirección 1 bit a la derecha, la
// librería I²Cmaster solo necesita los 7 bits
// mas significativos para la dirección.

int device3Address = 0x5A<<1; // 0x55 es la dirección asignada para
// comunicación I²C del sensor 1.
// Corra la dirección 1 bit a la derecha, la
// librería I²Cmaster solo necesita los 7 bits
// mas significativos para la dirección.

int device4Address = 0x74<<1; // 0x55 es la dirección asignada para
// comunicación I²C del sensor 1.
// Corra la dirección 1 bit a la derecha, la
// librería I²Cmaster solo necesita los 7 bits
// mas significativos para la dirección.

//Adafruit_MLX90614 mlx = Adafruit_MLX90614();

float celcius1 = 0; // Variable que contiene la temperatura en Celcius
// para el sensor 1.
float celcius2 = 0; // Variable que contiene la temperatura en Celcius
// para el sensor 2.
float celcius3 = 0; // Variable que contiene la temperatura en Celcius
// para el sensor 3.
float celcius4 = 0; // Variable que contiene la temperatura en Celcius
// para el sensor 4.

void setup()
{
Serial.begin(9600); // Inicia la comunicación serial a 9600bps.

i2c_init(); // Inicia el bus i2c.
PORTC = (1 << PORTC4) | (1 << PORTC5); // Habilita ‘pullups’.
}

void loop()
{
celcius1 = temperatureCelcius(device1Address);// Lee los datos del MLX90614
celcius2 = temperatureCelcius(device2Address);// con la dirección dada,
celcius3 = temperatureCelcius(device3Address); // los transforma en
celcius4 = temperatureCelcius(device4Address); // temperatura en Celcius y
// la guarda en las variables
// celcius1 o celcius2.

Serial.print(celcius1); // el puerto serial.
Serial.print(" “);
Serial.print(celcius2);
Serial.print(” “);
Serial.print(celcius3);
Serial.print(” ");
Serial.println(celcius4);

delay(1000); // Espera un segundo para imprimir de nuevo.
}

float temperatureCelcius(int address) {
int dev = address;
int data_low = 0;
int data_high = 0;
int pec = 0;

// Escribe
i2c_start_wait(dev+I2C_WRITE);
i2c_write(0x07);

// Lee
i2c_rep_start(dev+I2C_READ);
data_low = i2c_readAck(); // Lee 1 byte y envía ack.
data_high = i2c_readAck(); // Lee 1 byte y envía ack
pec = i2c_readNak();
i2c_stop();

// Esto convierte los bytes altos y bajos juntos y procesa la temperatura.
double tempFactor = 0.02; // 0.02 grados por LSB (medida de
// resolución del MLX90614).
double tempData = 0x0000;
int frac; // Datos después del punto decimal.

// Esto oculta el error del byte alto y lo mueve a la izquierda
// 8 bits y agrega el byte bajo.
tempData = (double)(((data_high & 0x007F) << 8) + data_low);
tempData = (tempData * tempFactor)-0.01;
float celcius = tempData - 273.15;

// Retorna la temperatura en Celcius.
return celcius;
}