logo elektroda
logo elektroda
X
logo elektroda

[BK7231N CBU] Generic Temperature and Humidity Sensor

Chasbrot 54015 359
ADVERTISEMENT
  • #271 20905768
    sirhcsat
    Level 7  
    The board stencil markings for rx & tx are incorrect. they are swapped as mentioned by @alexkip
    the rx board breakout header does connect to the cbu tx pin and the tx board breakout header is connected to the cbu rx pin.

    Now i just need to configure the sht as the current readings are -49c and humdidty of 3% and sort the sleep out.

    Sorry for being a pain in the arse. Sorting this car for M.O.T has rained down the brain fog.

    thx for the help.
  • ADVERTISEMENT
  • #272 20905772
    p.kaczmarek2
    Moderator Smart Home
    If the port on the board has wrong marking, then there is nothing to worry about. It's just the same old CBU module as always. Nothing is locked as far as I know.

    SHT should not give readings like -49C, do you have gpios selected correctly?
    Helpful post? Buy me a coffee.
  • #273 20905846
    sirhcsat
    Level 7  
    Thats what I am looking into now @p.kaczmarek2. I looked at the 2 configs for the sht3 on here and used the same and that is what it comes up with. The led is always on as well. I need to get the microscope out and check the actual sensor to see if it is an sht30 as my eyes can not see that well under led lighting. here is picture of the sensor.

    Close-up of a chip labeled CHT8310 CBR128 on a blue PCB.


    It apears that I was "sold a dud" as the sensor was advertised as having the sht3x chip but it turns out it was a different chip and actually is a cht8310 chip and that explains the muddled I got into with this sensor. (never believe a thing Aliexpress advertises).

    its the same sensor as @kuba4321234 and even the same board as theirs. As @p.kaczmarek2 mentioned in the other thread this is actually the cht8310 and is compatable with the cht8305 driver ( great work ) and the temp and humidity readings are a lot closer than -49c and 3% so things are looking up. In the thread (https://www.elektroda.com/rtvforum/topic4019974.html) there is no mention of the led or button or even the battery adc etc . have i missed a thread or post with a complete config for this ? or is this still a work in progress to make a complete working config for other users.

    thx
  • #275 20906563
    p.kaczmarek2
    Moderator Smart Home
    Are SCL/SDA pins really correct? Can you extract Tuya config?



    By the way, your config is very, very inefficient. This will drain battery fast. 50 seconds online? I'd just do wait for MQTT to report and back to sleep. Hm.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #276 20906880
    sirhcsat
    Level 7  
    I do not think the config will work very well, sda second channel is the same as wifi led and scl and as far as I know they need to be on seperate channels. ??
    the wifiled on 16 seems to be correct as it lights and flashes 6 or 7 times at power up.
    sck on 20 and dat on 22 is from the other thread and work if different chanels are used.
    bat adc & bat rel are unknown

    could these few posts be moved over to the other thread @p.kaczmarek2 since they are actually about the cht8310 ? that way it keeps this thread clean and puts this in the correct place with the other work done on the sensor ?
  • #278 20906976
    sirhcsat
    Level 7  
    @p.kaczmarek2 the sensor that me and @alexkip have seem to be cht8310 chips and this other thread would be a beter place to have our posts merged into.
    https://www.elektroda.com/rtvforum/topic4019974.html

    this thread also seems to be the same device if not the cht8305
    https://www.elektroda.com/rtvforum/topic4027957.html

    maybe they could all be merged into a new thread for cht8305/8310 sensors ??
    sirhc
  • #279 20910790
    Xinayder
    Level 8  
    p.kaczmarek2 wrote:
    I'd just do wait for MQTT to report and back to sleep.


    Is there a specific command for this or just wait for 5 seconds after publishing?
  • #280 20911140
    p.kaczmarek2
    Moderator Smart Home
    Helpful post? Buy me a coffee.
  • #281 20919451
    sirhcsat
    Level 7  
    I have transplanted an sht3x and R2-(10r), R3-(10k), R4-(10k) & C2-(100nf) onto the door sensor board, adjusted the config and it.... Sort of works.
    Screenshot showing information about a toilet door sensor, displaying temperature, humidity, and battery status.


    but only while the door sensor is open. with the door closed the temp and humidity blow to max readings
    Screenshot of toilet door sensor data showing anomalies in readings.


    config:

    "7": "SHT3X_SCK;2",
    "8": "SHT3X_SDA;3;4",
    "16": "DoorSnsrWSleep_nPup;0",
    "17": "BAT_Relay;1",
    "20": "Btn;5",
    "23": "BAT_ADC;1",
    "26": "LED;0"


    Future plans:-
    get the sht3x to give acurate readings while the door is closed ? could it be the hall sensor creating noise and messing the readings up.
    Could an autoexec.bat be made to take a reading from the sht3x every 15 mins and send via mqtt and maybe even send a door status at the same time (how would this effect the battery drain)

    Anyone any ideas. ?
  • #282 20919523
    p.kaczmarek2
    Moderator Smart Home
    Try setting different channels here:
    "8": "SHT3X_SDA;3;4",
    maybe 6 and 7
    Helpful post? Buy me a coffee.
  • #283 20919579
    sirhcsat
    Level 7  
    just the same on 6 & 7 as with 3 & 4.

    what I have noticed is that after about 10-15 seconds after the door sensor is closed the temp and humi readings return to the correct level most of the time. now and again they just sit maxed out until the battery goes to sleep after 60 seconds (that I have set in autoexec.bat) and just stay there until the door is opened again..
    I think it may need a juicy autoexec.bat to force a reading from the sht when the door sensor is opened or closed and poss every 10 mins or so to read them all and publish to mqtt for my home assistant system...

    I have been reading the example autoexec.bat files you supplied and got a rough (prob not working version) started.

    // start drivers
    startDriver Battery
    startDriver DoorSensor
    startDriver SHT3X
    //hold button to get into safe mode
    addEventHandler OnHold 20 SafeMode
    // press button to take temp & humi reading
    addEventHandler OnClick 20 // no idea what goes here.
    // wait for wifi to become WIFI_STA_CONNECTED
    waitFor WiFiState 4
    Battery_Setup 2500 4200 2.29 2400 4096
    battery_measure
    publishFloat "voltage" $CH4/1000
    publishFloat "battery" $CH4/25
    // extra wait
    delay_s 5
    // measure
    SHT_Measure
    // send data
    publishFloat "temperature" $CH2/10
    publishFloat "humidity" $CH3
    // wait for mqtt data sending to complete
    delay_s 5
    // sleep for 120 seconds and then wake up (from blank state)
    DeepSleep 120


    No idea if this is even close as my good old dos/basic code was forgot about 20 years ago the last time I needed to write a windows batch file to backup an hdd to cd, I vowed never to dig into it again.

    Edit :-0 simply removing the door sensor form the config and rebooting turns it into a normal temp humidity sensor and putting the magnet to the sensor as if the door is closed does not trigger the over reading on the temp or humidity so I think random noise from activating the hall sensor used for the door can be ruled out. but then it points to how the driver for the door sensor is doing its magic (the door sensor is still active and loaded in autoexec.bat)
  • ADVERTISEMENT
  • #284 20972227
    aleksey2
    Level 1  
    why my temperature not correct? now 20-21 C

    Screenshot of the web interface for OpenBK7231N device, showing a temperature of 28.7°C, humidity of 43%, and battery level of 37.9%. Device configuration with BK7231N CBU module, visible on a control panel with pin settings.
  • #285 20982756
    Xinayder
    Level 8  
    @p.kaczmarek2 I have reflashed my device again and recharged my batteries.

    I have an issue now and I'd like to ask for help debugging it. This is my current autoexec.bat file:

    
    startDriver SHT3X
    
    mqtt_broadcastItemsPerSec 5
    
    //SHT_cycle 60
    //Battery_cycle 60
    
    // hold button to get into safe mode
    addEventHandler OnHold 20 SafeMode
    
    // AAA battery: 1500 3000
    // rechargable: 1800 2400
    Battery_Setup 2000 2800
    // Battery_Measure
    
    // SHT_measure
    
    // wait until wifi is connected
    waitFor WiFiState 4
    
    // go to deep sleep if mqtt can't connect
    addRepeatingEventID 30 -1 1337 DeepSleep 900
    
    // wait until mqtt is connected
    waitFor MQTTState 1
    
    cancelRepeatingEvent 1337
    
    publishChannels
    
    delay_s 5
    
    DeepSleep 900
    


    I have the following flags enabled: Broadcast self state every N seconds; [WiFi] Quick connect to WiFi on reboot (TODO: check if it works for you and report on github);

    and when I check Home Assistant, the device is broadcasting three times, the last ones were at 15:10:39 (I suppose it broadcasts when connected), 15:10:41 and then 15:13:17. Maybe the first broadcast can be ruled out because of the avty_t field, but why is it broadcasting two times? It looks like the sensor is being kept online for 3 minutes before going to deep sleep.
  • #286 20983085
    p.kaczmarek2
    Moderator Smart Home
    Can you provide more information, maybe a more detailed log what happens when?

    There is a flag that allows you to control the device state broadcast on MQTT connect.
    Helpful post? Buy me a coffee.
  • #287 21006404
    sirhcsat
    Level 7  
    @p.kaczmarek2 My converted door sensor (now sht3x temp & humidity) sensor batterys only lasts about 7 days. I am in the process of changing over to Zigbee but it will be a few more months until I get round to the rest if the wifi sensors so can you check the autoexec.bat and see if I have configured it wrong.. Thx

    // start drivers
    startDriver Battery
    PowerSave 1
    // start Alexa Discovery
    //StartDriver SSDP
    // start wemo discovery
    //StartDriver Wemo
    // startDriver SHT3x Sensor Driver
    startDriver SHT3X
    // Calibrate Sensor offset for acurate readings
    SHT_Calibrate -2.4 +3
    //hold button to get into safe mode
    addEventHandler OnHold 20 SafeMode
    // press button to take temp & humi reading
    addEventHandler OnClick 20 SHT_Measure
    // wait for wifi to become WIFI_STA_CONNECTED
    waitFor WiFiState 4
    Battery_Setup 2500 3200 2.29 2400 4096
    battery_measure
    publishFloat "voltage" $CH4/1000
    publishFloat "battery" $CH1/25
    // extra wait
    delay_s 5
    // measure
    SHT_Measure
    // send data
    publishFloat "temperature" $CH2/10
    publishFloat "humidity" $CH3
    // wait for mqtt data sending to complete
    delay_s 5
    // sleep for 900 seconds (15 mins) and then wake up
    DeepSleep 900 



    Looking at the HA data the sensor seems to take a reading every 5 mins then every 15 mins sends the data to HA. If this is how it works how many readings can it store so I could only get it to send every hour. (its only a sensor in my attic space to monitor temp and humidity so I can keep my stuff dry that is stored up there)

    Cheers
  • #288 21006672
    p.kaczmarek2
    Moderator Smart Home
    You have twice the:
    
    // extra wait
    delay_s 5
    

    command, which is an unnecessary delay.
    You should just wait once for MQTT state and then publish and wait a second or so, nothing more.
    So you are wasting 9 seconds.

    Futhermore, why do you wait for WiFi state and then publish data via MQTT? WiFi state is not MQTT state, there may be a slight delay between WiFi connect event and MQTT connect event.
    Helpful post? Buy me a coffee.
  • #289 21006712
    sirhcsat
    Level 7  
    Thanks.

    The autoexec.bat is a generic one and I should remove the unused parts from this sensor. I just copy the base version to whatever device is on the bench and adjust it as and when while testing.

    I will adjust the wait time and remove the unused parts the next time I swap the batterys out.
    
    // start drivers
    startDriver Battery
    PowerSave 1
    // startDriver SHT3x Sensor Driver
    startDriver SHT3X
    // Calibrate Sensor offset for acurate readings
    SHT_Calibrate -2.4 +3
    //hold button to get into safe mode
    addEventHandler OnHold 20 SafeMode
    // press button to take temp & humi reading
    addEventHandler OnClick 20 SHT_Measure
    // Set Battery data
    Battery_Setup 2500 3200 2.29 2400 4096
    // Take Battery Readings
    battery_measure
    // Take SHT3X Readings
    SHT_Measure
    // Send MQTT Data
    publishFloat "voltage" $CH4/1000
    publishFloat "battery" $CH1/25
    publishFloat "temperature" $CH2/10
    publishFloat "humidity" $CH3
    // wait for mqtt data sending to complete
    delay_s 5
    // sleep for 900 seconds (15 mins) and then wake up (from blank state)
    DeepSleep 900

    Moderated By p.kaczmarek2:

    Following autoexec.bat is incorrect! It's missing a wait for MQTT. Don't use it!

  • ADVERTISEMENT
  • #290 21006720
    p.kaczmarek2
    Moderator Smart Home
    The autoexec you have posted now is incorrect. You need to use:
    
    // now wait for MQTT
    waitFor MQTTState 1
    

    before invoking
    
    publishFloat "voltage" $CH4/1000 
    

    The following script will not publish anything most likely because you execute publish commands before MQTT connection is established.
    Helpful post? Buy me a coffee.
  • #291 21006809
    sirhcsat
    Level 7  
    Oooops. Thank you @p.kaczmarek2 for pointing that out. I was more interested in watching the 6 nations rugby than watching what I was doing on the computer..
  • #292 21014538
    p.kaczmarek2
    Moderator Smart Home
    Scripting a device to go to sleep without any delay after reboot is a very good way to brick it. Luckily OBK checks for "uncomplete reboots", where each boot is always marked first as "incomplete" and it's marked as "complete" only after 5 seconds from the start (configurable). If 5 or more uncomplete boots are detected, then autoexec.bat is no longer run. This is called "safe mode" and it's designed for such cases, so you can still recover your device if you have some breaking code in the LittleFS.

    Still, your particular case may have been more tricky because you've actually scripted it to go to sleep after 5 seconds of delay, so it may have been unable to detect incomplete but still sleep too fast for user to react... well, that could have been problematic!
    Helpful post? Buy me a coffee.
  • #293 21051672
    MPatern
    Level 1  
    Hello guys,

    Can someone can explain to me, why I've got bad reading on my sensor ?

    Screenshot showing SHT3X sensor data with temperature 130.0°C, humidity 100%, battery level 53.33%, and other parameters.

    Thanks for all ! :)
  • #294 21052869
    p.kaczmarek2
    Moderator Smart Home
    Hello, what does the log say? Do you have correct GPIO roles selected?
    Helpful post? Buy me a coffee.
  • #295 21101835
    pipelkrsk
    Level 3  
    >>21052869>>21052869
    I have a similar problem. I looked at the temperature sensor under a microscope. It's labelled 8315. This means that I have the third version of the device.
    I have tried all the suggested settings in this and neighbouring threads. Nothing works.
    Only P7-CHT8305_SCK and P8-CHT8305_SDA have some reaction shown when heating and cooling the sensor. But the readings themselves are very strange.
  • #297 21101969
    insmod
    Level 22  
    What is the reported chip id? I haven't found a normal datasheet, but it is possible, that 8310 and 8315 are similar enough to work with the same code. If chip id is not 0x8215, then it uses default (8305) measurement code.
  • #300 21102133
    divadiow
    Level 34  
    will see if I can find anything.

    on a different note it looks like Easy flasher is missing some pin extraction opportunities

    eg

    Code: Text
    Log in, to see the code


    Code: JSON
    Log in, to see the code


    Code: Text
    Log in, to see the code


    Added after 1 [hours] 3 [minutes]:

    hmm. haven't worked out Ghidra clearly to find anything yet and I'm off for the whole weekend in an hour. over to someone else...

Topic summary

The discussion revolves around the BK7231N CBU temperature and humidity sensor, particularly focusing on its integration with OpenBeken firmware. Users share experiences regarding the sensor's performance, battery life, and configuration challenges. Key topics include the effectiveness of deep sleep modes for power saving, the calibration of the SHT30 sensor, and the impact of various configurations on battery consumption. Users also discuss issues with incorrect temperature readings, the need for proper GPIO assignments, and the potential for using alternative sensors. Several users report successful modifications and share their autoexec.bat scripts for optimal operation. The conversation highlights the importance of correct pin configurations and the challenges faced when using low-quality batteries.
Summary generated by the language model.
ADVERTISEMENT