/***************************************************
** Altimètre BMP 180 **
** Commande de servo en dépassement de consigne **
** Consigne par potentiomètre **
** XIAO-ESP32-C3 broches utilisées : **
** 0 -> A0 -> Potar
** 4 -> D4 -> I2C SDA
** 5 -> D5 -> I2C SCL
** -> Servo IN
** -> Servo OUT
****************************************************/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_BMP085.h>
#define pinPotar A0
LiquidCrystal_I2C lcd(0x27,16,2);
Adafruit_BMP085 BMP;
float altiIni = 0;
void setup() {
pinMode(pinPotar, INPUT);
// Initialisation LCD
lcd.init();
lcd.backlight();
lcd.clear();
// Initialisation BMP180
BMP.begin();
lcd.print("Altimetre BMP180");
lcd.setCursor(0,1);
lcd.print("Initialisation...");
delay(500);
altiIni = BMP.readAltitude();
delay(500);
lcd.setCursor(0,1);
lcd.print("Termine. ");
Serial.begin(115200);
delay(2000);
lcd.clear();
}
void loop() {
// Lecture consigne
int consigne = analogRead(pinPotar);
consigne = 10 * map(consigne,0,4095,0,40);
float altitude = BMP.readAltitude();
lcd.setCursor(0,0);
lcd.print("Alti :");
lcd.print(altitude);
lcd.print("m");
lcd.setCursor(0,1);
lcd.print("Cons :");
lcd.print(consigne);
lcd.print("m ");
delay(200);
}
Loading
xiao-esp32-c3
xiao-esp32-c3
Loading
bmp180
bmp180