1 | /***************************************************************************
|
2 | This is a library for the BME680 gas, humidity, temperature & pressure sensor
|
3 |
|
4 | Designed specifically to work with the Adafruit BME680 Breakout
|
5 | ----> http://www.adafruit.com/products/3660
|
6 |
|
7 | These sensors use I2C or SPI to communicate, 2 or 4 pins are required
|
8 | to interface.
|
9 |
|
10 | Adafruit invests time and resources providing this open source code,
|
11 | please support Adafruit and open-source hardware by purchasing products
|
12 | from Adafruit!
|
13 |
|
14 | Written by Limor Fried & Kevin Townsend for Adafruit Industries.
|
15 | BSD license, all text above must be included in any redistribution
|
16 | ***************************************************************************/
|
17 | #include <odroid_go.h> //zusätzlich mw
|
18 | //#include <Wire.h>
|
19 | //#include <SPI.h>
|
20 | /*#include "sensors/Adafruit_Sensor.h"*/
|
21 | #include "Adafruit_BME680.h"
|
22 |
|
23 | //#define BME_SCK 13
|
24 | //#define BME_MISO 12
|
25 | //#define BME_MOSI 11
|
26 | //#define BME_CS 10
|
27 |
|
28 | #define SEALEVELPRESSURE_HPA (1013.25)
|
29 |
|
30 | Adafruit_BME680 bme; // I2C
|
31 | //Adafruit_BME680 bme(BME_CS); // hardware SPI
|
32 | //Adafruit_BME680 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK);
|
33 |
|
34 |
|
35 | void displayFehlertext1(){
|
36 | GO.lcd.setTextSize(2);
|
37 | GO.lcd.clear();
|
38 | GO.lcd.setCursor(0, 0);
|
39 | GO.lcd.setTextColor(BLUE);
|
40 | GO.lcd.println("*************************");
|
41 | GO.lcd.println("* BME680-Test *");
|
42 | GO.lcd.println("* Adafruit-Lib *");
|
43 | GO.lcd.println("*************************");
|
44 | GO.lcd.setTextColor(RED);
|
45 | GO.lcd.println("* BME680 nicht gefunden *");
|
46 | GO.lcd.setTextColor(BLUE);
|
47 | GO.lcd.println("*************************");
|
48 | }
|
49 |
|
50 | void displayFehlertext2(){
|
51 | GO.lcd.setTextSize(2);
|
52 | GO.lcd.clear();
|
53 | GO.lcd.setCursor(0, 0);
|
54 | GO.lcd.setTextColor(RED);
|
55 | GO.lcd.println("*************************");
|
56 | GO.lcd.println("* Werte nicht *");
|
57 | GO.lcd.println("* gelesen *");
|
58 | GO.lcd.println("*************************");
|
59 | }
|
60 |
|
61 | void displayStarttext(){
|
62 | GO.lcd.setTextSize(2);
|
63 | GO.lcd.clear();
|
64 | GO.lcd.setCursor(0, 0);
|
65 | GO.lcd.setTextColor(BLUE);
|
66 | GO.lcd.println("*************************");
|
67 | GO.lcd.println("* BME680-Test *");
|
68 | GO.lcd.println("* Adafruit-Lib *");
|
69 | GO.lcd.println("*************************");
|
70 | GO.lcd.println("* Temperatur: *");
|
71 | GO.lcd.println("* Luftdruck: *");
|
72 | GO.lcd.println("* Luftfeuchte: *");
|
73 | GO.lcd.println("* Gas: *");
|
74 | GO.lcd.println("* geo. Hoehe: *");
|
75 | GO.lcd.println("*************************");
|
76 | }
|
77 |
|
78 | void setup() {
|
79 |
|
80 | Serial.begin(9600);
|
81 | while (!Serial);
|
82 | Serial.println(F("BME680 test"));
|
83 |
|
84 | GO.begin();
|
85 |
|
86 | if (!bme.begin()) {
|
87 | Serial.println("BME680 Sensor nicht gefunden.");
|
88 | Serial.println("Verbindung prüfen.");
|
89 | Serial.println("Folgende Verdrahtung für ODROID-GO");
|
90 | //GO.begin();
|
91 | displayFehlertext1();
|
92 | while (1);
|
93 | }else{
|
94 | // Set up oversampling and filter initialization
|
95 | bme.setTemperatureOversampling(BME680_OS_8X);
|
96 | bme.setHumidityOversampling(BME680_OS_2X);
|
97 | bme.setPressureOversampling(BME680_OS_4X);
|
98 | bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
|
99 | bme.setGasHeater(320, 150); // 320*C for 150 ms
|
100 |
|
101 | //GO.begin();
|
102 | displayStarttext();
|
103 | }
|
104 | }
|
105 |
|
106 | void loop() {
|
107 |
|
108 | float mw_temp_bme680;
|
109 | float mw_feuchte_bme680;
|
110 | float mw_druck_bme680;
|
111 | float mw_hoehe_bme680;
|
112 | uint32_t mw_gas_bme680;
|
113 |
|
114 | if (! bme.performReading()) {
|
115 | Serial.println("Failed to perform reading :(");
|
116 | //displayFehlertext2();
|
117 | //delay(2000);
|
118 | return;
|
119 | }
|
120 |
|
121 | // zur Kontrolle über serielle Schnittstelle
|
122 |
|
123 | mw_temp_bme680 = bme.temperature;
|
124 | Serial.print("Temperature = ");
|
125 | Serial.print(mw_temp_bme680);
|
126 | Serial.println(" *C");
|
127 |
|
128 | mw_druck_bme680 = bme.pressure / 100.0;
|
129 | Serial.print("Pressure = ");
|
130 | Serial.print(mw_druck_bme680);
|
131 | Serial.println(" hPa");
|
132 |
|
133 | mw_feuchte_bme680 = bme.humidity;
|
134 | Serial.print("Humidity = ");
|
135 | Serial.print(mw_feuchte_bme680);
|
136 | Serial.println(" %");
|
137 |
|
138 | mw_gas_bme680 = bme.gas_resistance / 1000.0;
|
139 | Serial.print("Gas = ");
|
140 | Serial.print(mw_gas_bme680);
|
141 | Serial.println(" KOhms");
|
142 |
|
143 | mw_hoehe_bme680 = bme.readAltitude(SEALEVELPRESSURE_HPA);
|
144 | Serial.print("Approx. Altitude = ");
|
145 | Serial.print(mw_hoehe_bme680);
|
146 | Serial.println(" m");
|
147 |
|
148 | Serial.println();
|
149 |
|
150 | /*
|
151 | // keine Ausgabe mehr auf Display
|
152 | GO.lcd.print("Temp: ");
|
153 | GO.lcd.println(mw_temp_bme680);
|
154 | */
|
155 | delay(2000);
|
156 | }
|