#include <Arduino.h>
#include <SensirionI2CSht4x.h>
#include <Wire.h>
SensirionI2CSht4x sht4x;
//LCD
#include"TFT_eSPI.h"
#include "Seeed_FS.h" //Including SD card library
#include"RawImage.h" //Including image processing libraryTFT_eSPI tft;
//
#include"TFT_eSPI.h"
#include"Free_Fonts.h" //include the header file
TFT_eSPI tft;
void setup() {
Serial.begin(115200);
// while (!Serial) {
// delay(100);
////
//
//// tft.fillScreen(TFT_BLACK); //Black background
// }
tft.begin();
tft.setRotation(3);
Wire.begin();
uint16_t error;
char errorMessage[256];
sht4x.begin(Wire);
uint32_t serialNumber;
error = sht4x.serialNumber(serialNumber);
if (error) {
Serial.print("Error trying to execute serialNumber(): ");
errorToString(error, errorMessage, 256);
Serial.println(errorMessage);
} else {
Serial.print("Serial Number: ");
Serial.println(serialNumber);
}
if (!SD.begin(SDCARD_SS_PIN, SDCARD_SPI)) {
while (1);
}
tft.begin();
tft.setRotation(3);
}
void loop() {
uint16_t error;
char errorMessage[256];
delay(1000);
float temperature;
float humidity;
error = sht4x.measureHighPrecision(temperature, humidity);
if (error) {
Serial.print("Error trying to execute measureHighPrecision(): ");
errorToString(error, errorMessage, 256);
Serial.println(errorMessage);
} else {
Serial.print("Temperature:");
Serial.print(temperature);
Serial.print("\t");
Serial.print("Humidity:");
Serial.println(humidity);
}
if(temperature < 30){
Serial.println("");
drawImage<uint16_t>("shidu1.0.bmp", 0, 0); //Display this 8-bit image in sd card from (0, 0)
delay(1000);
}else{
drawImage<uint16_t>("re1.0.bmp", 0, 0); //Display this 8-bit image in sd card from (0, 0)
delay(1000);
Serial.println("");
}
}
// drawImage<uint16_t>("shidu1.0.bmp", 0, 0); //Display this 8-bit image in sd card from (0, 0)
// delay(1000);
//
/*
tft.setFreeFont(&FreeSansBoldOblique9pt7b); //select Free, Sans, Bold, Oblique, 12pt.
tft.drawString("TEMP",0,210);//prints string at (70,80)
tft.setFreeFont(FF10); //select Free, Mono, Oblique, 12pt.
char sensorValue2[2];
sprintf(sensorValue2, "%s", humidity);
tft.drawString(sensorValue2,50,210);//prints string at (70,110)
// tft.setFreeFont(&FreeSansBoldOblique12pt7b); //select Free, Sans, Bold, Oblique, 12pt.
// tft.drawString(sensorValue2, 230, 200);
//*/
Comments