Can't get output from MLX90614 on Arduino IoT Cloud

Hi,

I can't seem to get any output on the serial monitor and dashboard on the Arduino IoT Cloud using my Nano 33 IoT and an MLX90614 temperature sensor. My code works on the Arduino IDE however. I've tried a bunch of different codes which all work on the Arduino IDE but not on the IoT Cloud. The following is my code on the Arduino IoT Cloud. Any advice would be helpful.

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/30f5b597-7ec4-4af4-bb5b-6839a8cec40a 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  float temperature;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"
#include <Adafruit_MLX90614.h>

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
  if (!mlx.begin()) {
    Serial.println("Error connecting to MLX sensor. Check wiring.");
    while (1);
    
  }
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  temperature = mlx.readObjectTempC();
  Serial.print("C/tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
  Serial.println();
  delay(1000);
  
}


What happens if you try a basic version of the sketch without the Arduino IoT Cloud stuff? Are you able to see the temperature printout in Serial Monitor?

#include <Adafruit_MLX90614.h>

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

void setup() {
  Serial.begin(9600);
  while(!Serial) {}
  if (!mlx.begin()) {
    Serial.println("Error connecting to MLX sensor. Check wiring.");
    while (1);
  }
}

void loop() {
  Serial.print("C/tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
  delay(1000);
}

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