From 79b24c2ba61d1b5f7e57643711b211f3425bec2c Mon Sep 17 00:00:00 2001 From: Martin Chlebovec Date: Wed, 13 Mar 2019 20:25:58 +0000 Subject: [PATCH] =?UTF-8?q?P=C5=99idat=20'examples/bme280=5Ftester/bme280?= =?UTF-8?q?=5Ftester.ino'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/bme280_tester/bme280_tester.ino | 49 ++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 examples/bme280_tester/bme280_tester.ino diff --git a/examples/bme280_tester/bme280_tester.ino b/examples/bme280_tester/bme280_tester.ino new file mode 100644 index 0000000..e297dae --- /dev/null +++ b/examples/bme280_tester/bme280_tester.ino @@ -0,0 +1,49 @@ +#include +#include +#define BME280_ADRESA (0x77) +Adafruit_BME280 bme; +void setup() { + Serial.begin(115200); + if (!bme.begin(BME280_ADRESA)) { + Serial.println("BME280 senzor nenalezen, zkontrolujte zapojeni!"); + while (1); + } +} + +void loop() { + float teplota = bme.readTemperature(); + float tlak = bme.readPressure()/100; + float nadmorska_vyska = bme.readAltitude(1013.25); + float tlak_hladina_mora = tlak / pow(1 - ((0.0065 *nadmorska_vyska) / (teplota + (0.0065 *nadmorska_vyska) + 273.15)), 5.257); + float tlak_hladina_mora2 = tlak / pow(1.0 - nadmorska_vyska / 44330.0, 5.255); + float tlak_hladina_mora3 = tlak / pow(1.0 - 0.0065 *nadmorska_vyska / (teplota + 273.15), 5.255); + Serial.print("Teplota = "); + Serial.print(teplota); + Serial.println(" *C"); + + Serial.print("Absolutny tlak = "); + Serial.print(tlak); + Serial.println(" hPa"); + + //RELATIVNY TLAK --> prepocitany na hladinu mora bosch vzorcom + Serial.print("Relativny tlak (origo Bosch vzorec) = "); + Serial.print(tlak_hladina_mora); + Serial.println(" hPa"); + + Serial.print("Relativny tlak (upraveny Bosch vzorec 2 - najviac odpoveda skutocnosti z merani) = "); + Serial.print(tlak_hladina_mora2); + Serial.println(" hPa"); + + Serial.print("Relativny tlak (upraveny Bosch vzorec 3) = "); + Serial.print(tlak_hladina_mora3); + Serial.println(" hPa"); + + Serial.print("Nadmorska vyska = "); + Serial.print(nadmorska_vyska); /* Adjusted to local forecast! */ + Serial.println(" m.n.m"); + + Serial.println(); + delay(10000); +} + + \ No newline at end of file