nRF24 / RF24

OSI Layer 2 driver for nRF24L01 on Arduino & Raspberry Pi/Linux Devices
https://nrf24.github.io/RF24
GNU General Public License v2.0
2.22k stars 1.02k forks source link

ESP32 and two Infrared Temperature Sensors (MLX90614) #928

Closed UdiNuwan closed 11 months ago

UdiNuwan commented 11 months ago

I'm Working with ESP32 and two Infrared Temperature Sensors (MLX90614). But I cant get accurate value in sensor reading. Following is my code and output

Code :

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

#define SDA_1 13
#define SCL_1 14

#define SDA_2 26
#define SCL_2 27

TwoWire I2Cone = TwoWire(0);
TwoWire I2Ctwo = TwoWire(1);

Adafruit_MLX90614 mlx1 = Adafruit_MLX90614();
Adafruit_MLX90614 mlx2 = Adafruit_MLX90614();

void setup() {
Serial.begin(115200);
Serial.println(F("mlx test"));

I2Cone.begin(SDA_1, SCL_1, 50000);
I2Ctwo.begin(SDA_2, SCL_2, 50000);

mlx1.begin(0x5A, &I2Cone);

mlx2.begin(0x5A, &I2Ctwo);

Serial.println();
}

void loop() {
Serial.print("Ambient temperature = ");
Serial.print(mlx1.readAmbientTempC());
Serial.print("°C");
Serial.print(" ");
Serial.print("Object temperature = ");
Serial.print(mlx1.readObjectTempC());
Serial.println("°C");

Serial.print("Ambient temperature = ");
Serial.print(mlx2.readAmbientTempC());
Serial.print("°C");
Serial.print(" ");
Serial.print("Object temperature = ");
Serial.print(mlx2.readObjectTempC());
Serial.println("°C");

Serial.println("-----------------------------------------------------------------");
delay(2000);
}

Output :

23:20:21.387 -> Ambient temperature = nan°C Object temperature = nan��C
23:20:21.387 -> -----------------------------------------------------------------
23:20:23.377 -> Ambient temperature = 27.73°C Object temperature = -177.13°C
23:20:23.377 -> Ambient temperature = 27.63°C Object temperature = 28.37°C
23:20:23.377 -> -----------------------------------------------------------------
23:20:25.372 -> Ambient temperature = nan°C Object temperature = nan°C
23:20:25.372 -> Ambient temperature = nan°C Object temperature = nan��C
23:20:25.404 -> -----------------------------------------------------------------
23:20:27.377 -> Ambient temperature = 27.73°C Object temperature = -177.13°C
23:20:27.377 -> Ambient temperature = 27.65°C Object temperature = 28.27°C
23:20:27.405 -> -----------------------------------------------------------------
23:20:29.405 -> Ambient temperature = nan��C Object temperature = nan°C
23:20:29.405 -> Ambient temperature = nan°C Object temperature = nan°C
23:20:29.405 -> -----------------------------------------------------------------
2bndy5 commented 11 months ago

This isn't the Arduino forums. This is for reporting RF24 library problems.