Hi,
goal is to estimate dew point. Therefore I build a small barometer with IR temperature, pressure and humidity sensor. Seeeduino xiao and arduino ide 2.0.3 is used.
problem is : IR temperature sensor returns nan value when used together with others sensors activated. IR sensor standalone works (same hardware setup, other sensors not used.)
I checked couple of threads from this forum but didn't found a solution.
This is my setup including error message.
Following i2c devices are used.
0x38 : AHT10 - ASAIR Humidity and Temperature sensor
0x3C : SH1106 - 132 X 64 Dot Matrix OLED
0x5A : IR sensor MLX90614
0x77 : BMP180 - Temp/Barometric
i2c scan shows first pecularity. standard mode recognizes all devices, fast mode miss IR sensor.
****************************
Scanne im standard mode (100 kHz):
0x38
0x3C
0x5A
0x77
Scanne im fast mode (400 kHz):
0x38
0x3C
0x77
****************************
I don't mind using standard mode. I tried using 100kHz and even 50kHz (see sketch) but this didn't helped.
Sketch Example -> Adafruit MLX90614 library -> mlxtest works out of the box
Adafruit MLX90614 test
Emissivity = 1.00
================================================
Ambient = 22.17*C Object = 21.27*C
Ambient = 71.91*F Object = 70.29*F
Without activated IR MLX90614 it works
With all sensors used : IR MLX90614 is recognized but returns nan.
Voltage is 3.3V. All sensors i2c should work with 3.3V.
I tried different pullup resistors (none, 2k, 5k1, 10k) with no difference.
This is the sketch
#include <Adafruit_BMP085.h>
/***************************************************
This is an example for the BMP085 Barometric Pressure & Temp Sensor
Designed specifically to work with the Adafruit BMP085 Breakout
----> BMP085 Barometric Pressure/Temperature/Altitude Sensor- 5V ready : ID 391 : $19.95 : Adafruit Industries, Unique & fun DIY electronics and kits
These pressure and temperature sensors use I2C to communicate, 2 pins
are required to interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
// Connect VCC of the BMP085 sensor to 3.3V (NOT 5.0V!)
// Connect GND to Ground
// Connect SCL to i2c clock - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 5
// Connect SDA to i2c data - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 4
// EOC is not used, it signifies an end of conversion
// XCLR is a reset pin, also not used here
Adafruit_BMP085 bmp;
// AHT20
#include <Adafruit_AHTX0.h>
Adafruit_AHTX0 aht;
// OLED
#include <Wire.h>
#include <Arduino.h>
#include <U8g2lib.h>
U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
//Bibliothek zum betrieb des IR Thermometers MLX90614
#include <Adafruit_MLX90614.h>
//Instanz eines Objektes erzeugen
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
// Funktion zur Berechnung des Taupunktest
float taupunkt(float t, float r);
void setup() {
Wire.begin();
Wire.setClock(50000);
Serial.begin(9600);
// activate internal pullups for twi.
digitalWrite(SDA, 1);
digitalWrite(SCL, 1);
delay(1000);
u8g2.begin();
u8g2.enableUTF8Print(); // enable UTF8 support for the Arduino print() function
u8g2.setFont(u8g2_font_6x13_tf);
u8g2.setFontDirection(0);
// Zeile 1
u8g2.setCursor(0, 12);
if (!bmp.begin()) {
u8g2.println("Could not find a valid BMP085 sensor, check wiring!");
while (1) {}
}
u8g2.println("* BMP180 found");
// Zeile 2
u8g2.setCursor(0, 24);
if (! aht.begin()) {
u8g2.println("Could not find AHT? Check wiring");
while (1) delay(10);
}
u8g2.println("* AHT20 found");
//beginn der Kommunikation mit dem IR Thermometer
// Zeile 3
u8g2.setCursor(0, 36);
if(! mlx.begin()) {
u8g2.println("Could not find a valid IR sensor, check wiring!");
while (1) {}
}
u8g2.println("* IR sensor found");
u8g2.sendBuffer();
delay(2000);
}
void loop() {
sensors_event_t humidity, temp;
aht.getEvent(&humidity, &temp);
u8g2.clearBuffer();
// Zeile 1
u8g2.setCursor(0, 12);
float temperatur = bmp.readTemperature();
u8g2.print("Tempera = ");
u8g2.print(temperatur, 1);
u8g2.print("°C");
// Zeile 2
u8g2.setCursor(0, 24);
double temp_o = mlx.readObjectTempC();
u8g2.print("TObjekt = ");
u8g2.print(temp_o, 1);
u8g2.println("°C");
// Zeile 3
u8g2.setCursor(0, 36);
float feuchte;
aht.getEvent(&humidity, &temp);
feuchte = humidity.relative_humidity;
u8g2.print("Feuchte = ");
u8g2.print(feuchte, 1);
u8g2.println(" %");
// Zeile 4
u8g2.setCursor(0, 48);
u8g2.print("Taupkt = ");
u8g2.print(taupunkt(temperatur, feuchte), 1);
u8g2.println("°C");
u8g2.setCursor(0, 60);
float druck = bmp.readPressure();
u8g2.print("Druck = ");
u8g2.print(druck * 0.75 / 100.0, 1);
u8g2.println(" mmHg");
u8g2.sendBuffer();
delay(2000);
}
float taupunkt(float t, float r)
{
float mw = 18.016; // Molekulargewicht des Wasserdampfes (kg/kmol)
float gk = 8214.3; // universelle Gaskonstante (J/(kmol*K))
float t0 = 273.15; // Absolute Temperatur von 0 °C (Kelvin)
float tk = t + t0; // Temperatur in Kelvin
float a, b;
if (t >= 0) {
a = 7.5;
b = 237.3;
} else if (t < 0) {
a = 7.6;
b = 240.7;
}
// Sättigungsdampfdruck (hPa)
float sdd = 6.1078 * pow(10, (a*t)/(b+t));
// Dampfdruck (hPa)
float dd = sdd * (r/100);
// Wasserdampfdichte bzw. absolute Feuchte (g/m3)
float af = pow(10,5) * mw/gk * dd/tk;
// v-Parameter
float v = log10(dd/6.1078);
// Taupunkttemperatur (°C)
float td = (b*v) / (a-v);
return(td);
}
Any idea or help.
Thanks!