kh

Dependencies:   Adafruit_SGP30_mbed mbed CCS811 mbed-rtos ALPHASENSE Adafruit_ADS1015_ BME680

Committer:
etiene32
Date:
Wed Mar 06 14:03:41 2019 +0000
Revision:
0:43070b2dfc87
,hb

Who changed what in which revision?

UserRevisionLine numberNew contents of line
etiene32 0:43070b2dfc87 1 #include "mbed.h"
etiene32 0:43070b2dfc87 2 #include "CCS811.h"
etiene32 0:43070b2dfc87 3 #include "Alphasense.h"
etiene32 0:43070b2dfc87 4 #include "NovaSDS011.h"
etiene32 0:43070b2dfc87 5 #include "PMS7003.h"
etiene32 0:43070b2dfc87 6 #include "HPMA115S0.h"
etiene32 0:43070b2dfc87 7 #include "BME680.h"
etiene32 0:43070b2dfc87 8 #include "Adafruit_SGP30.h"
etiene32 0:43070b2dfc87 9 #include "Teseo-LIV3F.h"
etiene32 0:43070b2dfc87 10
etiene32 0:43070b2dfc87 11 CCS811 ccs811(D14, D15);
etiene32 0:43070b2dfc87 12 BME680 BME(D14,D15,0);
etiene32 0:43070b2dfc87 13 Adafruit_SGP30 SGP30(D14, D15);
etiene32 0:43070b2dfc87 14
etiene32 0:43070b2dfc87 15 Serial HPMA(A0,A1);
etiene32 0:43070b2dfc87 16 HPMA115S0 HoneyWell(&HPMA);
etiene32 0:43070b2dfc87 17
etiene32 0:43070b2dfc87 18 Serial novaSerial(A4,A5);
etiene32 0:43070b2dfc87 19 NovaSDS011 nova(&novaSerial);
etiene32 0:43070b2dfc87 20
etiene32 0:43070b2dfc87 21 Serial PMS(D3,D5);
etiene32 0:43070b2dfc87 22 PMS7003 TowerPlant(&PMS);
etiene32 0:43070b2dfc87 23
etiene32 0:43070b2dfc87 24 DigitalOut set(D5);
etiene32 0:43070b2dfc87 25
etiene32 0:43070b2dfc87 26
etiene32 0:43070b2dfc87 27 InterruptIn button(USER_BUTTON);
etiene32 0:43070b2dfc87 28
etiene32 0:43070b2dfc87 29 DigitalOut led(LED1);
etiene32 0:43070b2dfc87 30
etiene32 0:43070b2dfc87 31 int ordo[20]={151500,0,1,0,151600,1,0,1,151600,1,1,1,151600,1,0,0,151600,0,0,1};
etiene32 0:43070b2dfc87 32
etiene32 0:43070b2dfc87 33 int i=0;
etiene32 0:43070b2dfc87 34 int j=0;
etiene32 0:43070b2dfc87 35
etiene32 0:43070b2dfc87 36 double delay = 0.5; // 500 ms
etiene32 0:43070b2dfc87 37 uint16_t eco2, tvoc;
etiene32 0:43070b2dfc87 38
etiene32 0:43070b2dfc87 39 void pressed()
etiene32 0:43070b2dfc87 40 {
etiene32 0:43070b2dfc87 41 uint8_t trame[100];
etiene32 0:43070b2dfc87 42 uint8_t oct=0,oct2=0;
etiene32 0:43070b2dfc87 43 i++;
etiene32 0:43070b2dfc87 44 oct2 = ordo[i] << 2;
etiene32 0:43070b2dfc87 45 oct |= oct2;
etiene32 0:43070b2dfc87 46 oct2 = ordo[i+1] << 1;
etiene32 0:43070b2dfc87 47 oct |= oct2;
etiene32 0:43070b2dfc87 48 oct2 = ordo[i+2];
etiene32 0:43070b2dfc87 49 oct |= oct2;
etiene32 0:43070b2dfc87 50 trame[j]=oct;
etiene32 0:43070b2dfc87 51 j++;
etiene32 0:43070b2dfc87 52 printf("flag ok\r\n");
etiene32 0:43070b2dfc87 53 printf("\n!!! ALARM 1 Triggered !!!\r\n");
etiene32 0:43070b2dfc87 54 if(ordo[i]==1){
etiene32 0:43070b2dfc87 55 printf("Capteur 0 actif - Erreur \r\n");
etiene32 0:43070b2dfc87 56 trame[j]=1;
etiene32 0:43070b2dfc87 57 j++;
etiene32 0:43070b2dfc87 58 }
etiene32 0:43070b2dfc87 59 if(ordo[i]==1){
etiene32 0:43070b2dfc87 60 printf("Capteur 1 actif - Heure\r\n");
etiene32 0:43070b2dfc87 61 trame[j]=2;
etiene32 0:43070b2dfc87 62 j++;
etiene32 0:43070b2dfc87 63 }
etiene32 0:43070b2dfc87 64 i++;
etiene32 0:43070b2dfc87 65 if(ordo[i]==1){
etiene32 0:43070b2dfc87 66 printf("Capteur 2 actif - N/A \r\n");
etiene32 0:43070b2dfc87 67 trame[j]=12;
etiene32 0:43070b2dfc87 68 j++;
etiene32 0:43070b2dfc87 69 }
etiene32 0:43070b2dfc87 70 i++;
etiene32 0:43070b2dfc87 71 if(ordo[i]==1){
etiene32 0:43070b2dfc87 72 printf("Capteur 4 actif - N/A\r\n");
etiene32 0:43070b2dfc87 73 trame[j]=42;
etiene32 0:43070b2dfc87 74 j++;
etiene32 0:43070b2dfc87 75 }
etiene32 0:43070b2dfc87 76 i++;
etiene32 0:43070b2dfc87 77 if(ordo[i]==1){
etiene32 0:43070b2dfc87 78 printf("Capteur 5 actif - GNSS \r\n");
etiene32 0:43070b2dfc87 79 trame[j]=42;
etiene32 0:43070b2dfc87 80 j++;
etiene32 0:43070b2dfc87 81 }
etiene32 0:43070b2dfc87 82 i++;
etiene32 0:43070b2dfc87 83 if(ordo[i]==1){
etiene32 0:43070b2dfc87 84 printf("Capteur 6 actif - O3\r\n"); /* Alphasense */
etiene32 0:43070b2dfc87 85 trame[j]=42;
etiene32 0:43070b2dfc87 86 j++;
etiene32 0:43070b2dfc87 87 }
etiene32 0:43070b2dfc87 88 i++;
etiene32 0:43070b2dfc87 89 if(ordo[i]==1){
etiene32 0:43070b2dfc87 90 printf("Capteur 7 actif - NO2\r\n"); /* Alphasense */
etiene32 0:43070b2dfc87 91 trame[j]=42;
etiene32 0:43070b2dfc87 92 j++;
etiene32 0:43070b2dfc87 93 }
etiene32 0:43070b2dfc87 94 i++;
etiene32 0:43070b2dfc87 95 if(ordo[i]==1){
etiene32 0:43070b2dfc87 96 printf("Capteur 8 actif - CO2\r\n"); /* Rechercher */
etiene32 0:43070b2dfc87 97 trame[j]=42;
etiene32 0:43070b2dfc87 98 j++;
etiene32 0:43070b2dfc87 99 }
etiene32 0:43070b2dfc87 100 i++;
etiene32 0:43070b2dfc87 101 if(ordo[i]==1){
etiene32 0:43070b2dfc87 102 printf("Capteur 9 actif - eCO2 / VOC \r\n"); /* BME690, CCS811, SGP30 */
etiene32 0:43070b2dfc87 103 trame[j]=42;
etiene32 0:43070b2dfc87 104 j++;
etiene32 0:43070b2dfc87 105 }
etiene32 0:43070b2dfc87 106 i++;
etiene32 0:43070b2dfc87 107 if(ordo[i]==1){
etiene32 0:43070b2dfc87 108 printf("Capteur 10 actif - PM2.5 / PM10 \r\n"); /* plantower, omron, sds */
etiene32 0:43070b2dfc87 109 trame[j]=42;
etiene32 0:43070b2dfc87 110 j++;
etiene32 0:43070b2dfc87 111 }
etiene32 0:43070b2dfc87 112 i++;
etiene32 0:43070b2dfc87 113 if(ordo[i]==1){
etiene32 0:43070b2dfc87 114 printf("Capteur 11 actif - Pression \r\n");
etiene32 0:43070b2dfc87 115 trame[j]=42;
etiene32 0:43070b2dfc87 116 j++;
etiene32 0:43070b2dfc87 117 }
etiene32 0:43070b2dfc87 118 i++;
etiene32 0:43070b2dfc87 119 if(ordo[i]==1){
etiene32 0:43070b2dfc87 120 printf("Capteur 12 actif - Humidite\r\n");
etiene32 0:43070b2dfc87 121 trame[j]=42;
etiene32 0:43070b2dfc87 122 j++;
etiene32 0:43070b2dfc87 123 }
etiene32 0:43070b2dfc87 124 i++;
etiene32 0:43070b2dfc87 125 if(ordo[i]==1){
etiene32 0:43070b2dfc87 126 printf("Capteur 13 actif - Temperature\r\n"); /* LM35 */
etiene32 0:43070b2dfc87 127 trame[j]=42;
etiene32 0:43070b2dfc87 128 j++;
etiene32 0:43070b2dfc87 129 }
etiene32 0:43070b2dfc87 130 printf("Taille = %d La trame = \r\n",j);
etiene32 0:43070b2dfc87 131 for(uint8_t t=0;t<j;t++){
etiene32 0:43070b2dfc87 132 printf("%d \r\n",trame[t]);
etiene32 0:43070b2dfc87 133 }
etiene32 0:43070b2dfc87 134 j=0;
etiene32 0:43070b2dfc87 135 }
etiene32 0:43070b2dfc87 136
etiene32 0:43070b2dfc87 137 int main()
etiene32 0:43070b2dfc87 138 {
etiene32 0:43070b2dfc87 139 ccs811.init();
etiene32 0:43070b2dfc87 140 // Assign functions to button
etiene32 0:43070b2dfc87 141 button.fall(&pressed);
etiene32 0:43070b2dfc87 142
etiene32 0:43070b2dfc87 143 while (1) {
etiene32 0:43070b2dfc87 144 led = !led;
etiene32 0:43070b2dfc87 145 }
etiene32 0:43070b2dfc87 146 }