Hey, i am having a problem with my lcd screen.
I have 2 I2C devices connected:
- LCD 20x4 screen
- SCD30 sensor
I have also connected 2 10K resistors from the scl/sda to the 5V line.
The sketch works OK for around 30 minutes and then the screen freezes and no new data is shown.
On the serial monitor i can still see that the sensor is working and outputting data to the serial monitor.
The sketch is fairly simple and short, i'm trying to understand if this is a hardware issue or software and would like some help.
I've also added the pictures of connection (hope its understandable)
#include <Wire.h>
#include "SparkFun_SCD30_Arduino_Library.h"
#include <RTClib.h>
#include <SPI.h>
#include "LCD.h" // For LCD
#include "LiquidCrystal_I2C.h" // Added library*
//Set the pins on the I2C chip used for LCD connections
//ADDR,EN,R/W,RS,D4,D5,D6,D7
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // 0x27 is the default I2C bus address of the backpack-see article
SCD30 airSensor;
RTC_PCF8523 RTC;
const int chipPin = 10;
float lowRH, lowTemp;
void setup()
{
Serial.begin(9600);
Wire.begin();
lcd.begin(20,4);
lowRH = 80;
Serial.println(String(lowRH));
if (airSensor.begin() == false)
{
Serial.println(F("Air sensor not detected. Please check wiring. Freezing..."));
while (1);
}
//
lcd.setBacklightPin(3,POSITIVE); // BL, BL_POL
lcd.setBacklight(HIGH);
//The SCD30 has data ready every two seconds
}
void loop()
{
DateTime now = RTC.now();
float temp,rh;
int co2;
if (airSensor.dataAvailable())
{
co2 = airSensor.getCO2();
temp = airSensor.getTemperature();
rh = airSensor.getHumidity();
Serial.print(F("Co2(ppm):"));
Serial.print(co2);
// lcd.clear();
lcd.setCursor(0,0);
lcd.print("Date:" + String(now.day()) + "/" + String(now.month()) + "/" + String(now.year()));
lcd.setCursor(0,1);
lcd.print(F("Co2(ppm): "));
lcd.print(co2);
Serial.print(F(" Temp(C):"));
Serial.print(temp);
lcd.setCursor(0,2);
lcd.print(F("Temp(C): "));
lcd.print(temp);
Serial.print(F(" Humidity(%):"));
Serial.print(rh);
lcd.setCursor(0,3);
lcd.print(F("Humidity(%):"));
lcd.print(rh);
Serial.println();
if (rh < lowRH){
}
//
}
delay(2000);
}