Member Since: January 9, 2012

Country: United States

  • I really wanted to use this sensor with a Teensy 3.0 (ARM based) board, but all the working code I could find uses the i2cmaster library and is dependent on the microcontroller being AVR based. I never used I2C before this project so I still can’t get it to run in PWM mode, but I did manage to get the sensor to communicate successfully using Wire.h included in Arduino 1.0.5 and print a readable temperature using some code from the bildr tutorial. I hope this will be of help to someone. #include Wire.h #define LED_pin 13 #define slaveAddress 0x00

    void setup(){
      // An LED will blink to indicate when we have successfully read the temperature
      pinMode(LED_pin, OUTPUT);
      digitalWrite(LED_pin, LOW);
    void loop(){
      // Store the two relevant bytes of data for temperature
      byte dataLow = 0x00;
      byte dataHigh = 0x00;
      Wire.write(0x07);    // This is the command to view object temperature in the sensor's RAM
      Wire.requestFrom(slaveAddress, 2);
      while (Wire.available()){
        dataLow = Wire.read();
        dataHigh = Wire.read();
        digitalWrite(13, HIGH);    // Blink the LED to indicate a successful reading
      digitalWrite(13, LOW);
      double tempFactor = 0.02; // 0.02 degrees per LSB (measurement resolution of the MLX90614)
      double tempData = 0x0000; // zero out the data
      int frac; // data past the decimal point
      // This masks off the error bit of the high byte, then moves it left 8 bits and adds the low byte.
      tempData = (double)(((dataHigh & 0x007F) 
      tempData = (tempData * tempFactor)-0.01;
      float celcius = tempData - 273.15;
      float fahrenheit = (celcius*1.8) + 32;
      Serial.println(" F");

No public wish lists :(