Lourdès Abou-tayeh / Mbed 2 deprecated Capteur1

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
louatayehh
Date:
Mon Sep 06 11:30:37 2021 +0000
Parent:
0:c23b55e3ca7d
Commit message:
Capteur 1 : BMP280

Changed in this revision

BMP280/BMP280.cpp Show annotated file Show diff for this revision Revisions of this file
BMP280/BMP280.h Show annotated file Show diff for this revision Revisions of this file
BMP280/main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/BMP280/BMP280.cpp	Mon Sep 06 09:15:22 2021 +0000
+++ b/BMP280/BMP280.cpp	Mon Sep 06 11:30:37 2021 +0000
@@ -1,4 +1,4 @@
-// capteur pression
+//*****************Capteur BMP280 - pression atmosphérique ***************************//
 
 #include "mbed.h"
 #include "BMP280.h"
@@ -8,7 +8,7 @@
     :
     i2c_p(new I2C(sda, scl)),
     i2c(*i2c_p),
-    address(slave_adr<<1),
+    address(slave_adr<<1), // décalage adresse I2C 
     t_fine(0)
 {
     initialize();
@@ -75,7 +75,7 @@
     dig_P9 = (cmd[17] << 8) | cmd[16];
 
     DEBUG_PRINT("dig_P = 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", dig_P1, dig_P2, dig_P3, dig_P4, dig_P5, dig_P6, dig_P7, dig_P8, dig_P9);
-        //
+     /*   
         cmd[0] = 0xA1; // read dig_H regs
       i2c.write(address, cmd, 1);
       i2c.read(address, cmd, 1);
@@ -91,7 +91,7 @@
       dig_H6 = cmd[7];
 
       DEBUG_PRINT("dig_H = 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", dig_H1, dig_H2, dig_H3, dig_H4, dig_H5, dig_H6);
-    //
+    */
 }
 
 float BMP280::getTemperature()
--- a/BMP280/BMP280.h	Mon Sep 06 09:15:22 2021 +0000
+++ b/BMP280/BMP280.h	Mon Sep 06 11:30:37 2021 +0000
@@ -1,9 +1,11 @@
+//*****************Capteur BMP280 - pression atmosphérique ***************************//
+
 #ifndef MBED_BMP280_H
 #define MBED_BMP280_H
  
 #include "mbed.h"
   
-#define DEFAULT_SLAVE_ADDRESS (0x77) // adresse I2C
+#define DEFAULT_SLAVE_ADDRESS (0x77) // adresse I2C BMP280
  
 #ifdef _DEBUG
 extern Serial pc;
--- a/BMP280/main.cpp	Mon Sep 06 09:15:22 2021 +0000
+++ b/BMP280/main.cpp	Mon Sep 06 11:30:37 2021 +0000
@@ -8,7 +8,7 @@
 Serial bluetooth(p9, p10);      //tx, rx
 CAN can(p30,p29);               //CAN
 I2C i2c(p9,p10);                //SDA, SCL
-BMP280 bmp(i2c);                //Default address = 0x76
+BMP280 bmp(i2c);                //address par défaut= 0x77
 
 
 int main()
@@ -25,21 +25,17 @@
 
     //bmp.initialize();
 
-    //declaration des variables d'affichage
+    //déclaration des variables d'affichage
     float BMPTemp = 0;
     float BMPPressure = 0;
 
     //affichage de la variable de pression
     while(1) {
-        //BMPTemp = (bmp.getTemperature() - 32) / 1.8f;
         BMPPressure = bmp.getPressure();
-        //bluetooth.printf("Temp: %f, Pressure: %f\r\n",BMPTemp, BMPPressure);
-        
         bluetooth.printf("Pressure: %f\r\n",BMPPressure);
-        
 
         can.write(CANMessage(BMP_TMP_ID, (char*)&BMPTemp, sizeof(BMPTemp)/sizeof(char)));
-        wait(0.1); //Need waits for some reason, without them the data doesnt always arrive in a neat order
+        wait(0.1); //Besoin de temps pour que la data arrive de façon nette
         can.write(CANMessage(BMP_PRES_ID, (char*)&BMPPressure, sizeof(BMPPressure)/sizeof(char)));
         wait(0.1);
     }