Hi Everyone!
This is my first post in arduino forum. I'm not programist or informatikier, only I'd like to make aparatus to measure temperature, humadity, gas resistation in air. In this situation I used BME680 sensor, LCD 16,2 with I2C and Arduino Uno. Very simply connections and everythings work, but only since 10s to 10 minutes. After this time my measured results is freeze on LCD in light off backlight.
I read about this problem - 2 device I2C. I read about two methods. Simply - set the interrupt as a short timer, e.g. 1 ms and if it isn't get correct answer at that time, it is out of the "while" loop.
Advenced - doing all I2C support at interrupts + some error handling as I2C communication fails.
But for me this two methods is difficult... I try used differend source and codes but after this time still freeze results in station. I connected LCD without I2C only with digitals pin 2,3,4,5,6 and 7 - you know about this conncetions, and the same problem. In next step I'd like to save all measuerd on microSD but with this I have experience. But with this I don't have new idea...
I know for you is very simply problem, but not for me. Please repair my code to station.
Thanks you
This is my code:
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME680.h"
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
#define SEALEVELPRESSURE_HPA (1013.25)
#define BMP680_I2C_ADDRESS 0x76
Adafruit_BME680 bme; // I2C
void setup() {
lcd.begin(16,2);
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Weather station");
delay(3000);
if (!bme.begin(0x76))
{
Serial.println("Could not find a valid BME680 sensor, check wiring!");
while (1);
}
// Set up oversampling and filter initialization
bme.setTemperatureOversampling(BME680_OS_8X);
bme.setHumidityOversampling(BME680_OS_2X);
bme.setPressureOversampling(BME680_OS_4X);
bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
bme.setGasHeater(320, 150); // 320*C for 150 ms
}
void loop() {
if (! bme.performReading())
{
Serial.println("Failed to perform reading");
return;
}
lcd.setCursor(0,0);
lcd.print("Temperature =");
lcd.print(bme.temperature);
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Pressure = ");
lcd.print(bme.pressure / 100.0);
lcd.print("hPa");
delay(3000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Humidity = ");
lcd.print(bme.humidity);
lcd.print(" %");
lcd.setCursor(0,1);
lcd.print("Gas = ");
lcd.print(bme.gas_resistance / 1000.0);
lcd.print(" KOhms");
delay(3000);
}