1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
| #include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include "Adafruit_GFX.h"
#include "MCUFRIEND_kbv.h"
#include <Fonts/FreeSansBold12pt7b.h>
#include <Fonts/FreeSerif9pt7b.h>
MCUFRIEND_kbv tft;
#define ROUGE 0xF800
#define NOIR 0x0000
#define BLANC 0xFFFF
#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10
#define SEALEVELPRESSURE_HPA (1013.25)
String Jour[]={"Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi","Dimanche"};
int heure_date[6] = {10,34,18,18,10,2022}; //seconde minute heure jour mois année
int mod[6] = {60,60,24,31,12,3000}; // limite d incrementation
Adafruit_BME280 bme; // I2C
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
unsigned long delayTime;
void setup() {
uint16_t ID = tft.readID();
tft.begin(ID);
tft.setFont(&FreeSansBold12pt7b);
tft.fillScreen(NOIR);
tft.setRotation(1);
tft.setTextSize(2);
bool status;
tft.drawRect(0, 0, 240, 120, BLANC);
tft.drawRect(1, 1, 238, 118, BLANC);
tft.drawRect(2, 2, 237, 116, BLANC);
tft.drawRect(240, 0, 240, 120, BLANC);
tft.drawRect(241, 1, 238, 118, BLANC);
tft.drawRect(242, 2, 236, 116, BLANC);
tft.drawRect(0, 120, 240, 120, BLANC);
tft.drawRect(1, 121, 238, 118, BLANC);
tft.drawRect(2, 122, 236, 116, BLANC);
tft.drawRect(240, 120, 240, 120, BLANC);
tft.drawRect(241, 121, 288, 118, BLANC);
tft.drawRect(242, 122, 266, 116, BLANC);
tft.drawRect(0, 240, 480, 80, BLANC);
tft.drawRect(1, 241, 478, 78, BLANC);
tft.drawRect(2, 242, 476, 76, BLANC);
// default settings
status = bme.begin();
if (!status) {
tft.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
}
void loop() {
printValues();
delay(delayTime);
}
void printValues() {
tft.setCursor(10, 40);
tft.write("Temp.");
tft.println();
tft.write(bme.readTemperature());
tft.setCursor(185, 110);
tft.write(" C");
tft.setCursor(245, 40);
tft.write("P atm");
tft.println();
tft.write(bme.readPressure() / 100.0F);
tft.setCursor(376, 110);
tft.println(" hPa");
tft.setCursor(245,160);
tft.write("Altitude") ;
tft.println();
tft.write(bme.readAltitude(SEALEVELPRESSURE_HPA));
tft.setCursor(420, 230);
tft.println(" m");
tft.setCursor(10, 160);
tft.write("Humidite");
tft.println();
tft.write(bme.readHumidity());
tft.setCursor(178, 230);
tft.println(" %");
tft.println();
} |
Partager