-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBME280SensorModule.ino
More file actions
98 lines (84 loc) · 2.16 KB
/
BME280SensorModule.ino
File metadata and controls
98 lines (84 loc) · 2.16 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*Sensor BME280
En este programa configuraremos el sensor BME280
para leer los datos en el terminal serie.
Creado por Adafruit
Modificado por TecnoTalayotic
https://www.instagram.com/tecnotalayotic
https://www.thingiverse.com/TecnoTalayotic
https://github.com/TecnoTalayotic
Más información del proyecto en:
https://github.com/TecnoTalayotic/BME280-Sensor-Module
*/
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BME280.h>
//Usa el interfaz I2C
Adafruit_BME280 bme;
Adafruit_Sensor *bme_temp = bme.getTemperatureSensor();
Adafruit_Sensor *bme_pressure = bme.getPressureSensor();
Adafruit_Sensor *bme_humidity = bme.getHumiditySensor();
int conta = 0;
void setup() {
Serial.begin(9600);
inici();
if (!bme.begin()) {
Serial.println(F("Error sensor BME280"));
while (1) delay(10);
}
bme_temp->printSensorDetails();
bme_pressure->printSensorDetails();
bme_humidity->printSensorDetails();
}
void loop() {
conta++;
delay(1000);
if (conta = 10000){
temp();
conta=0;
}
}
//Imprimimos Iniciando y una línea de puntos
void inici(){
Serial.println("Iniciando");
delay(100);
Serial.print(" . ");
delay(100);
Serial.print(" . ");
delay(100);
Serial.print(" . ");
delay(100);
Serial.print(" . ");
delay(100);
Serial.print(" . ");
delay(100);
Serial.print(" . ");
delay(100);
Serial.print(" . ");
delay(100);
Serial.print(" . ");
delay(100);
Serial.print(" . ");
delay(100);
Serial.print(" . ");
delay(100);
Serial.print(" . ");
delay(100);
Serial.println(" . ");
delay(100);
}
void temp(){
sensors_event_t temp_event, pressure_event, humidity_event;
bme_temp->getEvent(&temp_event);
bme_pressure->getEvent(&pressure_event);
bme_humidity->getEvent(&humidity_event);
Serial.print(F("Temperatura = "));
Serial.print(temp_event.temperature);
Serial.println(" *C");
Serial.print(F("Humitat = "));
Serial.print(humidity_event.relative_humidity);
Serial.println(" %");
Serial.print(F("Pressió = "));
Serial.print(pressure_event.pressure);
Serial.println(" hPa");
Serial.println();
}