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
| #include <SPI.h>
#include <MD_MAX72xx.h>
#include <MD_Parola.h>
#include <Adafruit_BME280.h>
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CS_PIN 3
#define BUFFER_SIZE 60 //taille pour stocker le message à afficher
uint8_t dg[]={4,6,9,9,6}; //définition du caratère degré
float pression; //Stockage de la pression atmosphérique (Pa)
float temperature; //Stockage de la température (oC)
float humidite; //Stockage de l'humidité relative (%)
char message[BUFFER_SIZE] = {""}; //message à afficher
MD_Parola matrice = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
Adafruit_BME280 sens;
void lectureCapteur(){
pression = sens.readPressure()/100;
temperature = sens.readTemperature();
humidite =sens.readHumidity();
}
void setup() {
//Serial.begin(115200);
matrice.begin();
matrice.setIntensity(0);
matrice.setTextAlignment(PA_CENTER);
matrice.setPause(1000);
matrice.setSpeed(100);
matrice.displayClear();
matrice.addChar('$',dg);
sens.begin(0x76);
}
void loop() {
lectureCapteur();
char data[BUFFER_SIZE];
String silo = "T=" + (String)temperature + (String)'$' + "C " + "H=" + (String)humidite + "%" + " P=" + (String)pression + "hPa";
silo.toCharArray(data,BUFFER_SIZE);
strcpy(message,data);
if(matrice.displayAnimate()){
matrice.displayText(message,PA_CENTER,100,0,PA_SCROLL_LEFT,PA_SCROLL_LEFT);
matrice.displayReset();
}
} |
Partager