Hi @paulvha , I am trying to integrate an OLED with a scd30 sensor over esp32, but I am getting some TwoWire errors.
My code is:
#include <Wire.h>
#include <WiFi.h>
#include <esp_wpa2.h>
#include <FirebaseESP32.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include "paulvha_SCD30.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define EAP_ANONYMOUS_IDENTITY "[email protected]"
#define EAP_IDENTITY "[email protected]"
#define EAP_PASSWORD "epreslab@iitd"
const char* ssid = "IITD_WIFI";
int counter = 0;
WiFiClient client;
int rssi;
String notif_wifi, notif_sensor;
#define FIREBASE_HOST "labindividuallight.firebaseio.com"
#define FIREBASE_AUTH "tQNM1JXaHbrkpyVdavuwayNLnnzi0d4srHk6mptT"
FirebaseData firebaseData;
const long utcOffsetInSeconds = 19800;
String formattedDate, dateStamp, dateStamp_display, dateStamp_firebase, timeStamp, timeStamp_display, timeStamp_firebase;
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org", utcOffsetInSeconds);
#define scd_debug 0
#define SCD30_I2C_ADDRESS 0x61
SCD30 scd30;
float temperature, humidity; int co2;
String temp_str, hum_str, co2_str;
Adafruit_SSD1306 display(-1);
#define OLED_I2C_ADDRESS 0x3C
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
const unsigned char EPRESlogo [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xdc,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xdc, 0x02, 0x00,
0x00, 0x00, 0x08, 0x01, 0xdc, 0x42, 0x00, 0x00, 0x00, 0x00, 0x41, 0x9c, 0x40, 0x00, 0x00, 0x00,
0x1f, 0xc1, 0xbc, 0x40, 0x00, 0x00, 0x00, 0x1f, 0xc0, 0x00, 0x42, 0x00, 0x00, 0x00, 0x1f, 0xc0,
0x00, 0x40, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x80, 0x00, 0x00,
0x00, 0x70, 0x00, 0x19, 0x80, 0x06, 0x00, 0x00, 0x50, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x70,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00,
0x00, 0x22, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41,
0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x41, 0x00, 0x07,
0x77, 0x00, 0x00, 0x00, 0x22, 0x00, 0x1f, 0x27, 0xe0, 0x30, 0x00, 0x1c, 0x00, 0x36, 0x23, 0xa0,
0x20, 0x00, 0x00, 0x00, 0x38, 0x20, 0xe0, 0x3e, 0x00, 0x00, 0x00, 0x10, 0x20, 0x40, 0x87, 0x00,
0x00, 0x20, 0x00, 0x20, 0x00, 0x81, 0x00, 0x00, 0x00, 0x00, 0x20, 0x07, 0xe7, 0x00, 0x00, 0x00,
0x00, 0x20, 0x0d, 0x6c, 0x00, 0x06, 0x40, 0x00, 0x00, 0x0f, 0x38, 0x00, 0x07, 0xc0, 0x00, 0x00,
0x2f, 0xf0, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x25, 0xe0, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x14, 0xc0,
0x00, 0x00, 0x0f, 0xe0, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x08, 0x20, 0x00, 0x86, 0x00, 0x00, 0x00,
0x0b, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x08, 0x20, 0x00, 0x34, 0x00, 0x00, 0x00, 0x0f, 0xe0,
0x00, 0x18, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char IITDLogo [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00,
0xdf, 0xff, 0x80, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x0f, 0xe0, 0x03,
0xf8, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x78, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x1f, 0x00,
0x00, 0x00, 0x78, 0x0d, 0x80, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x20, 0x0c, 0x03, 0x80, 0x00, 0x01,
0xe1, 0x40, 0x01, 0x81, 0xe0, 0x00, 0x03, 0x81, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x03, 0x80, 0x01,
0xc0, 0x00, 0x60, 0x00, 0x07, 0x08, 0x01, 0xe2, 0x00, 0x78, 0x00, 0x0e, 0x00, 0x78, 0x0f, 0x00,
0x38, 0x00, 0x0e, 0x20, 0x60, 0x03, 0x82, 0x18, 0x00, 0x0c, 0x20, 0x40, 0x00, 0x00, 0x1c, 0x00,
0x1c, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x38, 0x06, 0x00, 0x00, 0x30, 0x0e, 0x00, 0x38, 0x06,
0x00, 0x00, 0x38, 0xce, 0x00, 0x38, 0x8c, 0x00, 0x00, 0x18, 0x06, 0x00, 0x70, 0x04, 0x00, 0x00,
0x10, 0x07, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x06,
0x00, 0x30, 0x18, 0x00, 0x00, 0x0c, 0x07, 0x00, 0x73, 0x18, 0x00, 0x80, 0x0c, 0xc7, 0x00, 0x73,
0x18, 0x00, 0x00, 0x0c, 0xc7, 0x00, 0x70, 0x18, 0x00, 0xc0, 0x0c, 0x07, 0x00, 0x30, 0x08, 0x00,
0x00, 0x00, 0x07, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x70, 0x84, 0x00, 0x00, 0x10,
0x07, 0x00, 0x30, 0x8c, 0x00, 0x00, 0x18, 0x06, 0x00, 0x18, 0x86, 0x00, 0x00, 0x38, 0x0e, 0x00,
0x38, 0x46, 0x00, 0x00, 0x31, 0x0e, 0x00, 0x38, 0x40, 0x00, 0x80, 0x01, 0x0e, 0x00, 0x1c, 0x20,
0x00, 0x10, 0x00, 0x18, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x0e, 0x08, 0x00, 0x00,
0x00, 0x38, 0x00, 0x0f, 0x0c, 0x00, 0x00, 0x08, 0x70, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x60,
0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x03, 0xc0, 0x00, 0x01, 0x81, 0xe0, 0x00, 0x00,
0x70, 0x00, 0x06, 0x03, 0x80, 0x00, 0x00, 0x78, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x7c, 0x00,
0x00, 0x1f, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x0f, 0xe0, 0x03, 0xf8,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x80, 0x00, 0x00,
0x00, 0x00, 0x0d, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
const unsigned char temperatureLogo [] PROGMEM = {
0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x0c, 0x70, 0x00, 0x00, 0x00, 0x18, 0x18, 0x60, 0x00, 0x00,
0x11, 0x88, 0xf0, 0x00, 0x00, 0x32, 0xcc, 0xf0, 0x00, 0x00, 0x26, 0x6c, 0x60, 0x00, 0x00, 0x26,
0x6c, 0x0f, 0x80, 0x00, 0x27, 0xec, 0x18, 0xc0, 0x00, 0x27, 0xec, 0x18, 0xc0, 0x00, 0x26, 0x6c,
0x18, 0x00, 0x00, 0x26, 0x60, 0x18, 0x00, 0x00, 0x26, 0x60, 0x18, 0x00, 0x00, 0x27, 0xe4, 0x18,
0x00, 0x00, 0x26, 0x6c, 0x18, 0x00, 0x00, 0x26, 0x6c, 0x18, 0xc0, 0x00, 0x26, 0x6c, 0x0f, 0x80,
0x00, 0x26, 0x6c, 0x07, 0x00, 0x00, 0x27, 0xec, 0x00, 0x00, 0x00, 0x26, 0x6c, 0x00, 0x00, 0x00,
0x26, 0x6c, 0x00, 0x00, 0x00, 0x26, 0x6c, 0x00, 0x00, 0x00, 0x27, 0xec, 0x00, 0x00, 0x00, 0x26,
0x6c, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0xc6, 0x63, 0x00, 0x00, 0x00, 0x8c, 0x31,
0x00, 0x00, 0x01, 0x90, 0x19, 0x80, 0x00, 0x01, 0x30, 0x0c, 0x80, 0x00, 0x03, 0x20, 0x04, 0x80,
0x00, 0x03, 0x20, 0x04, 0xc0, 0x00, 0x03, 0x60, 0x04, 0xc0, 0x00, 0x03, 0x20, 0x04, 0xc0, 0x00,
0x01, 0x20, 0x04, 0x80, 0x00, 0x01, 0x30, 0x0c, 0x80, 0x00, 0x01, 0x80, 0x19, 0x80, 0x00, 0x00,
0x8f, 0xf1, 0x00, 0x00, 0x00, 0x43, 0xc2, 0x00, 0x00, 0x00, 0x30, 0x0c, 0x00, 0x00, 0x00, 0x1c,
0x38, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00
};
const unsigned char humidityLogo [] PROGMEM = {
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xc0, 0x18, 0x00, 0x00, 0x01, 0xe0, 0x2c, 0x00, 0x00,
0x01, 0xe0, 0x64, 0x00, 0x00, 0x03, 0xf0, 0x46, 0x00, 0x00, 0x06, 0xf8, 0x83, 0x00, 0x00, 0x06,
0xf8, 0x09, 0x00, 0x00, 0x0c, 0x7c, 0x0d, 0x80, 0x00, 0x18, 0x3e, 0x06, 0x80, 0x00, 0x18, 0x3e,
0x02, 0xc0, 0x00, 0x30, 0x1f, 0x03, 0x40, 0x00, 0x30, 0x1f, 0x81, 0x60, 0x00, 0x00, 0x0f, 0x81,
0xa0, 0x00, 0x40, 0x07, 0xc0, 0xb0, 0x00, 0xc0, 0x07, 0xc0, 0x90, 0x00, 0x80, 0x03, 0xe0, 0xd0,
0x00, 0x80, 0x03, 0xe0, 0x10, 0x00, 0x3c, 0x03, 0xf0, 0x10, 0x03, 0x7f, 0x07, 0xf0, 0x10, 0x02,
0x63, 0x8e, 0xf8, 0x10, 0x06, 0x43, 0x9d, 0xf8, 0x30, 0x06, 0x63, 0xbb, 0xf8, 0x20, 0x0c, 0x7f,
0x77, 0xfc, 0x40, 0x0c, 0x3c, 0xef, 0x7d, 0x80, 0x0c, 0x00, 0xde, 0x7f, 0x00, 0x08, 0x02, 0x3c,
0x3c, 0x00, 0x08, 0x06, 0x78, 0x3c, 0x00, 0x08, 0x0e, 0xf0, 0x3c, 0x00, 0x08, 0x1d, 0xef, 0x3c,
0x00, 0x0c, 0x3b, 0xdf, 0xfc, 0x00, 0x0c, 0x77, 0xb1, 0xfc, 0x00, 0x04, 0xef, 0x30, 0x78, 0x00,
0x06, 0xde, 0x30, 0xf8, 0x00, 0x03, 0xfc, 0x1f, 0xf0, 0x00, 0x03, 0xf0, 0x0f, 0xf0, 0x00, 0x01,
0xc0, 0x03, 0xe0, 0x00, 0x00, 0xe0, 0x0f, 0xc0, 0x00, 0x00, 0x78, 0x1f, 0x80, 0x00, 0x00, 0x1f,
0xfe, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x00
};
const unsigned char co2Logo [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x01, 0xa0, 0x00, 0x00,
0x03, 0xe1, 0xe0, 0x00, 0x00, 0x0c, 0x18, 0xc0, 0x00, 0x07, 0xd8, 0x0c, 0x00, 0x00, 0x1c, 0x70,
0x04, 0x00, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x40, 0x00, 0x02,
0x00, 0x00, 0x40, 0x00, 0x02, 0xe0, 0x00, 0x40, 0x00, 0x03, 0xf8, 0x07, 0x40, 0x00, 0x00, 0x04,
0x1f, 0xc3, 0x87, 0x00, 0x02, 0x20, 0x07, 0xdf, 0x80, 0x03, 0x40, 0x0c, 0x58, 0xc0, 0x01, 0xc0,
0x0c, 0x18, 0xc0, 0x01, 0x80, 0x0c, 0x18, 0xc0, 0x01, 0x80, 0x04, 0xd9, 0x98, 0x01, 0x80, 0x07,
0xcf, 0x3c, 0x01, 0x80, 0x00, 0x00, 0x08, 0x01, 0x80, 0x00, 0x00, 0x38, 0x01, 0xc0, 0x00, 0x00,
0x18, 0x03, 0x40, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x04, 0x1f, 0xff, 0xff, 0xf1,
0xf8, 0x07, 0xff, 0xff, 0xf3, 0xe0, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00,
0x00, 0x1b, 0x00, 0x00, 0x00, 0x01, 0x9b, 0x00, 0x00, 0x00, 0x01, 0xce, 0x00, 0x00, 0x00, 0x01,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
void setup()
{
Serial.begin(9600);
Wire.begin();
Wire.beginTransmission(SCD30_I2C_ADDRESS);
scd30.setDebug(scd_debug);
scd30.begin(Wire);
scd30.setAutoSelfCalibration(1);
delay(1000);
display.begin(SSD1306_SWITCHCAPVCC, OLED_I2C_ADDRESS);
display.clearDisplay();
display.setTextColor(WHITE, BLACK);
display.setTextWrap(false);
delay(10);
Serial.println();
Serial.print("Connecting to network: ");
display.setCursor(8, 25);
display.setTextSize(2);
display.println("Connecting to network: ");
display.display(); delay(3000);
display.clearDisplay();
Serial.println(ssid);
WiFi.disconnect(true);
WiFi.mode(WIFI_STA); //init wifi mode
esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_ANONYMOUS_IDENTITY, strlen(EAP_ANONYMOUS_IDENTITY));
esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY));
esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD));
esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT(); //set config settings to default
esp_wifi_sta_wpa2_ent_enable(&config); //set config settings to enable function
WiFi.begin(ssid);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
counter++;
if (counter >= 60) //after 30 seconds timeout - reset board
{
ESP.restart();
}
}
Serial.println("");
Serial.println("WiFi connected");
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
// WELCOME SCREEN
rssi = WiFi.RSSI();
networkStrength(rssi);
if (rssi < 0)
{
NTP();
display.setCursor(8, 25);
display.setTextSize(2);
display.println("Datalogger");
display.display(); delay(3000);
display.clearDisplay();
NTP();
networkStrength(rssi);
display.drawBitmap(10, 15, EPRESlogo, 50, 50, WHITE);
display.drawBitmap(65, 15, IITDLogo, 50, 50, WHITE);
display.display(); delay(3000);
display.clearDisplay();
}
else
{
display.setCursor(8, 25);
display.setTextSize(2);
display.println("Datalogger");
display.display(); delay(3000);
display.clearDisplay();
networkStrength(rssi);
display.drawBitmap(10, 15, EPRESlogo, 50, 50, WHITE);
display.drawBitmap(65, 15, IITDLogo, 50, 50, WHITE);
display.display(); delay(3000);
display.clearDisplay();
}
}
void loop()
{
temperature = 0;
humidity = 0;
co2 = 0;
if (scd30.dataAvailable())
{
temperature = scd30.getTemperature(); temp_str = String(temperature) + "C";
humidity = scd30.getHumidity(); hum_str = String(humidity) + "%";
co2 = scd30.getCO2(); co2_str = String(co2) + "ppm";
notif_wifi = "";
notif_sensor = "";
LCDdisplay(temp_str, hum_str, co2_str, notif_wifi, notif_sensor);
Serial.print("co2(ppm):"); Serial.print(scd30.getCO2());
Serial.print(" temp(C):"); Serial.print(scd30.getTemperature(), 1);
Serial.print(" humidity(%):"); Serial.print(scd30.getHumidity(), 1);
}
else
{
temp_str = "No Data";
hum_str = "No Data";
co2_str = "No Data";
notif_wifi = "";
notif_sensor = "Check Sensor";
LCDdisplay(temp_str, hum_str, co2_str, notif_wifi, notif_sensor);
Serial.println("No data");
}
// const size_t capacity = JSON_ARRAY_SIZE(2) + JSON_OBJECT_SIZE(3);
// DynamicJsonBuffer jsonBuffer(capacity);
// JsonObject& root1 = jsonBuffer.createObject();
// JsonObject& root2 = jsonBuffer.createObject();
//
// root1["Date"] = dateStamp_firebase;
// root1["Time"] = timeStamp_firebase;
// root1["Temperature"] = temperature;
// root1["Humidity"] = humidity;
// root1["CO2"] = co2;
//
// root2["Temperature"] = temperature;
// root2["Humidity"] = humidity;
// root2["CO2"] = co2;
//
// String path1 = "/SensorValues";
// String path2 = "/SensorValuesLog/" + dateStamp_firebase + "/" + timeStamp_firebase;
// Firebase.set(path1, root1);
// Firebase.set(path2, root2);
// root1.printTo(Serial); Serial.println(); root2.printTo(Serial); Serial.println();
}
void networkStrength(int rssiVal)
{
if (rssiVal >= 0)
{
display.fillRect(123, 8, 1, 4, BLACK);
display.fillRect(125, 5, 1, 7, BLACK);
display.fillRect(127, 1, 1, 11, BLACK);
}
else if (rssiVal >= -50 && rssiVal < 0)
{
display.fillRect(123, 8, 1, 4, WHITE);
display.fillRect(125, 5, 1, 7, WHITE);
display.fillRect(127, 1, 1, 11, WHITE);
}
else if (rssiVal < -50 && rssiVal > -75)
{
display.fillRect(123, 8, 1, 4, WHITE);
display.fillRect(125, 5, 1, 7, WHITE);
}
else
{
display.fillRect(123, 8, 1, 4, WHITE);
}
}
void NTP()
{
timeClient.begin();
while (!timeClient.update())
{
timeClient.forceUpdate();
}
String formattedDate = timeClient.getFormattedDate();
int splitT = formattedDate.indexOf("T");
String dateStamp_display_temp = formattedDate.substring(0, splitT);
String day = String(dateStamp_display_temp[8]) + String(dateStamp_display_temp[9]);
String month = String(dateStamp_display_temp[5]) + String(dateStamp_display_temp[6]);
String year = String(dateStamp_display_temp[0]) + String(dateStamp_display_temp[1]) + String(dateStamp_display_temp[2]) + String(dateStamp_display_temp[3]);
dateStamp_display = day + "/" + month;
dateStamp_firebase = day + "-" + month + "-" + year;
String timeStamp_display_temp = formattedDate.substring(splitT + 1, formattedDate.length() - 1);
String hour = String(timeStamp_display_temp[0]) + String(timeStamp_display_temp[1]);
String minute = String(timeStamp_display_temp[3]) + String(timeStamp_display_temp[4]);
String second = String(timeStamp_display_temp[6]) + String(timeStamp_display_temp[7]);
int h = hour.toInt();
if (h < 12)
{
String hour = String(h);
timeStamp_display = hour + ":" + minute + "am";
timeStamp_firebase = hour + "-" + minute + + "-" + second + "am";
}
else
{
if (h == 12)
{
h = 12;
}
else
{
h = h - 12;
}
String hour = String(h);
timeStamp_display = hour + ":" + minute + "pm";
timeStamp_firebase = hour + "-" + minute + + "-" + second + "pm";
}
display.setCursor(20, 0);
display.setTextSize(1);
display.print(dateStamp_display);
display.print(" ");
display.println(timeStamp_display);
}
void LCDdisplay(String t, String h, String c, String n_wifi, String n_sensor)
{
String n;
// ------------------Temperature Screen------------------
rssi = WiFi.RSSI();
networkStrength(rssi);
if (rssi >= 0)
{
n_wifi = "Check WiFi";
if (n_wifi.length() != 0 && n_sensor.length() != 0)
{
String n1 = "Check WiFi";
String n2 = "and Sensor";
display.clearDisplay();
display.setTextSize(2);
display.setCursor(3, 20); display.println(n1);
display.setCursor(3, 37); display.println(n2);
display.display();
delay(2000);
display.clearDisplay();
}
else
{
n = n_wifi;
display.drawBitmap(5, 20, temperatureLogo, 40, 40, WHITE);
display.setTextSize(2);
display.setCursor(50, 30); display.println(t);
display.setTextSize(1);
display.setCursor(53, 50); display.println(n);
display.display();
delay(2000);
display.clearDisplay();
}
}
else if (rssi < 0)
{
networkStrength(rssi);
if (n_sensor.length() != 0)
{
n = n_sensor;
NTP();
display.drawBitmap(3, 20, temperatureLogo, 40, 40, WHITE);
display.setTextSize(2);
display.setCursor(47, 30); display.println(t);
display.setTextSize(1);
display.setCursor(53, 50); display.println(n);
display.display();
delay(2000);
display.clearDisplay();
}
else
{
NTP();
display.drawBitmap(5, 20, temperatureLogo, 40, 40, WHITE);
display.setTextSize(2);
display.setCursor(50, 30); display.println(t);
display.display();
delay(2000);
display.clearDisplay();
}
}
// ------------------Humidity Screen------------------
rssi = WiFi.RSSI();
networkStrength(rssi);
if (rssi >= 0)
{
n_wifi = "Check WiFi";
if (n_wifi.length() != 0 && n_sensor.length() != 0)
{
String n1 = "Check WiFi";
String n2 = "and Sensor";
display.clearDisplay();
display.setTextSize(2);
display.setCursor(3, 20); display.println(n1);
display.setCursor(3, 37); display.println(n2);
display.display();
delay(2000);
display.clearDisplay();
}
else
{
n = n_wifi;
display.drawBitmap(5, 20, humidityLogo, 40, 40, WHITE);
display.setTextSize(2);
display.setCursor(50, 30); display.println(h);
display.setTextSize(1);
display.setCursor(53, 50); display.println(n);
display.display();
delay(2000);
display.clearDisplay();
}
}
else if (rssi < 0)
{
if (n_sensor.length() != 0)
{
n = n_sensor;
NTP();
display.drawBitmap(3, 20, humidityLogo, 40, 40, WHITE);
display.setTextSize(2);
display.setCursor(47, 30); display.println(h);
display.setTextSize(1);
display.setCursor(53, 50); display.println(n);
display.display();
delay(2000);
display.clearDisplay();
}
else
{
NTP();
display.drawBitmap(5, 20, humidityLogo, 40, 40, WHITE);
display.setTextSize(2);
display.setCursor(50, 30); display.println(h);
display.display();
delay(2000);
display.clearDisplay();
}
}
// ------------------CO2 Screen------------------
rssi = WiFi.RSSI();
networkStrength(rssi);
if (rssi >= 0)
{
n_wifi = "Check WiFi";
if (n_wifi.length() != 0 && n_sensor.length() != 0)
{
String n1 = "Check WiFi";
String n2 = "and Sensor";
display.clearDisplay();
display.setTextSize(2);
display.setCursor(3, 20); display.println(n1);
display.setCursor(3, 37); display.println(n2);
display.display();
delay(2000);
display.clearDisplay();
}
else
{
n = n_wifi;
display.drawBitmap(3, 20, co2Logo, 40, 40, WHITE);
display.setTextSize(2);
display.setCursor(47, 30); display.println(c);
display.setTextSize(1);
display.setCursor(53, 50); display.println(n);
display.display();
delay(2000);
display.clearDisplay();
}
}
else if (rssi < 0)
{
if (n_sensor.length() != 0)
{
n = n_sensor;
NTP();
display.drawBitmap(3, 20, co2Logo, 40, 40, WHITE);
display.setTextSize(2);
display.setCursor(47, 30); display.println(c);
display.setTextSize(1);
display.setCursor(53, 50); display.println(n);
display.display();
delay(2000);
display.clearDisplay();
}
else
{
NTP();
display.drawBitmap(3, 20, co2Logo, 40, 40, WHITE);
display.setTextSize(2);
display.setCursor(47, 30); display.println(c);
display.display();
delay(2000);
display.clearDisplay();
}
}
}
Can you help me with this?