Browse Source

test/bmx280: rename bme280 test

master
Alexandre Abadie 5 years ago
parent
commit
82e68b008c
  1. 2
      tests/driver_bmx280/Makefile
  2. 20
      tests/driver_bmx280/README.md
  3. 31
      tests/driver_bmx280/main.c

2
tests/driver_bme280/Makefile → tests/driver_bmx280/Makefile

@ -1,4 +1,4 @@
APPLICATION = driver_bme280
APPLICATION = driver_bmx280
include ../Makefile.tests_common
USEMODULE += bme280

20
tests/driver_bme280/Readme.md → tests/driver_bmx280/README.md

@ -1,12 +1,12 @@
## About
This is a test application for the BME280 Pressure, Temperature and
Humidity sensor.
This is a test application for the BME280 and BMP280 sensors. Both can measure
pressure and temperature. The BME280 can also measure relative humidity.
## Usage
The application will initialize the BME280 device and display its
The application will initialize the BME280/BMP280 device and display its
calibration coefficients. More information can be found on the
[Bosch website][1]
And in this [BST-BME280_DS001-11 datasheet] [2]
[Bosch website][1], in the [BST-BME280_DS001-11 datasheet] [2] and in the
[BST-BMP280-DS001-12 datasheet] [3].
Notice that it is necessary to first read the temperature even if only one
of the other values (humidity or pressure) is needed. This is described in
@ -15,7 +15,7 @@ the above mentioned datasheet.
After initialization, every 2 seconds, the application:
* reads and displays the temperature (d°C);
* reads and displays the pressure (Pa);
* reads and displays the humidity (%rH);
* reads and displays the humidity (%rH) (only with bme280);
## Overruling default parameters
@ -25,6 +25,14 @@ can build the test as follows:
export CFLAGS=-DBME280_PARAM_I2C_ADDR=0x76
make -C tests/driver_bme280 BOARD=sodaq-autonomo
By default, the test application is built to use the bme280 module, to build it for
the bmp280, in the Makefile change `USEMODULE += bme280` with:
USEMODULE += bmp280
[1]: http://www.bosch-sensortec.com/en/bst/products/all_products/bme280
[2]: https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME280_DS001-11.pdf
[3]: https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMP280-DS001-12.pdf

31
tests/driver_bme280/main.c → tests/driver_bmx280/main.c

@ -22,28 +22,28 @@
#include <stdio.h>
#include <inttypes.h>
#include "bme280_params.h"
#include "bme280.h"
#include "bmx280_params.h"
#include "bmx280.h"
#include "xtimer.h"
#define MAINLOOP_DELAY (2 * 1000 * 1000u) /* 2 seconds delay between printf's */
int main(void)
{
bme280_t dev;
bmx280_t dev;
int result;
puts("BME280 test application\n");
puts("BMX280 test application\n");
printf("+------------Initializing------------+\n");
result = bme280_init(&dev, &bme280_params[0]);
result = bmx280_init(&dev, &bmx280_params[0]);
if (result == -1) {
puts("[Error] The given i2c is not enabled");
return 1;
}
if (result == -2) {
printf("[Error] The sensor did not answer correctly at address 0x%02X\n", bme280_params[0].i2c_addr);
printf("[Error] The sensor did not answer correctly at address 0x%02X\n", bmx280_params[0].i2c_addr);
return 1;
}
@ -64,35 +64,48 @@ int main(void)
printf("dig_P8: %i\n", dev.calibration.dig_P8);
printf("dig_P9: %i\n", dev.calibration.dig_P9);
#if defined(MODULE_BME280)
printf("dig_H1: %u\n", dev.calibration.dig_H1);
printf("dig_H2: %i\n", dev.calibration.dig_H2);
printf("dig_H3: %i\n", dev.calibration.dig_H3);
printf("dig_H4: %i\n", dev.calibration.dig_H4);
printf("dig_H5: %i\n", dev.calibration.dig_H5);
printf("dig_H6: %i\n", dev.calibration.dig_H6);
#endif
printf("\n+--------Starting Measurements--------+\n");
while (1) {
int16_t temperature;
uint32_t pressure;
#if defined(MODULE_BME280)
uint16_t humidity;
#endif
/* Get temperature in centi degrees Celsius */
temperature = bme280_read_temperature(&dev);
temperature = bmx280_read_temperature(&dev);
/* Get pressure in Pa */
pressure = bme280_read_pressure(&dev);
pressure = bmx280_read_pressure(&dev);
#if defined(MODULE_BME280)
/* Get pressure in %rH */
humidity = bme280_read_humidity(&dev);
#endif
printf("Temperature [°C]: %d.%d\n"
"Pressure [Pa]: %lu\n"
#if defined(MODULE_BME280)
"Humidity [%%rH]: %u.%02u\n"
#endif
"\n+-------------------------------------+\n",
temperature / 100, (temperature % 100) / 10,
#if defined(MODULE_BME280)
(unsigned long)pressure,
(unsigned int)(humidity / 100), (unsigned int)(humidity % 100));
(unsigned int)(humidity / 100), (unsigned int)(humidity % 100)
#else
(unsigned long)pressure
#endif
);
xtimer_usleep(MAINLOOP_DELAY);
}
Loading…
Cancel
Save