From 3c87a68e8db504f9953ee02b36e7702b48bb2c0d Mon Sep 17 00:00:00 2001 From: maxsrobotics Date: Sat, 20 Jan 2024 12:45:21 -0500 Subject: [PATCH 1/5] Examples Added basic examples for new users. --- examples/BME_I2CTest | 61 +++++++++++++++++++++++++++++++++++++ examples/BME_Sleep | 71 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 examples/BME_I2CTest create mode 100644 examples/BME_Sleep diff --git a/examples/BME_I2CTest b/examples/BME_I2CTest new file mode 100644 index 0000000..45f1f60 --- /dev/null +++ b/examples/BME_I2CTest @@ -0,0 +1,61 @@ +/* + Tiny BME280 Library + https://github.com/technoblogy/tiny-bme280 + Example to print out environmental data (temperature, pressure, humidity) once per second. + + Created by Max Kendall + Modified 20 January 2024 + Library by Technoblogy + + Connections: + BME --- MCU + VCC to 3v3 + GND to GND + SDA to A4 + SCL to A5 + + Set your Serial monitor to 9600 baud and click the magnifiying glass icon on the top-right. +*/ + +#include + +void setup() { + // Runs once at start or board reset + + // Uncomment to change address. Default is 0x77 + //BME280setI2Caddress(address) + + // Begin the I2C connection with BME280 + BME280setup(); + + // Begin Serial monitor output for debugging + Serial.begin(9600); + + Serial.println("BME280 Interface Example."); +} + +void loop() { + // Runs forever after setup + + // Gives the temperature as a signed 32-bit integer in °C with a resolution of 0.01°C. So an output value of “5123” equals 51.23°C. + float temp = BME280temperature() / 100; + + // Pives the pressure in Pa as an unsigned 32-bit integer, so an output value of “96386” equals 96386 Pa, or 963.86 hPa. + float press = BME280pressure() / 100; + + // Gives the humidity in %RH with a resolution of 0.01% RH, so an output value of “4653” represents 46.53 %RH. + float humid = BME280humidity() / 100; + + + // Print the data to Serial output! + Serial.print("Temperature: "); + Serial.print(temp); + + Serial.print("Pressure: "); + Serial.println(press); + + Serial.print("Humidity: "); + Serial.print(humid); + + delay(1000); +} diff --git a/examples/BME_Sleep b/examples/BME_Sleep new file mode 100644 index 0000000..843c6d2 --- /dev/null +++ b/examples/BME_Sleep @@ -0,0 +1,71 @@ +/* + Tiny BME280 Library + https://github.com/technoblogy/tiny-bme280 + Example to print out environmental data (temperature, pressure, humidity) once every two seconds. + Sleeps in-between reading for lower power consumption. + + Created by Max Kendall + Modified 20 January 2024 + Library by Technoblogy + + Connections: + BME --- MCU + VCC to 3v3 + GND to GND + SDA to A4 + SCL to A5 + + Set your Serial monitor to 9600 baud and click the magnifiying glass icon on the top-right. +*/ + +#include + +void setup() { + // Runs once at start or board reset + + // Uncomment to change address. Default is 0x77 + //BME280setI2Caddress(address) + + // Begin the I2C connection with BME280 + BME280setup(); + + // Begin Serial monitor output for debugging + Serial.begin(9600); + + Serial.println("BME280 Interface Example."); +} + +void loop() { + // Runs forever after setup + + // Wake up BME if asleep + BME280setup(); + + // Give time to wake up + delay(15); + + // Gives the temperature as a signed 32-bit integer in °C with a resolution of 0.01°C. So an output value of “5123” equals 51.23°C. + float temp = BME280temperature() / 100; + + // Pives the pressure in Pa as an unsigned 32-bit integer, so an output value of “96386” equals 96386 Pa, or 963.86 hPa. + float press = BME280pressure() / 100; + + // Gives the humidity in %RH with a resolution of 0.01% RH, so an output value of “4653” represents 46.53 %RH. + float humid = BME280humidity() / 100; + + + // Print the data to Serial output! + Serial.print("Temperature: "); + Serial.print(temp); + + Serial.print("Pressure: "); + Serial.println(press); + + Serial.print("Humidity: "); + Serial.print(humid); + + // Go to sleep + BME280sleep(); + + delay(2000); +} From 53209ed201ec3faa59a6e41e7e4466ea025fb7e5 Mon Sep 17 00:00:00 2001 From: maxsrobotics Date: Sat, 20 Jan 2024 12:47:59 -0500 Subject: [PATCH 2/5] Ex asd --- examples/{BME_I2CTest => BME_I2CTest.ino} | 0 examples/{BME_Sleep => BME_Sleep.ino} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename examples/{BME_I2CTest => BME_I2CTest.ino} (100%) rename examples/{BME_Sleep => BME_Sleep.ino} (100%) diff --git a/examples/BME_I2CTest b/examples/BME_I2CTest.ino similarity index 100% rename from examples/BME_I2CTest rename to examples/BME_I2CTest.ino diff --git a/examples/BME_Sleep b/examples/BME_Sleep.ino similarity index 100% rename from examples/BME_Sleep rename to examples/BME_Sleep.ino From 245e8c21fe01da37f55342b7232f40260273aee0 Mon Sep 17 00:00:00 2001 From: maxsrobotics Date: Sat, 20 Jan 2024 12:53:45 -0500 Subject: [PATCH 3/5] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 1c81941..629fff8 100644 --- a/README.md +++ b/README.md @@ -42,3 +42,8 @@ To add altitude use this routine: } where **referencePressure** is the pressure in Pa at zero altitude; for example, 101325.0. + +#### Examples + +BME_I2CTest.ino - Basic usage example; Sends data through Serial monitor +BME_Sleep.ino - Sleeps in-between readings \ No newline at end of file From 321e16ab59b8de758bc17f15ac601ba28568ed2f Mon Sep 17 00:00:00 2001 From: Max K <66796793+maxsrobotics@users.noreply.github.com> Date: Fri, 31 May 2024 06:18:53 -0400 Subject: [PATCH 4/5] Rename examples/BME_I2CTest.ino to examples/BME_I2CTest/BME_I2CTest.ino --- examples/{ => BME_I2CTest}/BME_I2CTest.ino | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/{ => BME_I2CTest}/BME_I2CTest.ino (100%) diff --git a/examples/BME_I2CTest.ino b/examples/BME_I2CTest/BME_I2CTest.ino similarity index 100% rename from examples/BME_I2CTest.ino rename to examples/BME_I2CTest/BME_I2CTest.ino From cbfe568f3d89f4496e19d8b5ef46a8f22dbd3418 Mon Sep 17 00:00:00 2001 From: Max K <66796793+maxsrobotics@users.noreply.github.com> Date: Fri, 31 May 2024 06:19:10 -0400 Subject: [PATCH 5/5] Rename examples/BME_Sleep.ino to examples/BME_Sleep/BME_Sleep.ino --- examples/{ => BME_Sleep}/BME_Sleep.ino | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/{ => BME_Sleep}/BME_Sleep.ino (100%) diff --git a/examples/BME_Sleep.ino b/examples/BME_Sleep/BME_Sleep.ino similarity index 100% rename from examples/BME_Sleep.ino rename to examples/BME_Sleep/BME_Sleep.ino