Skip to content

Commit

Permalink
Updated examples
Browse files Browse the repository at this point in the history
  • Loading branch information
soylentOrange committed Apr 30, 2023
1 parent 0184b6e commit 7e10979
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include "forcedBMX280.h" // https://github.com/soylentOrange/Forced-BMX280

/* Test-ino for BMX280 library
Uses the minmal version of the library (int32_t result of temperature)
Uses an Arduino Nano and a BME280/BMP280 sensor connected to Pin A4/A5
Uses the full version of the library (integer and float result of temperature, pressure and humidity)
Uses an Arduino Nano and a BME280 sensor connected to Pin A4/A5
Note to myself: yellow wire is SDA, connected to pin A4
green wire is SCL, connected to pin A5
Components are 5V tolerant (using an on-bord LDO)
Expand Down Expand Up @@ -88,7 +88,7 @@ void setup() {
digitalWrite(LED_BUILTIN, HIGH);
Serial.println(dashLine);
Serial.println("BMX280 ready");
Serial.print("\tChipID = 0x");
Serial.print("\tChipID: 0x");
Serial.println(climateSensor.getChipID(), HEX);
Serial.println(dashLine);
}
Expand All @@ -101,43 +101,43 @@ void loop() {

// // uncomment this block to print temperature - int32_t
// g_temperature = climateSensor.getTemperatureCelsius();
// Serial.print("Temperature = ");
// Serial.print("Temperature: ");
// Serial.print(g_temperature/100);
// Serial.print(".");
// Serial.print(g_temperature%100);
// Serial.println(" °C");

// uncomment this block to print temperature - float
g_temperature_float = climateSensor.getTemperatureCelsius_float(true);
Serial.print("Temperature = ");
Serial.print("Temperature: ");
Serial.print(g_temperature_float);
Serial.println(" °C");

// // uncomment this block to print pressure - uint32_t
// g_pressure = climateSensor.getPressure();
// Serial.print("Pressure = ");
// Serial.print("Pressure: ");
// Serial.print(g_pressure/100);
// Serial.print(".");
// Serial.print(g_pressure%100);
// Serial.println(" hPa");

// uncomment this block to print pressure - float
g_pressure_float = climateSensor.getPressure_float();
Serial.print("Pressure = ");
Serial.print("Pressure: ");
Serial.print(g_pressure_float);
Serial.println(" hPa");

// // uncomment this block to print humidity - uint32_t
// g_humidity = climateSensor.getRelativeHumidity();
// Serial.print("Humidity = ");
// Serial.print("Humidity: ");
// Serial.print(g_humidity/100);
// Serial.print(".");
// Serial.print(g_humidity%100);
// Serial.println(" %rh");

// uncomment this block to print humidity - float
g_humidity_float = climateSensor.getRelativeHumidity_float();
Serial.print("Humidity = ");
Serial.print("Humidity: ");
Serial.print(g_humidity_float);
Serial.println(" %rh");
}
Expand Down
71 changes: 71 additions & 0 deletions examples/BMX280_minimal_example/BMX280_minimal_example.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* Forced-BMX280 Library
soylentOrange - https://github.com/soylentOrange/Forced-BMX280
forked from:
Forced-BME280 Library
Jochem van Kranenburg - jochemvk.duckdns.org - 9 March 2020
*/

#include <Wire.h> // https://www.arduino.cc/reference/en/language/functions/communication/wire/
#include "forcedBMX280.h" // https://github.com/soylentOrange/Forced-BMX280

/* Test-ino for BMX280 library
Uses the minmal version of the library (int32_t result of temperature)
Uses an Arduino Nano and a BME280/BMP280 sensor connected to Pin A4/A5
Note to myself: yellow wire is SDA, connected to pin A4
green wire is SCL, connected to pin A5
Components are 5V tolerant (using an on-bord LDO)
- https://www.amazon.de/dp/B0B1HXTS29
- https://www.amazon.de/dp/B0B1DWSKF5
*/

// BMX280-sensor
ForcedBMX280 climateSensor = ForcedBMX280();
int32_t g_temperature; // current temperature - value of 1234 would be 12.34 °C

// UART control interface
#define SERIAL_BAUD 9600
static const char dashLine[] = "=======================================";

void setup() {
// set LED as output and turn it off
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);

// initialize serial pport
Serial.begin(SERIAL_BAUD);

// Wait for serial port to settle
while (!Serial) {
delay(10);
}

// start I2C and BME sensor
Wire.begin();
while (climateSensor.begin()) {
Serial.println("Waiting for sensor...");
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
delay(1000);
}

// Turn LED on if everything is fine
digitalWrite(LED_BUILTIN, HIGH);
Serial.println(dashLine);
Serial.println("BMX280 ready");
Serial.print("\tChipID: 0x");
Serial.println(climateSensor.getChipID(), HEX);
Serial.println(dashLine);
}

void loop() {
// get Temperature
delay(2000);
climateSensor.takeForcedMeasurement();
g_temperature = climateSensor.getTemperatureCelsius();
Serial.println(" ");
Serial.print("Temperature: ");
Serial.print(g_temperature/100);
Serial.print(".");
Serial.print(g_temperature%100);
Serial.println(" °C");
}
47 changes: 0 additions & 47 deletions examples/Test/Test.ino

This file was deleted.

0 comments on commit 7e10979

Please sign in to comment.