Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <UTFT.h> //TFT library
- #include <Wire.h> //I2C library
- #include <Adafruit_Sensor.h> //"Tweaked" sensor library
- #include <Adafruit_BME280.h> //"tweaked" bme sensor library
- extern uint8_t SmallFont[]; //set font size for the display
- #define SEALEVELPRESSURE_HPA (1013.25) //set local pressure
- UTFT myGLCD(ST7735S_4L_80160,11,13,10,8,9); //initialize the TFT
- Adafruit_BME280 bme; //initialize the bme sensor
- void setup()
- {
- myGLCD.InitLCD(); //begin the tft
- myGLCD.setFont(SmallFont); //set font size
- bme.begin(); //begin the bme
- }
- void loop()
- {
- String tmp = (bme.readTemperature()); //get the temp string from the sensor
- String prs = (bme.readPressure() / 100.0F); // get pressure string
- String hum = (bme.readHumidity()); // get hunidity string
- myGLCD.clrScr(); //clear the screen
- myGLCD.fillScr(0, 0, 0); //fill the screen black as my ex-wife's soul
- myGLCD.setColor(255, 0, 0); //set color red
- myGLCD.fillRoundRect(10, 17, 149, 72); //draw a box w/ round corners from 10,17 to 149,72
- myGLCD.setColor(255, 255, 255); //set text color WHITE
- myGLCD.setBackColor(255, 0, 0); // set BKG color RED
- myGLCD.print(tmp, CENTER, 20); //print the temperatue in white with red bkg, centered on line 20
- myGLCD.setColor(0, 255, 0);
- myGLCD.setBackColor(255, 0, 0);
- myGLCD.print(prs , CENTER, 45);
- myGLCD.setColor(0, 0, 255);
- myGLCD.setBackColor(255, 0, 0);
- myGLCD.print(hum, CENTER, 57);
- delay (5000); //wait 5 seconds and do it again
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement