MLX90614 will not compile Arduino examples

I am looking for a complete library with all dependent header files, examples of code etc. I have downloaded and tried running the Adafruit and other MLX90614 examples off git hub, Arduino site (here) etc. Each time ther eis a "begin()" error I have not been able to find / fix.

I am just trying to compile the code (not upload it yet). Once it will compile, then I can upload it to the Mega2560 and try the sensor.

I am new to the sensor and not a professional programmer so any help is much appreciated!

Please post a full sketch that illustrates the problem, using code tags when you do, and the full error message, also using code tags

Its looking like it needs AsyncDelay.h and SoftWire.h I downloaded both and it compiles fine (once I comment out "DisableJTAG.h").

The board is hooked up and the code is running.I am using the stock sample code in the library i downloaded here (Arduino.cc) with the exception of the "JTAG" I mentioned above. No other code changes.
Here is the code:



#include <AsyncDelay.h>
#include <SoftWire.h>
#include <MLX90614.h>

#ifdef JTD
//#include <DisableJTAG.h>
#endif

MLX90614 mlx90614;
AsyncDelay samplingInterval;

inline float convertToDegC(int16_t data)
{
  return (data / 100.0);
}

void setup(void)
{
  Serial.begin(9600);
  Serial.println("MLX90614_demo");
#ifdef JTD
//  disableJTAG();
#endif
  mlx90614.initialise();
  mlx90614.getSoftWire().setDelay_us(2);
  samplingInterval.start(1000, AsyncDelay::MILLIS);
}

bool printed = true;
void loop(void)
{
  if (samplingInterval.isExpired() && !mlx90614.isSampling()) {
    mlx90614.start();
    printed = false;
    samplingInterval.repeat();
    Serial.println("Sampling started");
  }

  mlx90614.process();

  if (mlx90614.isFinished() && !printed) {
    printed = true;
    // Print saved values
    Serial.print("Ambient: ");
    Serial.print(convertToDegC(mlx90614.getAmbient()));
    Serial.print("    Object 1: ");
    Serial.print(convertToDegC(mlx90614.getObject1()));
    if (mlx90614.isDualSensor()) {
      Serial.print("Object 2: ");
      Serial.print(convertToDegC(mlx90614.getObject2()));
    }
    Serial.println();
  }
  
}







My output is as follows:



18:15:51.228 -> MLX90614_demo
18:15:52.258 -> Sampling started
18:15:53.522 -> Ambient: 327.67    Object 1: 327.67
18:15:53.568 -> Sampling started
18:15:54.832 -> Ambient: 327.67    Object 1: 327.67
18:15:54.879 -> Sampling started
18:15:56.096 -> Ambient: 327.67    Object 1: 327.67
18:15:56.142 -> Sampling started
18:15:57.406 -> Ambient: 327.67    Object 1: 327.67
18:15:57.453 -> Sampling started
18:15:58.654 -> Ambient: 327.67    Object 1: 327.67
18:15:58.701 -> Sampling started
18:15:59.964 -> Ambient: 327.67    Object 1: 327.67
18:16:00.011 -> Sampling started

Any and all help is appreciated!!

I just noticed there is no Wire.begin() in the code. I guess the "SoftWire.h" replaces the "Wire.h"?

If 'things' are not being found, then the compiler should generate an error.

You didn't mention if you have pull ups on the communications lines. Are you sure of the operational voltage... Some are 5V and others are 3V3.

I notice the numbers are all the same. From my experience with these, I'd think you have a communication error of some type with the device. Since all the numbers are the same.

327 C is pretty warm for either temperature...

If the libraries are working, then I'd guess the device and micro are not talking as expected. And I'd double check the interface... scope would be nice...

I'm not familiar with these libraries, I use the I2C libraries. Can you get to the 'raw' data to examine?


One issue I did encounter was that a lot of the devices I purchased, upon POR, default of pwm output, not the SMBus. I found a sketch to change it back, so I'm not the only one that's had that occur.

Data sheet... says...


The factory default POR setting is SMBus.


Although the SMBus is commonly used with an I2C, there are differences. The SMBus can time out and I don't think the I2C bus can. How could you check?

Good luck

:smiley_cat:

Wire.h or not does not seem to make a difference when running: I still get the same nonsensical result I posted above.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.