Photon going offline and coming online automatically while using i2c for mlx90621

Hey there,

I am just trying to run an example code for mlx90621. But the photon is going offline continuously.
Here is my code -


#include "MLX90621.h"

MLX90621 sensor; // create an instance of the Sensor class

void setup(){ 
  Serial.println("trying to initialize sensor...");
  sensor.initialise (16); // start the thermo cam with 8 frames per second
  Serial.println("sensor initialized!");
void loop(){
  sensor.measure(); //get new readings from the sensor
  for(int y=0;y<4;y++){ //go through all the rows
    for(int x=0;x<16;x++){ //go through all the columns
      double tempAtXY= sensor.getTemperature(y+x*4); // extract the temperature at position x/y
      if (x<15) Serial.print(",");
    if (y<3)Serial.print("~"); 


When I try to see the serial output on Putty, I can only see "trying to initialize sensor…"
After that, there is a command to initialize the sensor and serial print.
But I never got to see the output of this second serial print command. "Serial.println(“sensor initialized!”);"
What can be the issue here?
Does this means that sensor.initialise command not working? But the code is getting compiled successfully.

Hardware connections -

SCL -> D1
SDA -> D0
VDD -> 3V3 with resistor connected, sensor getting 2.6V input voltage as requured.

Please let me know if you see any catch.

Thanks in advance,

P.S. - My internet connection is ok. I have successfully used same photon for another application.

Color code -

Blinking green
Fast Blinking Blue
Fast blinking Red
Slow blinking Red (4 times)
Fast blinking Red
Slow blinking Red (4 times)

The photon goes offline after this. And the cycle continues.

It looks like the MLX90621 library does not call Wire.begin() inside it. You need to move your Wire.begin() call before your call to sensor.initialise().

If you make Wire calls before calling Wire.begin the Photon will SOS fault.


Your suggestion worked perfectly. I can now see the data on serial and program is working.
However, now I am getting only “nan” values.
This same code, however, is running for Arduino. Showing the outputs. So sensor and hardware connections are verified and correct.

There is some catch in my program or in the mlx library.
Any suggesstions on this.?