Browse Source

Merge pull request #1647 from CraigMarkwardt/bmx280-second-sensor

sensors - allow a second BMX280 sensor
rules-rpn
Xose Pérez 5 years ago
committed by GitHub
parent
commit
b74e02ea92
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
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
#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
#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_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();
sensor->setAddress(BMX280_ADDRESS);
_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


Loading…
Cancel
Save