logo elektroda
logo elektroda
X
logo elektroda

[BK7231N CBU] Tuya WiFi Temperature and Humidity Sensor (Blue PCB, no TuyaMCU)

dmcbeing  16 7437 Cool? (+4)
📢 Listen (AI):

TL;DR

  • The BK7231N CBU Tuya WiFi Temperature and Humidity Sensor with a blue PCB and no TuyaMCU was identified for OpenBeken/ESPHome support.
  • The board talks directly to the CHT8305 temperature-and-humidity sensor over I2C instead of using a TuyaMCU.
  • Battery operation depends on deep sleep, because the sensor lasts only a few days on batteries without it, and the ESPHome test used a bk72xx cbu setup.
  • ESPHome flashing worked, but I2C and deep-sleep support were still incomplete.
Generated by the language model.
I recently bought a few of 'Tuya WiFi Temperature and Humidity Sensor'.

I looked for an existing thread for this exact device but only found a few users posting pictures of this board.

Here is a picture of the PCB: PCB board of Tuya WiFi sensor with highlighted components and connections.

And here is the firmware from an unused device:
tuya_r..zip (1002.72 kB)You must be logged in to download this attachment.
Tuya JSON:
Code: JSON
Log in, to see the code

It does not have a TuyaMCU and is using I2C to communicate with the Temp+Humidity sensor CHT8305.

This device requires deep sleep to run on batteries longer than few days.
Please see related topics for details:
https://www.elektroda.com/rtvforum/topic4025593.html
https://www.elektroda.com/rtvforum/topic3945688.html
https://www.elektroda.com/rtvforum/find.php?q=CHT8305

I have flashed esphome and aside from I2C, and deep-sleep, everything else works.

esphome:
  name: upk2esphome-bk7231n

bk72xx:
  board: cbu

logger:
  baud_rate: 0

# tuya:

web_server:

captive_portal:

mdns:

external_components:
  - source: /soft_i2c

#api:
#  password: ""
#  reboot_timeout: 0s

ota:
  password: ""

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  use_address: 192.168.1.32
  fast_connect: true
  ap:

mqtt:
  broker: mqtt.hlab.host

button:
  - platform: restart
    name: Restart

debug:
  update_interval: 30s

text_sensor:
  - platform: debug
    reset_reason:
      name: Reset Reason
  - platform: libretiny
    version:
      name: LibreTiny Version
sensor:
  - platform: uptime
    name: Uptime
    update_interval: 15s
    id: uptime_sensor
  - platform: adc
    pin: P23
    name: "Battery Level"
    update_interval: 15s
    on_value:
      then:
        - mqtt.publish_json:
            topic: temp_sensor
            payload: |-
              root["batt"] = x;
              root["uptime"] = id(uptime_sensor).state;
              root["alert"] = id(alert).state;

uart:
  rx_pin: RX1
  tx_pin: TX1
  baud_rate: 115200

light:
  - platform: binary
    name: "Status"
    output: status_output

output:
  - id: status_output
    platform: gpio
    pin: P16

binary_sensor:
  - platform: gpio
    pin: 
      number: P14
      inverted: true
    name: "Button"
  - platform: gpio
    id: alert
    pin: 
      number: P7
      inverted: true
    name: "Alert"


I hope this information is sufficient to 'port'/support openbeken for this device.

Let me know if i can help any other way.

About Author
dmcbeing wrote 5 posts with rating 4 . Been with us since 2024 year.

Comments

p.kaczmarek2 13 Jan 2024 08:57

I will edit your first post to add more information, but first of all, your current config is incorrect . You can't just: This device must have deep sleep, otherwise it will drain batteries really,... [Read more]

johnypean 13 Jan 2024 21:03

I have it working quite well. I have gathered information from multiple threads about these sensors here. Even the battery is working and showing up in HASS. "pins": { "8": "BAT_Relay;0", "14":... [Read more]

dmcbeing 16 Jan 2024 23:45

Thanks for the replies @p.kaczmarek2 and @johnypean. I got stuck at flashing as the GUIFlashTool would not work in Linux ... it would freeze when writing the first page after erasing all flash blocks. Installing... [Read more]

p.kaczmarek2 16 Jan 2024 23:47

Are the device configs the same? Is the device hardware the same for both devices? [Read more]

dmcbeing 17 Jan 2024 00:31

Yes, I copied and pasted all settings and autoexec.bat from the first device I flashed that reports correct values. [Read more]

dmcbeing 19 Jan 2024 22:00

I played a bit with the sensors in the previous days and redid my configuration, and now all sensors return valid readings. I also started playing with the deepsleep as @p.kaczmarek2 recommended. However... [Read more]

johnypean 22 Jan 2024 14:18

If you activated Flag 36 - "[DRV] Deactivate Autostart of all drivers", you have to add startDriver Battery to autoexec.bat Had the same happen. [Read more]

dmcbeing 23 Jan 2024 21:39

@johnypean Nope, i don't have that enabled I have the following enabled: Flag 2 - [MQTT] Broadcast self state every N (def: 60) seconds (delay configurable by 'mqtt_broadcastInterval' and 'mqtt_broadcastItemsPerSec'... [Read more]

nacxoffw 29 Jan 2024 17:42

Hi! Thanks a lot about this post and the information given. I have one of this PCB with CBU chip. Here a resume about my configuration: https://obrazki.elektroda.pl/2744555700_1706546227_thumb.jpg... [Read more]

nacxoffw 30 Jan 2024 07:17

Solved!! Setting Channel 4 for gpio of configured battery send MQTT data. https://obrazki.elektroda.pl/7046929300_1706595312_thumb.jpg Data appear as unavailable in sleep time is solved after... [Read more]

crispybeken 23 Mar 2024 00:29

I've got one of these devices, too. But I can't find a template in the WebApp. Could you please post your template here? [Read more]

mcexmltv 23 Apr 2024 20:09

Newbie here, anyone could be kind and post a how to, or at least post the files. Thanks in advance. [Read more]

p.kaczmarek2 24 Apr 2024 08:55

Hello @mcexmltv , what kind of information do you need exactly? Are you asking about device configuration, or about flashing? For flashing, please see: https://github.com/openshwprojects/BK7231GUIFlashTool You... [Read more]

mcexmltv 01 May 2024 00:34

Thanks @pkaczmarek2 , finally had some time to do some research. Here is what I am looking for. I have ESPHome installed. How do I flash openBK OTA or do I have to use UART? If OTA is possible what... [Read more]

p.kaczmarek2 01 May 2024 09:35

They have OTA locked against flashing our/Tuya RBL format but someone has found a work around (converted files...): https://github.com/BenJamesAndo/OpenBeken_uf2_firmware Let me know how it works for... [Read more]

psyko_chewbacca 19 Dec 2024 03:19

Hi, where do I find this "soft_i2c" external component? I have an i2c device I'd like to interface to a bk7231n in ESPHome. Thanks! [Read more]

FAQ

TL;DR: Use OpenBeken or ESPHome deep-sleep to cut current from 15 mA to 25 µA (-99.8 %) [Bk7231N DS]. “This device must have deep sleep, otherwise it will drain batteries really, really fast” [Elektroda, p.kaczmarek2, post #20906573]

Why it matters: Correct sleep settings turn a 3-day gadget into a 6-month sensor.

Quick Facts

• MCU: Tuya BK7231N-CBU, 32-bit @120 MHz [Elektroda, dmcbeing, post #20904515] • Sensor: CHT8305, ±0.3 °C & ±2 %RH typical accuracy [CHT8305 DS] • Deep-sleep current: 20–30 µA; active Wi-Fi ≈15 mA [Bk7231N DS] • Flash size: 2 MB; OpenBeken image ≈480 kB [OpenBeken Wiki] • Best practice report interval: 15–30 min for >180 days on CR2450 [Elektroda, johnypean, post #20907778]

What pin template works for the "Blue PCB" BK7231N sensor?

Use the following mapping: P8 = BAT_Relay, P14 = Btn (inverted), P16 = LED (inverted), P20 = CHT8305_SCK, P22 = CHT8305_SDA, P23 = BAT_ADC [Elektroda, johnypean, post #20907778]

How do I enable deep sleep in OpenBeken?

  1. Add PowerSave 1 in autoexec.bat. 2. Schedule sleep: addRepeatingEventID 30 -1 1337 DeepSleep 1800 (30 min). 3. Optionally add a fail-safe: waitFor MQTTState 1 ; cancelRepeatingEvent 1337 [Elektroda, johnypean, post #20907778]

Why did one unit show –26 °C while the other was fine?

A bad I²C start-up caused corrupted bytes. Power-cycling or delaying sensor reads (delay_s 1) fixed the issue [Elektroda, dmcbeing, post #20913628]

MQTT shows no battery voltage—what’s missing?

Start the Battery driver (startDriver Battery) or map BAT_ADC to Channel 4; then publish with Battery_Setup 1000 3300 2 [Elektroda, nacxoffw, #20935801; #20922847].

Can the physical button wake the device?

BK7231N supports either timed DeepSleep or PinDeepSleep, not both at once. The current firmware lacks dual-mode, so the button cannot wake while timed sleep is active [Elektroda, johnypean, post #20907778]

Where do I find the "soft_i2c" component for ESPHome?

Clone the LibreTiny external component repository and include external_components:source: /soft_i2c. The path ships inside LibreTiny SDK used by ESPHome for BK7231N [Elektroda, dmcbeing, post #20904515]

Which flags improve Home Assistant availability?

Enable Flag 35 to deactivate avty_t and prevent “unavailable” status during sleep; keep Flag 10 for state on MQTT connect [Elektroda, johnypean, post #20907778]

How do I calibrate temperature and humidity?

Add offsets: addEventHandler OnEverySecond Temperature 0.5 increases reading by 0.5 °C; use similar for humidity. CHT8305 supports ±2 %RH factory tolerance, so trim within that window [CHT8305 DS].

What happens if Wi-Fi or MQTT fail on boot?

A repeating event can force sleep after 120 s of no MQTT. Without it, the radio stays on and battery drains in ≈48 h [Elektroda, johnypean, post #20907778]

How long will a CR2450 last at 30-minute reports?

Deep-sleep current 25 µA and a 550 mAh cell yield ≈220 days. Active bursts (15 mA for 10 s) cut this to ≈180 days—still 60× longer than no sleep [Bk7231N DS].

Edge case: what if flags calculation exceeds 32-bit?

Bit-shifting beyond 31 sets a negative or large value in 32-bit math. Use calcFlags command in OpenBeken web UI instead of manual shifts [Elektroda, dmcbeing, post #20925404]
Generated by the language model.
%}