-
Notifications
You must be signed in to change notification settings - Fork 0
/
alternativesv1.ino
76 lines (61 loc) · 2.06 KB
/
alternativesv1.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
#define BMP_SCK (13)
#define BMP_MISO (12)
#define BMP_MOSI (11)
#define BMP_CS (10)
Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);
int PRESION_LOCAL=1018;
float DENSIDAD=1.225;
float TEMPERATURA=0;
float PRESION_ABSOLUTA=0;
float ALTITUD=0;
float PRESION_DINAMICA=0;
float PRESION_MEDIDA=0;
float VELOCIDAD=0;
void setup() {
Serial.begin(9600);
// Serial.println(F("BMP280 test"));
if (!bmp.begin()) {
// Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
while (1);
}
/* Default settings from datasheet. */
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */
Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */
Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */
Adafruit_BMP280::FILTER_X16, /* Filtering. */
Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
for(int i=0;i<4;i++){
PRESION_MEDIDA=bmp.readPressure();
}
}
void loop() {
TEMPERATURA=((bmp.readTemperature())*(1.8))+32; /*°F*/
PRESION_ABSOLUTA=bmp.readPressure(); /*Pa*/
ALTITUD=(bmp.readAltitude(PRESION_LOCAL))/0.3048;/*ft*/
PRESION_DINAMICA= PRESION_ABSOLUTA-PRESION_MEDIDA; /*Pa*/
VELOCIDAD=(pow((((PRESION_DINAMICA)/(0.5*DENSIDAD))),0.5)*1.944); /*knot*/
if (isnan(VELOCIDAD)== 1){
VELOCIDAD=0;
}
/* Pabs=Pdin+Patm*/
// Serial.print(F("TEMPERATURA = "));
// Serial.print(TEMPERATURA);
// Serial.println(" *F \n");
// Serial.print(F("PRESION ABSOLUTA = "));
// Serial.print(PRESION_ABSOLUTA);
// Serial.println(" *PA \n");
// Serial.print(F("ALTITUD = "));
Serial.print((float)ALTITUD);
// Serial.println(" *FT \n");
Serial.print(',');
// Serial.print(F("PRESION DINAMICA = "));
// Serial.print(PRESION_DINAMICA);
// Serial.println(" *PA \n");
// Serial.print(F("VELOCIDAD = "));
Serial.println((float)VELOCIDAD);
// Serial.println(" *KNT \n");
delay(500);
}