logo elektroda
logo elektroda
X
logo elektroda

Integrating BME280 Sensor with OpenBK on WB2S Modules for Home Automation

bilbs84 7452 75
Best answers

Can I use a BME280 sensor with OpenBK on a WB2S module over software I2C, and how do I configure the pins, address, and Home Assistant publishing?

Yes — OpenBK can drive a BME280 on a WB2S using the BMP280/BMPI2C software-I2C driver, and the later BMPI2C version adds temperature, pressure, and humidity support [#20862222][#21123022] Use the `startDriver` command with your GPIOs and channel numbers; examples from the thread were `startDriver BMP280 [CLK] [DATA] [TempChan] [PressureChan]` and later `startDriver BMPI2C [CLK] [DATA] [Temp] [Pressure] [Humidity] [Addr]` [#20862067][#21123022] A working BME280 setup on a WB2S used `P7` as SDA and `P8` as SCL, with the sensor address set to `0x76` [#21112840] For Home Assistant, you can use channel types like `Temp_div100` and `Pressure_div100`, or publish manually with `publishFloat`; MQTT still carries the raw integer value unless you apply the divider/publish logic yourself [#20862313][#21013338] One important caveat is that the BME280 temperature reading is the chip’s internal temperature, so it can read a few degrees high and may need an offset calibration if you want it to represent room temperature [#20862559][#20862569]
Generated by the language model.
ADVERTISEMENT
  • #61 21112840
    divadiow
    Level 38  
    Posts: 5062
    Help: 438
    Rate: 893
    BME280 working with build 1231_merge_5205ac2480d5
    Screenshot of OpenBK_BK7231N_CB3S_DevMCU interface displaying BME280 sensor readings.

    Address 0x76 (dec 118)

    for me:
    Code: Text
    Log in, to see the code


    P7 - SDA
    P8 - SCL

    Close-up of a BME280 module connected to a microcontroller with colored wires.
  • ADVERTISEMENT
  • #62 21122990
    olekwal
    Level 6  
    Posts: 12
    How often is the 'value' updated via MQTT? Still every second, or can this already be set?
  • #63 21123022
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14616
    Help: 655
    Rate: 12633
    New controller:
    
    // startDriver BMPI2C 8 14 1 2 3 0
    // startDriver BMPI2C [CLK] [DATA] [ChannelForTemp] [ChannelForPressure] [ChannelForHumidity] [Addr]
    // Adr8bit 0 for 0x77, 1 for 0x76
    
    .
    Has the command :
    
    BMPI2C_Cycle 60
    
    .
    but is not included in the public build: System online builds OpenBeken - firmware compilation for all platforms on Github .
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #65 21275971
    DeDaMrAz
    Level 22  
    Posts: 603
    Help: 34
    Rate: 129
    After enabling BMPI2C driver I managed to get both BME680 and BME280 running on the same board, will let run for some time for testing purposes.

    This is the autoexec script with some explanations

    // startDriver BMPI2C [CLK] [DATA] [ChannelForTemp] [ChannelForPressure] [ChannelForHumidity] [Addr]
    //SDO to GND for Adr8bit 236 for 0x76 or set SD to VCC for Adr8bit 238 for 0x77
    //set CSB pin to GND for SPI mode and to VCC for I2C mode
    
    // startDriver BMP280 8 14 1 2 3 236
    // startDriver BMP280 [CLK] [DATA] [ChannelForTemp] [ChannelForPressure] [ChannelForHumidity] [Adr8bit]
    // Adr8bit 236 for 0x76, 238 for 0x77
    
    startDriver BMPI2C 26 24 4 5 6 238
    //BMP680_Adr 0x77
    
    startDriver BMP280 8 7 1 2 3 236
    //BMP280_Adr 0x76


    Pictures or it didn't happen :)

    Screen showing test results for BME280 and BME680 sensors.

    BME680 and BME280 modules connected to a prototype board.
  • #66 21276056
    divadiow
    Level 38  
    Posts: 5062
    Help: 438
    Rate: 893
    that's cool. so that's your own build with the old driver added?
  • ADVERTISEMENT
  • #67 21276274
    DeDaMrAz
    Level 22  
    Posts: 603
    Help: 34
    Rate: 129
    divadiow wrote:
    that's cool. so that's your own build with the old driver added?


    Yes, from my playground/fork :)
  • ADVERTISEMENT
  • #68 21370419
    olekwal
    Level 6  
    Posts: 12
    Welcome,

    I have a question for the updated BMPI2C driver - I would like to use it on my bl602 (magic home). I made a project fork and added the driver (in obk_config.h):
    #define ENABLE_DRIVER_BMPI2C 1  
     #define ENABLE_I2C	1.  

    is this correct, or should I also add the "old" #define ENABLE_DRIVER_BMP280 1?

    otherwise i can deactivate
    #define ENABLE_DRIVER_BL0937   0;
     #define ENABLE_DRIVER_BL0942    0,
    #define ENABLE_DRIVER_CSE7766   0,
    #define ENABLE_DRIVER_WEMO	0,
    #define ENABLE_DRIVER_DHT		0
    #define ENABLE_DRIVER_CHT83XX 0
    #define ENABLE_DRIVER_DS1820		0
    
    to save space?

    somehow the image is not building for me: [/home/runner/work/OpenBK7231T_App/OpenBK7231T_App/sdk/OpenBL602/customer_app/bl602_sharedApp/../../make_scripts_riscv/project.mk:537: component-shared-build] Error 2

    Added after 38 [minutes]: .

    Update:
    I have started again.
    The standard build works, but already adding the i2c driver causes an error when compiling.

    Did I perhaps forget a dependency?
  • #69 21370530
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14616
    Help: 655
    Rate: 12633
    Provide a link and information on what compilation error you have.

    There are two BMP drivers, choose the one that suits you.

    You can disable unnecessary things.

    If something is breaking, disable things one by one to determine which one is causing the problem.
    Helpful post? Buy me a coffee.
  • #70 21370759
    olekwal
    Level 6  
    Posts: 12
    To the topic of the 2 BMP drivers: yes, the "old" driver worked, I also had a working build. The problem was that the old driver (I think) was sending new measurements every second and so spamming my MQTT....

    Now I read that in the new driver there is an option "BMPI2C_Cycle 60". - I understand that this is how the frequency of measurements is set, yes? And this option only exists in the new controller?

    So I am just trying to build an image with this controller. I am building for BL602, a couple of unnecessary drivers I disabled without problems - this conf builds the image without problems:
    #elif PLATFORM_BL602
    // I have enabled drivers on BL602
    #define ENABLE_TASMOTADEVICEGROUPS 1
    #define ENABLE_LITTLEFS			1
    #define ENABLE_NTP    1
    //#define ENABLE_NTP_DST			1
    #define ENABLE_CALENDAR_EVENTS	1
    #define ENABLE_DRIVER_LED       1
    #define ENABLE_DRIVER_BL0937    1
    #define ENABLE_DRIVER_BL0942    1
    #define ENABLE_DRIVER_CSE7766   1
    //#define ENABLE_DRIVER_WEMO		1
    #define ENABLE_DRIVER_FREEZE	0
    //#define ENABLE_DRIVER_DHT		1
    // parse things like $CH1 or $hour etc
    #define ENABLE_EXPAND_CONSTANT	1
    #define ENABLE_TASMOTA_JSON		1
    #define ENABLE_DRIVER_DDP		1
    #define ENABLE_DRIVER_SSDP		1
    //#define ENABLE_DRIVER_CHT83XX 1
    //#define ENABLE_DRIVER_DS1820		1
    #define OBK_OTA_EXTENSION 		".bin.xz.ota"
    .

    but when I add i2c: #define ENABLE_I2C 1 it no longer builds:

    /home/runner/work/OpenBK7231T_App/OpenBK7231T_App/sdk/OpenBL602/customer_app/bl602_sharedApp/build_out/shared/libshared.a(drv_main.o): in function `.LANCHOR0':
    drv_main.c:(.data.g_drivers 0x24): undefined reference to `DRV_I2C_Init'
    /home/runner/work/OpenBK7231T_App/OpenBK7231T_App/sdk/OpenBL602/toolchain/riscv/Linux/bin/../lib/gcc/riscv64-unknown-elf/8.3.0/../../../../riscv64-unknown-elf/bin/ld: drv_main.c:(.data.g_drivers 0x28): undefined reference to `DRV_I2C_EverySecond'
    /home/runner/work/OpenBK7231T_App/OpenBK7231T_App/sdk/OpenBL602/toolchain/riscv/Linux/bin/../lib/gcc/riscv64-unknown-elf/8.3.0/../../../../riscv64-unknown-elf/bin/ld: drv_main.c:(.data.g_drivers 0x34): undefined reference to `DRV_I2C_Shutdown'
    /home/runner/work/OpenBK7231T_App/OpenBK7231T_App/sdk/OpenBL602/toolchain/riscv/Linux/bin/../lib/gcc/riscv64-unknown-elf/8.3.0/../../../../riscv64-unknown-elf/bin/ld: /home/runner/work/OpenBK7231T_App/OpenBK7231T_App/sdk/OpenBL602/customer_app/bl602_sharedApp/build_out/shared/libshared.a(new_pins.o): in function `Channel_OnChanged':
    /home/runner/work/OpenBK7231T_App/OpenBK7231T_App/sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared/src/new_pins.c:1060: undefined reference to `I2C_OnChannelChanged'
    make[1]: *** [/home/runner/work/OpenBK7231T_App/OpenBK7231T_App/sdk/OpenBL602/customer_app/bl602_sharedApp/../../make_scripts_riscv/project.mk:448: /home/runner/work/OpenBK7231T_App/OpenBK7231T_App/sdk/OpenBL602/customer_app/bl602_sharedApp/build_out/bl602_sharedApp.elf] Error 1
    make[1]: Leaving directory '/home/runner/work/OpenBK7231T_App/OpenBK7231T_App/sdk/OpenBL602/customer_app/bl602_sharedApp'
    make: *** [Makefile:177: OpenBL602] Error 2
    Error: Process completed with exit code 2.
    .

    looks like i2c can't build anymore. link to full log in fork: Link
  • #71 21370874
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14616
    Help: 655
    Rate: 12633
    ENABLE_I2C is not needed for this particular BME/BMP because it is done in standalone version, well you are right that there is an error with compilation when ENABLE_I2C is set to 1 under BL602.
    I have fixed it:
    https://github.com/openshwprojects/OpenBK7231...mmit/8fba7dd31e1326fc865f7f50f98fea589f091381
    Only as I say, you don't need ENABLE_I2C anyway.
    And while we're on the subject of the measurement cycle, I think I'll try to enter "drv_cycle [DriverName]" globally anyway, because I see this notification pops up every now and then, so it's worth it.
    Helpful post? Buy me a coffee.
  • #72 21371661
    olekwal
    Level 6  
    Posts: 12
    Ok, I understand.
    So I took out the extra I2C and the build works. Great, thank you!
    I just have one more question: i get from the build *.bin and *.ota.bin - both about 700 kB. On the OTA page of the WebApp I cannot upload them - Invalid OTA file was selected. Does anything still need to be done with these files? I see that the official builds are smaller (about 400 kB), but I thought it was because of the extra driver... .
    I have the image with the driver, after compressing the OTA file to xz and rename to "OpenBL602_OTA.bin.xz.ota" the file looks ok, it also has approx. 400 kB. But I still can't upload: in webApplication after uploading the file I still get "Invalid OTA file was selected". I am on the last official build (1.17.820).
  • #73 21392620
    olekwal
    Level 6  
    Posts: 12
    OK. Update:
    I can compile both drivers (BMPI2C and BMP280) correctly on BL602. OTA works.
    With my BME280 sensor: the BMP280 driver works everything.
    With the BMPI2C controller I do not get the humidity (or rather the humidity is wrong at 100%).
  • #74 21510676
    UserNameTaken
    Level 2  
    Posts: 3
    >>21370874 I've enabled BMP280 driver on the latest release on a fork. I notice that the command drv_cycle BMP280 is not recognized. I guess it never got added to the latest release? Any way to reduce the reporting interval? 1s floods the MQTT server.
    Otherwise all working great.
  • #76 21510838
    UserNameTaken
    Level 2  
    Posts: 3
    >>21510692 Ah OK, I'll add the other driver BMPI2C tomorrow, and test again. Thanks.

    Added after 1 [hours] 34 [minutes]:

    >>21510838 added & all working fine. Had to add a placeholder for humidity channel, even though there won't be a reading from a bmp280, in the config.
    startDriver BMPI2C 11 10 1 2 3 1
    BMPI2C_Cycle 60

    thanks again.

Topic summary

✨ The discussion focuses on integrating BME280 sensors with OpenBK firmware on WB2S modules for home automation, specifically for temperature, pressure, and humidity measurements. Initial efforts involved porting a BMP280 driver to OpenBK, with adaptations for BME280 compatibility, including chip ID detection (0x60 for BME280 vs. 0x58 for BMP280) and configurable I2C pins and addresses (0x76 or 0x77). The driver supports software-defined I2C and channels for temperature, pressure, and humidity, with MQTT integration for Home Assistant. Users addressed issues such as measurement scaling, channel type configuration, and publishing intervals, with suggestions to adjust measurement frequency via driver tick commands or BMPI2C_Cycle. The BME280 temperature reading is noted to be chip temperature, slightly higher than ambient, requiring calibration offsets for accuracy. Development progressed to support multiple sensors and improved driver flexibility. Challenges include limited flash memory on some platforms (e.g., BL602), requiring manual driver enabling and custom builds. A newer BMPI2C driver supports both BME280 and BME680 sensors with humidity measurement, though humidity accuracy on BME680 requires further work. Users shared build configurations, troubleshooting tips, and integration methods, including Home Assistant MQTT discovery and manual scripting. The community also discussed driver availability on different hardware platforms, compilation issues, and OTA update file handling. Overall, the integration is functional with ongoing development to enhance features, stability, and ease of use for home automation applications.
Generated by the language model.

FAQ

TL;DR: With 1 sensor per WB2S and a simple command, OpenBK can read BME280 data over software I2C; one contributor confirmed, "all working fine" with BMPI2C_Cycle 60, which also stops 1-second MQTT flooding. This FAQ helps OpenBK users connect BME280/BMP280/BME680-class sensors and publish stable readings to Home Assistant or OpenHAB. [#21510838]

Why it matters: This thread shows the practical path from a first BME280 question to working OpenBK drivers, Home Assistant publishing, BL602 builds, and configurable reporting intervals.

Driver Sensors discussed Humidity support Address handling Reporting interval
BMP280 BMP280, partial BME280 use No native BME humidity at first Later extended Originally every 1 s
BMPI2C BME280, BMP280, BME680-class testing Yes, via humidity channel Explicit address parameter BMPI2C_Cycle 60 supported

Key insight: Use the older BMP280 driver only for basic temperature and pressure tests. For real deployments, BMPI2C is the better OpenBK path because it adds humidity-channel support and a configurable measurement cycle.

Quick Facts

  • BME280 and BMP280 use different chip IDs: BME280 reports 0x60, while BMP280 reports 0x58; confusing those values causes the classic "wrong ID" error. [#20862072]
  • The same BME280 breakout can expose two I2C addresses, 0x76 or 0x77, selected by switch or ADDR wiring on the board. [#20861920]
  • OpenBK later introduced startDriver BMPI2C [CLK] [DATA] [TempCh] [PressureCh] [HumidityCh] [Addr], where 0 means 0x77 and 1 means 0x76 in the newer syntax. [#21123022]
  • One BL602 user confirmed working wiring on P16 = SCL and P7 = SDA, after initial ID errors caused by wrong pin guesses. [#21011686]
  • A long-run test device with BME280 stayed stable for 10+ days, suggesting the OpenBK integration is practical beyond bench testing. [#21143369]

How do I connect a BME280 sensor to a WB2S module running OpenBK using software I2C?

Wire the sensor to two free GPIOs and start the OpenBK driver with those pins as software I2C clock and data. 1. Connect SCL to your chosen CLK GPIO and SDA to your chosen DATA GPIO. 2. Power the sensor and set its address to 0x76 or 0x77. 3. Run startDriver BMP280 24 11 1 2 for temp and pressure, or use BMPI2C if you also want humidity. The thread confirms one BME280 worked immediately after pin selection and driver start on WB2S-class hardware. [#20862072]

What does the OpenBK command "startDriver BMP280 [CLK] [DATA] [ChannelForTemp] [ChannelForPressure]" actually do, and how should I choose the GPIO pins and channels?

It starts the BMP280-family driver on two chosen GPIOs and stores readings in the channels you assign. CLK and DATA are the software I2C pins, while ChannelForTemp and ChannelForPressure are numeric OpenBK channels, such as 1 and 2. Pick GPIOs that are free on your board, then map the channels to channel types like Temp_div100 or Pressure_div100. One working example from the thread is startDriver BMP280 8 14 1 2. [#20862067]

Why does OpenBK report "BMx280 wrong ID" with a BME280 or BMP280 sensor, and how do I troubleshoot chip ID versus I2C address issues?

OpenBK reports "BMx280 wrong ID" when it can talk on I2C but the returned chip ID does not match what the driver expects. Check three things in order: 1. Confirm SCL and SDA are on the correct GPIOs. 2. Confirm the board is really a BME280 or BMP280. 3. Separate chip ID from I2C address during diagnosis. One BL602 user fixed the error simply by finding the correct pins, and another user found the BME280 returned 0x60 instead of the BMP280 0x58. [#21011686]

What is the difference between the BME280 chip ID and the I2C address, and why do values like 0x60, 0x58, 0x76, and 0x77 get mixed up?

The chip ID identifies the sensor model, while the I2C address identifies where that sensor sits on the bus. 0x60 is the BME280 chip ID, 0x58 is the BMP280 chip ID, and 0x76 or 0x77 are selectable I2C addresses. They get mixed up because both numbers appear during setup, but they solve different problems. One user explicitly realized the difference after trying to treat 0x77 as a chip ID value. [#21072813]

How can I publish BMP280 or BME280 temperature and pressure readings from OpenBK to Home Assistant over MQTT?

Use OpenBK channels with MQTT publishing, then let Home Assistant discover them or publish them manually. The thread gives two direct commands: publishFloat myTemp $CH1*0.01 and publishFloat myPress $CH2*0.1. You can also trigger updates on change with addEventHandler OnChannelChange 1 publishFloat myTemp $CH1*0.01. One user said the target platform was Home Assistant over MQTT, and the developer confirmed both discovery-based and script-based publishing paths. [#20862313]

What's the correct way to scale OpenBK BMP280 pressure and temperature values for Home Assistant, including Temp_div100 and Pressure_div100?

Scale temperature by 0.01 and pressure by the correct divider for the channel type you use. The thread shows raw values like T 2391 and P 100185, which correspond to about 23.91 °C and 1001.85 hPa after scaling. In OpenBK, Temp_div100 is the expected choice for temperature, and pressure needed its own corrected handling during development. One fix changed the web display from g_pressure*0.1f to g_pressure*0.01f for hectopascals. [#20865733]

How do channel types and the divider flag in OpenBK affect MQTT values for BME280 or BMP280 sensors?

Channel types control formatting and discovery, but MQTT can still send raw integers unless the divider flag is enabled. A BL602 user saw 2660 over MQTT instead of 26.60, even though the web page displayed scaled values correctly. The developer answered that a divider flag solves that mismatch because OpenBK still follows the TuyaMCU-style integer storage model. Turn that flag on if you want MQTT payloads to honor the selected divider. [#21013349]

What is the BMPI2C driver in OpenBK, and how is it different from the older BMP280 driver?

BMPI2C is the newer OpenBK driver for BMx280-style sensors, and it adds humidity support plus a configurable cycle command. "BMPI2C is a sensor driver that reads BMx280-family devices over software I2C, exposes separate temperature, pressure, and humidity channels, and accepts an explicit address parameter for multi-model support." The older BMP280 driver started as a simpler temp-and-pressure driver and originally ran every second. The BMPI2C command format adds [ChannelForHumidity] and [Addr], plus BMPI2C_Cycle 60. [#21123022]

BMP280 driver vs BMPI2C in OpenBK — which one should I use for BME280, BMP280, or BME680 sensors?

Use BMPI2C for new setups, especially if you need humidity or slower reporting. The older BMP280 driver is fine for quick BMP280 or basic BME280 temperature-and-pressure tests, and users confirmed it worked on real hardware. BMPI2C is the better fit for BME280 and newer experiments because it supports temp, pressure, humidity, and a cycle command. A later user switched to BMPI2C for a plain BMP280 and reported it worked after adding a placeholder humidity channel. [#21510838]

How can I slow down BME280 or BMP280 measurement and MQTT reporting in OpenBK so it doesn't publish every second?

Move to the newer BMPI2C driver and set a longer cycle. The older BMP280 path measured and published every 1 second, which multiple users called noisy or flooding for MQTT. The newer solution is BMPI2C_Cycle 60, which triggers the driver every 60 seconds instead. That change directly addresses the thread's repeated complaint about one-second updates on Home Assistant or OpenHAB. [#21123022]

What does the OpenBK command "BMPI2C_Cycle 60" do, and how should I set a practical measurement interval for Home Assistant or OpenHAB?

BMPI2C_Cycle 60 tells the BMPI2C driver to read and report every 60 seconds. For room temperature, pressure, and humidity, 60 seconds is a practical starting point because ambient conditions rarely need 1-second updates. One user wanted 5 minutes to reduce MQTT noise, while another confirmed 60 seconds worked fine in practice. Set the interval to match your dashboard and automation needs, not the fastest possible sensor rate. [#21510838]

Why is the BMP280 or BMPI2C driver missing from some OpenBK builds, and how do I enable it in obk_config.h and compile my own firmware?

Some OpenBK builds omit these drivers because flash space is tight, so you must enable them in obk_config.h and compile a custom binary. The developer explicitly said the BMP280 driver may be disabled because the project is slowly running out of flash memory. For the older driver, add #define ENABLE_DRIVER_BMP280 1. For newer builds, enable the newer BMPI2C path instead if that is the driver you need. [#20945538]

How do I build OpenBK with BMP280 or BMPI2C support for BL602, and what compile errors or missing dependencies should I watch for?

For BL602, enable the specific driver in the BL602 section of obk_config.h, then build without assuming generic I2C is required. The key trap is enabling ENABLE_I2C 1, which caused undefined references such as DRV_I2C_Init, DRV_I2C_EverySecond, and I2C_OnChannelChanged until it was fixed. The developer later clarified that ENABLE_I2C is not needed for this standalone BME/BMP driver on BL602. That makes the cleanest BL602 path: enable the sensor driver, skip generic I2C, and compile again. [#21370874]

What is OTA in OpenBK, and how do I prepare a custom BL602 firmware file so the web app accepts it for update?

OTA is the OpenBK web update package format, and BL602 custom builds may need repackaging before the web app accepts them. One user found that raw .bin and .ota.bin files were rejected as "Invalid OTA file was selected." They then compressed the OTA file to xz, renamed it to OpenBL602_OTA.bin.xz.ota, and got the file into the expected size range near 400 kB instead of about 700 kB. Later, the same user confirmed OTA worked with their BL602 custom builds. [#21371661]

How far can I get using a BME680 with OpenBK today, and what still needs extra driver work compared with BME280 support?

You can get partial detection and some experimental operation, but BME680 still needs extra driver work compared with BME280. One contributor added BME680 chip-ID detection only and stated that the driver itself still needed more work to function properly on BME680. Later, another user reported both BME680 and BME280 running on the same board with a custom BMPI2C-enabled build, but that was from a personal fork, not a standard public binary. So BME280 support is the mature path today. [#21275971]
Generated by the language model.
ADVERTISEMENT