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]
Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tam
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"
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.
• 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]
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]delay_s 1) fixed the issue [Elektroda, dmcbeing, post #20913628]startDriver Battery) or map BAT_ADC to Channel 4; then publish with Battery_Setup 1000 3300 2 [Elektroda, nacxoffw, #20935801; #20922847].external_components: → source: /soft_i2c. The path ships inside LibreTiny SDK used by ESPHome for BK7231N [Elektroda, dmcbeing, post #20904515]avty_t and prevent “unavailable” status during sleep; keep Flag 10 for state on MQTT connect [Elektroda, johnypean, post #20907778]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].calcFlags command in OpenBeken web UI instead of manual shifts [Elektroda, dmcbeing, post #20925404]
Comments
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]
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]
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]
Are the device configs the same? Is the device hardware the same for both devices? [Read more]
Yes, I copied and pasted all settings and autoexec.bat from the first device I flashed that reports correct values. [Read more]
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]
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]
@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]
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]
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]
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]
Newbie here, anyone could be kind and post a how to, or at least post the files. Thanks in advance. [Read more]
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]
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]
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]
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]