fadi ladhari / Mbed 2 deprecated Nucleo_L43_Bracelet

Dependencies:   ADXL345 DHT HMC5883L_12 SerialGPS mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "HMC5883L.h"
00003 #include "DHT.h"
00004 #include "ADXL345.h"
00005 #include "SerialGPS.h"
00006 
00007 //SerialGPS gps(D1, D0);
00008 DHT sensor(D6, DHT22);
00009 Serial pc(A7, NC); // tx, rx 
00010 Serial rfid(NC, D4); //tx, rx
00011 //DigitalIn btn(PC_13);
00012 
00013 InterruptIn button_RFID(PA_9);
00014 InterruptIn button_SOS(PB_0);
00015 
00016 DigitalOut led(LED2);
00017  
00018 void ReadRFID_CALLBACK();
00019 void SOS_CALLBACK() ;
00020 
00021  // Utility Boussole HMC5883L
00022 #ifndef M_PI
00023 #define M_PI 3.1415926535897932384626433832795
00024 #endif
00025 #define PI2         (2*M_PI)
00026 #define RAD_TO_DEG  (180.0/M_PI)
00027 #define DEG_TO_RAD  (M_PI/180.0)
00028 #define  DECLINATION_ANGLE -0.02123
00029 #define SDA      A4
00030 #define SCL      A5
00031  
00032 int    SOSEtat; 
00033 float  temp,Humidity;
00034 int RFID=0;
00035 
00036 
00037 
00038 int main()
00039 {   
00040 
00041     // variable DHT11 ///////////////////////////
00042     int err;
00043     
00044     // configuration du BTN RFID
00045     button_RFID.mode(PullUp);
00046     button_RFID.fall(&ReadRFID_CALLBACK);  // attach the address of the flip function to the rising edge
00047     led = 0;
00048     // configuration du BTN SOS
00049     button_SOS.mode(PullUp);
00050     button_SOS.fall(&SOS_CALLBACK);  // attach the address of the flip function to the rising edge
00051     led = 0;
00052 
00053     while(1) 
00054     { 
00055     RFID=0;
00056     SOSEtat=0;
00057 ////////////////////////////////////////////////////////////////////////////////
00058 ////////////////////////// aquisation de la boussole ///////////////////////////
00059 ////////////////////////////////////////////////////////////////////////////////
00060 
00061         
00062         
00063 ////////////////////////////////////////////////////////////////////////////////
00064 ////////////////////////// aquisation du capteur de température/////////////////
00065 ////////////////////////////////////////////////////////////////////////////////
00066         err = sensor.readData();
00067         if (err==0){
00068             temp=sensor.ReadTemperature(CELCIUS);
00069             Humidity=sensor.ReadHumidity();
00070             SOSEtat=0;
00071            // pc.printf("AT$SS=%x%x%x%x0000\r\n",(int)temp,(int)Humidity,SOSEtat,RFID);  
00072        }
00073         //pc.printf("*********************\r\n");         
00074         
00075 
00076         //pc.printf("AT$SS=%x%x0000\r\n",SOSEtat,RFID);  
00077 
00078         
00079 ////////////////////////////////////////////////////////////////////////////////
00080 //////////////////////////     Sigfox     ////////////:::::::::::::::///////////
00081 ////////////////////////////////////////////////////////////////////////////////
00082    // pc.printf("AT$SS=%x %x   \r\n",(int)sensor.ReadTemperature(CELCIUS),(int)sensor.ReadHumidity(),(int)RFID);
00083    // pc.printf("AT$SS= %x %x \r\n",(int)sensor.ReadTemperature(CELCIUS),(int)sensor.ReadHumidity());
00084 
00085     wait(3); 
00086     }  
00087 }
00088 
00089 ////////////////////////////////////////////////////////////////////////////////
00090 ////////////////////////// aquisation RFID /////////////////////////////////////
00091 ////////////////////////////////////////////////////////////////////////////////
00092 void ReadRFID_CALLBACK() {
00093     // configuration RFID 
00094     int i;
00095     int RFID_read[15];
00096     pc.printf("RFID_read1 : \r\n");     
00097     for(i=0;i<5;i++)
00098         RFID_read[i]=rfid.getc();
00099     for(i=0;i<5;i++)
00100         RFID=RFID+RFID_read[i];
00101     pc.printf("AT$SS=%x%x0000\r\n",SOSEtat,RFID);  
00102     wait(3);
00103 
00104 }
00105 
00106 ////////////////////////////////////////////////////////////////////////////////
00107 ////////////////////////// aquisation GPS_SOS //////////////////////////////////
00108 ////////////////////////////////////////////////////////////////////////////////
00109 void SOS_CALLBACK() {
00110             //pc.printf("AT$SS=SOS \r\n");    
00111             SOSEtat=1;
00112             pc.printf("AT$SS=%x%x0000\r\n",SOSEtat,RFID);  
00113 
00114 
00115 }