Browse Source

Up to two BMX280 sensors are allowed on a single I2C bus, with addresses 0x76 and 0x77. Currently espurna only supports one of them.

This change adds a second sensor object to deal with two sensors, if BMX280_NUMBER == 2
rules-rpn
Craig Markwardt 5 years ago
parent
commit
b5748c9c26
2 changed files with 16 additions and 2 deletions
  1. +7
    -2
      code/espurna/config/sensors.h
  2. +9
    -0
      code/espurna/sensor.ino

+ 7
- 2
code/espurna/config/sensors.h View File

@ -158,9 +158,14 @@
#define BMX280_SUPPORT 0 #define BMX280_SUPPORT 0
#endif #endif
#ifndef BMX280_ADDRESS
#define BMX280_ADDRESS 0x00 // 0x00 means auto
#ifndef BMX280_NUMBER
#define BMX280_NUMBER 2 // Number of sensors present. Either 1 or 2 allowed
#endif #endif
#ifndef BMX280_ADDRESS
#define BMX280_ADDRESS 0x00 // 0x00 means auto (0x76 or 0x77 allowed) for sensor #0
#endif // If (BMX280_NUMBER == 2) and
// (BMX280_ADDRESS == 0x00) then sensor #1 is auto-discovered
// (BMX280_ADDRESS != 0x00) then sensor #1 is the unnamed address
#define BMX280_MODE 1 // 0 for sleep mode, 1 or 2 for forced mode, 3 for normal mode #define BMX280_MODE 1 // 0 for sleep mode, 1 or 2 for forced mode, 3 for normal mode
#define BMX280_STANDBY 0 // 0 for 0.5ms, 1 for 62.5ms, 2 for 125ms #define BMX280_STANDBY 0 // 0 for 0.5ms, 1 for 62.5ms, 2 for 125ms


+ 9
- 0
code/espurna/sensor.ino View File

@ -484,6 +484,15 @@ void _sensorLoad() {
BMX280Sensor * sensor = new BMX280Sensor(); BMX280Sensor * sensor = new BMX280Sensor();
sensor->setAddress(BMX280_ADDRESS); sensor->setAddress(BMX280_ADDRESS);
_sensors.push_back(sensor); _sensors.push_back(sensor);
#if (BMX280_NUMBER == 2)
// Up to two BME sensors allowed on one I2C bus
BMX280Sensor * sensor2 = new BMX280Sensor();
// For second sensor, if BMX280_ADDRESS is 0x00 then auto-discover
// otherwise choose the other unnamed sensor address
sensor->setAddress( (BMX280_ADDRESS == 0x00) ? 0x00 : (0x76 + 0x77 - BMX280_ADDRESS));
_sensors.push_back(sensor2);
#endif
} }
#endif #endif


Loading…
Cancel
Save