logo elektroda
logo elektroda
X
logo elektroda

Integrating BME280 Sensor with OpenBK on WB2S Modules for Home Automation

bilbs84 6987 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: 4852
    Help: 424
    Rate: 857
    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?
  • ADVERTISEMENT
  • #63 21123022
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14412
    Help: 650
    Rate: 12357
    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: 596
    Help: 34
    Rate: 126
    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: 4852
    Help: 424
    Rate: 857
    that's cool. so that's your own build with the old driver added?
  • #67 21276274
    DeDaMrAz
    Level 22  
    Posts: 596
    Help: 34
    Rate: 126
    divadiow wrote:
    that's cool. so that's your own build with the old driver added?


    Yes, from my playground/fork :)
  • #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: 14412
    Help: 650
    Rate: 12357
    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.
  • ADVERTISEMENT
  • #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: 14412
    Help: 650
    Rate: 12357
    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: OpenBK keeps BMP/BME280-enabled firmware below 400 kB [Elektroda, olekwal, post #21371661]; “Very impressed with OpenBK” [Elektroda, bilbs84, post #20862072] Flash the driver, wire SDA/SCL, run startDriver BMPI2C …, and your sensor publishes temperature, pressure and humidity to Home Assistant in under five minutes.

Why it matters: Re-using cheap WB2S/BL602 modules avoids landfill and adds room-wide climate data to any smart home.

Quick Facts

• I²C addresses selectable: 0x76 or 0x77 via jumper or command [Elektroda, bilbs84, post #20861920] • Default OpenBK sampling: 1 s; adjustable to 60 s+ with BMPI2C_Cycle [Elektroda, p.kaczmarek2, post #21123022] • Chip IDs – BMP280 0x58, BME280 0x60, BME680 0x61 [Elektroda, bilbs84, post #20862072] • Typical OTA binary size with driver: ≈400 kB (compressed) [Elektroda, olekwal, post #21371661] • Sensor offset: on-board temperature reads 2-3 °C high [Elektroda, Helmi_Beh, post #20862559]

How do I enable a BME280/BMP280 on a WB2S or BK7231 module?

  1. Wire SCL to your chosen CLK GPIO and SDA to DATA; power at 3.3 V.
  2. In the WebApp console enter startDriver BMPI2C <CLK> <DATA> <TempCh> <PressCh> <HumCh> <Addr> where Addr is 1 for 0x76 or 0 for 0x77 [Elektroda, p.kaczmarek2, post #21123022]
  3. Save to autoexec so the driver loads on boot. A reading appears immediately on the index page and via MQTT.

My firmware says “Driver BMP280 is not known in this build”. What now?

The driver was compiled out to save flash. Re-build OpenBK with #define ENABLE_DRIVER_BMP280 1 (or ENABLE_DRIVER_BMPI2C 1) in obk_config.h, then flash the new binary [Elektroda, p.kaczmarek2, post #20945538]

How can I slow down the 1-second MQTT flood?

With the new BMPI2C driver run BMPI2C_Cycle <seconds>; e.g., BMPI2C_Cycle 60 publishes once a minute [Elektroda, p.kaczmarek2, post #21123022] Older BMP280 driver lacks this option—update or script throttling.

Which chip ID or I²C address should I expect?

• BMP280: ID 0x58, address 0x76/0x77 • BME280: ID 0x60, address 0x76/0x77 • BME680: ID 0x61, address 0x76/0x77 [Elektroda, bilbs84, #20862072; divadiow, #21072813].

Home Assistant shows temperature but no pressure or humidity—why?

Assign correct channel types: set Temp_div100, Pressure_div100, and Humidity_div100 for the respective channels, or let discovery auto-map them. Missing mapping leaves blank fields on the device page even though MQTT data is sent [Elektroda, bilbs84, post #20864417]

Can I run multiple sensors on one bus?

Yes. Use different I²C addresses (0x76 and 0x77). Example autoexec: startDriver BMPI2C 26 24 4 5 6 238 (BME680 0x77) startDriver BMP280 8 7 1 2 3 236 (BMP280 0x76) [Elektroda, DeDaMrAz, post #21275971]

Does the temperature reading need calibration?

Datasheet states the internal temp is mainly for pressure/humidity compensation and can be 2-3 °C high [Elektroda, Helmi_Beh, post #20862559] Add an offset with the addChannelOffset command or in Home Assistant if precise ambient values are required.

What if compilation fails with I²C undefined references on BL602?

Do not set ENABLE_I2C for BMPI2C; it is standalone. A patch fixing the linker issue is in commit 8fba7dd3 [Elektroda, p.kaczmarek2, post #21370874]

Edge case: chip detected but reads wrong ID, driver fails.

This occurs when SDA/SCL pins are swapped or floating, or if VDDIO is at 5 V (sensor is 3.6 V max). Correct wiring and level-shift if needed [Elektroda, p.kaczmarek2, post #21054975]

How stable is the sensor with OpenBK long-term?

A BME280 test node has run for >10 days without data drop [Elektroda, DeDaMrAz, post #21143369] That equals ~14,400 successful cycles at a 1-minute interval.

Quick 3-step build-and-flash guide?

  1. Fork repo, edit obk_config.h, enable driver.
  2. Push to GitHub; Actions produce *.ota artifact (≈400 kB).
  3. Upload the file via WebApp OTA page; device reboots with sensor support [Elektroda, olekwal, post #21011634]
Generated by the language model.
ADVERTISEMENT