Digistump Forums

The Oak by Digistump => Oak Support => Topic started by: digi_guy on May 27, 2016, 09:28:13 am

Title: MLX90614 Temp Sensor over I2C
Post by: digi_guy on May 27, 2016, 09:28:13 am
Hey guys,

I've been trying to get an infrared thermometer working over i2c, but currently my readings are way off. It's the MLX90614 (https://www.adafruit.com/product/1747) from Adafruit, using their library from github
https://github.com/adafruit/Adafruit-MLX90614-Library

My guess is that it was written for a different arduino and needs to get ported for the Oak, but I'm not sure where to start with that. The output I get is
Code: [Select]
Ambient: 536870912 Temp: 1083192883
My second guess is that I'm not reading/writig the variables properly. When I changed the temps to integers I get
Code: [Select]
Ambient: 34 Temp: 35
If anyone has any thoughts I'd greatly appreciate hearing them.
Thanks


Code: [Select]
/***************************************************
  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() {
  Particle.publish("Status", "Adafruit MLX90614 test");
  mlx.begin(); 
   
  double ambient =   mlx.readAmbientTempC();
  double tempC =   mlx.readObjectTempC();
   
  char buff[64];
  sprintf(buff, "Ambient: %d Temp: %d", ambient, tempC);
  Particle.publish("Ambiant", buff);
 
}

void loop() {
}

Title: Re: MLX90614 Temp Sensor over I2C
Post by: masrodjie on October 03, 2017, 04:38:10 pm
I know it's old but maybe it can help for others.
You can use dtostrf function.

Code: [Select]
/***************************************************
  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() {
  Particle.publish("Status", "Adafruit MLX90614 test");
  mlx.begin(); 
   
  char ambient[64];
  char tempC[64];
  dtostrf(mlx.readAmbientTempC(), 2, 2, ambient);
  dtostrf(mlx.readObjectTempC(), 2, 2, tempC);
  char buff[64];
  sprintf(buff, "Ambient: %s Temp: %s", ambient, tempC);
  dtostrf(temp, 2, 2, msg);
  Particle.publish("Ambiant", buff);
 
}

void loop() {
}