logo elektroda
logo elektroda
X
logo elektroda

Integrating BME280 Sensor with OpenBK on WB2S Modules for Home Automation

bilbs84 4509 75
ADVERTISEMENT
  • #61 21112840
    divadiow
    Level 34  
    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  
    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
    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.
  • #65 21275971
    DeDaMrAz
    Level 19  
    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 34  
    that's cool. so that's your own build with the old driver added?
  • #68 21370419
    olekwal
    Level 6  
    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?
  • ADVERTISEMENT
  • #69 21370530
    p.kaczmarek2
    Moderator Smart Home
    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  
    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
    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  
    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).
  • ADVERTISEMENT
  • #73 21392620
    olekwal
    Level 6  
    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  
    >>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  
    >>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 revolves around integrating the BME280 sensor with OpenBK firmware on WB2S modules for home automation. A user seeks guidance on utilizing their BME280 sensors with OpenBeken, expressing a lack of examples and knowledge about software-defined I2C. Contributors share their progress in porting drivers, troubleshooting issues related to sensor IDs, and implementing temperature, pressure, and humidity readings. They discuss the need for proper scaling in Home Assistant (HA) and the possibility of adjusting measurement intervals. The conversation also touches on the compatibility of BME680 sensors and the challenges faced in enabling drivers for different platforms, including BL602. Overall, the community collaborates to enhance sensor functionality and integration with home automation systems.
Summary generated by the language model.
ADVERTISEMENT