Infrared temperature sensor

frohr

Well-known member
Hi all,
I have Teeny 4 with OLED display connected to SCL0 and SDA0. It works fine. Now I connected infrared temperature sensor MLX90614, GY-906 on SCL1 and SDA1. But I can see value about 1037°C what is wrong. I think I have to address it correct but I have no clue how. Below is code for MLX90614 only - but values are the same in my code with OLED.
Could you help me?
Thanks!

Code:
#include <Wire.h>
#include <Adafruit_MLX90614.h>

Adafruit_MLX90614 mlx = Adafruit_MLX90614();

void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit MLX90614 test");  
  mlx.begin();  
}

void loop() {
  Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC()); 
  Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C");
  Serial.println();
  delay(500);
}
 
OK, thank you, it is more clear for me now.
But how to define address?

I have:

Code:
#include <Adafruit_SSD1306.h>  
#include <Adafruit_MLX90614.h>

Adafruit_SSD1306 display(128, 64, &Wire, -1, 1000000);  // 1MHz I2C clock OLED DISPLAY
Adafruit_MLX90614 mlx = Adafruit_MLX90614(); //TEMPERATURE SENSOR

void setup()
 {
 display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
 mlx.begin(); //HOW to address?
}

void loop() 
{
  display.setCursor(15,25);
  display.print("text1);
  display.setCursor(60,35);
  display.print(mlx.readObjectTempC());
}

Thank you.
 
First ensure that the MLX90614 is 3v by checking the part code written on the casing. Also those devices have programmable address which only can be changed using global i2c address with only one device on the bus.
If it's 5v you can use a cheap level translator.
 
Hi, thanks. If temperature sensor MLX90614 is connected then I have nonsense chars on display. If I disconnect it, its ok (without values from sensor of course). Any idea?


Code:
#include <Adafruit_MLX90614.h>
#include <Adafruit_GFX.h>      
#include <Adafruit_SSD1306.h>   

Adafruit_SSD1306 display(128, 64, &Wire, -1, 1000000);  
Adafruit_MLX90614 mlx = Adafruit_MLX90614(0x5A);

void setup()
 {
   Serial.begin(1500000);
   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
   display.clearDisplay();
   display.display();
   mlx.begin();
}

 void loop() 
  {
      display.clearDisplay(); 
      display.setTextSize(1);
      display.setTextColor(1);
         
      display.setCursor(15,10);
      display.println("AAA");
 
      display.setCursor(15,25);
      display.print("BBB");

      display.setCursor(15,40);
      display.print("CCC");

      display.setCursor(50,10);
      display.print("aaa");

      display.setCursor(50,25);
      display.print("bbb");

      display.setCursor(50,40);
      display.print(mlx.readObjectTempC());
     
      display.display();  
}

connected.JPG
disconnected.JPG
 
Code:
Adafruit_SSD1306 display(128, 64, &Wire, -1, 1000000);
Test a slower speed. 1MHZ is much for I2C.
If that works, you can test shorter cables.
 
If that doesn't work, it looks like it would be easy to move the OLED display to SCL1 and SDA1.
 
Yes, I will try. But if I connected OLED to SCL0 / SDA0 and sensor to SCL1 / SDA1 and I run Wire / Scanner I saw only OLED but not temperature sensor.
 
Yes, but the reverse should work if you use:

Adafruit_SSD1306 display(128, 64, &Wire1, -1, 1000000);

Ie, the SSD1306 is easy to move to different connections. The temp sensor is best on SCL0 / SDA0.
 
Could it be the MLX has been set to PWM output?

Is the MLX programmed to 0x5A? Try to leave out the address to use the default with the Adafruit example on SCL0/SDA0 and alone without displays to test.

Could it be the MLX has been accidentially "recalibrated" to nonsense?
Do the SDA and SCL have pull-up to 3.3V? May use 4k7 to be on the safe side. Some OLED displays have the pull-up already, so take them out and have them only on the last device.
Try set I2C to 200kHz.
 
Back
Top