Horloge Tubes Nixie de voyage

Programme ESP12

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET    -1
#define SCREEN_ADDRESS 0x3C
#define BMP280_ADDRESS 0x76

Adafruit_BMP280 bmp;
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

void setup() {
  Serial.begin(115200);
  Wire.begin();

  if (!bmp.begin(BMP280_ADDRESS)) {
    while (1);
  }

  if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    while (1);
  }

  display.display();
  delay(2000);
  display.clearDisplay();
}

void loop() {
  float temperature = bmp.readTemperature();
  float pressure = bmp.readPressure() / 100.0; // Conversion de la pression en hPa

  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.print(F("Température : "));
  display.print(temperature);
  display.println(" °C");

  display.print(F("Pression : "));
  display.print(pressure);
  display.println(" hPa");
  
  display.display();

  Serial.print(F("Température : "));
  Serial.print(temperature);
  Serial.println(" °C");

  Serial.print(F("Pression : "));
  Serial.print(pressure);
  Serial.println(" hPa");

  delay(1000);
}

gvivan

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *