Elektroda.com
Elektroda.com
X

BK7231N/CB3S Tuya generic battery powered temperature and humidity sensor with CHT8305 sensor

minusync 5979 91
  • #61
    p.kaczmarek2
    Moderator Smart Home
    minusync wrote:
    Currently, HA receives a signal about 4-6 times, but then, at least my sensor switches to safety mode and then stops transmitting any data. Such behavior has been repeatedly tested.

    Hey, do you mean that device is booting into safe mode because it had 5 reboots with uptime lower than 30 seconds?
    Then you can just change the uptime required to mark boot as safe there:
    BK7231N/CB3S Tuya generic battery powered temperature and humidity sensor with CHT8305 sensor
    BK7231N/CB3S Tuya generic battery powered temperature and humidity sensor with CHT8305 sensor
    Change to 5 seconds or something...

    Of course, that's assuming I understood you well. Does my hint solves your problem?
  • #62
    minusync
    Level 6  
    p.kaczmarek2 wrote:
    Hey, do you mean that device is booting into safe mode because it had 5 reboots with uptime lower than 30 seconds?

    The sensor goes to safety mode without any obvious errors.
    Anyway , I will test it with a smaller boot uptime value.
    BK7231N/CB3S Tuya generic battery powered temperature and humidity sensor with CHT8305 sensor
  • #63
    p.kaczmarek2
    Moderator Smart Home
    @minusync it's obvious, you are most likely doing reboot before 30 seconds uptime passes, and device detects it as boot failure.
    Please change "time required to mark boot as ok" to something smaller, 5 seconds are so
  • #64
    Kureigu
    Level 2  
    I have the same device as ionoleinic, BK7231N/CB3S with TuyaMCU and AHT20.
    I managed to do a firmware backup and flash OpenBK after cutting the output of Q1 and powering the CB3S module via my FTDI USB-UART.
    Now I have it on my local WiFi and MQTT set up, and have the autoexe.bat set up the same. However my sensors both always read 0, and never report to mqtt.
    Any help would be greatly appreciated
  • #65
    minusync
    Level 6  
    p.kaczmarek2 wrote:
    @minusync it's obvious, you are most likely doing reboot before 30 seconds uptime passes, and device detects it as boot failure.
    Please change "time required to mark boot as ok" to something smaller, 5 seconds are so


    I tested with a smaller number and now the sensor seems to work. For some reason, rounding still doesn't work all the time. Periodically it shows numbers like 21.700000000000003 C.
    I should also ask how is the situation with displaying the battery status? Are there any options to do it?

    Added after 30 [minutes]:

    Kureigu wrote:
    I have the same device as ionoleinic, BK7231N/CB3S with TuyaMCU and AHT20


    I am not actually sure that ionoleinic had AHT20 sensor, but it could be also that I missed some post.
    p.kaczmarek2 is certainly more qualified to answer that but I think that different sensors need different drivers to work. It has also happened to me that one of two completely identical sensors works, but the other simply refuses to transmit data. It could be a mistake in my own soldering or some bug that I couldn't track down. In the end I just gave up on that faulty sensor. However, as I said, the problem could be in the driver or ten other things.
    I also don't know what exactly you are using. In order for mqtt to work, you must remove the external power supply of the sensor and leave it only on the batteries. Also, if you use HomeAssistant, you need to set up the HA side yaml script.
  • #66
    Kureigu
    Level 2  
    minusync wrote:
    I am not actually sure that ionoleinic had AHT20 sensor, but it could be also that I missed some post.

    I don't think ionoleinic stated they had an AHT20 sensor. Our boards both have AHT20 SDA & SCL silkscreened on them, so hopefully the parts match the printing.

    Kureigu wrote:
    However my sensors both always read 0, and never report to mqtt.

    I do now have the Temperature and Humidity reading correctly, and can force raw or multiplied values with flags.
    With flag 19, in each roughly 80sec wake cycle the readings are published to MQTT 8 times. So I have instead implemented the following script

    Update: Humidity is still broken. Slowly climbs to 99 and stays there, despite the actual humidity being around 65. I can get it to go down again by blasting it with a hair dryer, but over about an hour it'll go back to 99.

    delay_s 15.00
    echo "Script Running"
    delay_s 0.50
    echo "Publish RH"
    publishInt Humidity $CH2
    delay_s 1.00
    echo "Publish T"
    publishFloat Temperature $CH1/10
    delay_s 10.00
    echo "Deep Sleep in 5s"
    delay_s 5.00
    echo "Deep Sleep"
    delay_s 0.65
    DeepSleep 60


    Regarding Channel 3, it appears to be for battery OK/Low, 2 indicating ok, and 1 indicating Low, this seems to happen around 2.5v
  • #67
    Xinayder
    Level 5  
    Realized I didn't post an update in some time.

    I got my new temperature and humidity sensor along with my door sensor that I bought from AliExpress (will make a teardown soon enough). However, I have the same issue I had with the previous module. I soldered the wires correctly this time (the temperature sensor has a 6-pin header so I can easily solder the wires there, and they are connected to VCC/GND/TX/RX), but after connecting the wires to my USB programmer, the GUI application on Windows would go crazy on the serial port dropdown, as if I was unplugging/plugging the programmer several times in a second. Disconnecting one of the VCC or GND wires from the module stops this behavior and the serial port shows up, but then I can't communicate to the device.

    Could this be a faulty programmer or the fact that I'm trying to run the GUI flash tool on my laptop?
  • #68
    p.kaczmarek2
    Moderator Smart Home
    @Kureigu if humidity goes up to 99, there is not much we can do. We don't have increment in our code, it must be what sensor sends. You can recheck now with latest firmware or ask @dheenhasty but it looks like a sensor issue to me.

    @Xinayder , are you using that on Windows? I have never seen such issue, maybe try with another USB to TTL dongle?
    Or wait...
    It could also mean that you have a short somewhere and the current taken by the device is too much for USB port and it resets.
    It could also happen with a large capacitor connected between 5V and GND, that's because such capacitors are taking a large inrush current just after being connected to power, and it overloads USB port briefly.

    I've been fixing that issue in the past by desoldering large electrolytic capacitors from smart device board and only in that case I was able to do power off/on cycle without USB to TTL resetting. I was not using CEN method for flashing back then.
  • #69
    Kureigu
    Level 2  
    p.kaczmarek2 wrote:
    but it looks like a sensor issue to me.

    Yes the sensor was damaged, I replaced it with another. It reads low compared to other humidity sensors that I have, but at least it now works.

    Xinayder wrote:
    Could this be a faulty programmer or the fact that I'm trying to run the GUI flash tool on my laptop?

    I don't know the specifics of your set up, but I have in the past had issues some with serial-USB configurations when a connected board is powered by two supplies (i.e. via USB-serial and a battery).
  • #70
    ionoleinic
    Level 10  
    Hi everyoane, I was busy for a time, but i am back for working on my project with these devices.Today i took my temp and hum sensor that i flashed about month ago.It worked perfectly until batteries have been discharged completely.Module entered always in AP mode, and changing the batteries didn't help.I decided to conect directly 3.3V to CB3S module, and it works, i could boot up the module.After changing another batteries, there was the same problem, and after a time, AP mode disappeared too.Then i decided to reflash the module.The flashing was succesfull, with the latest bin, but the AP didn't appear ...I desoldered the whole module, reflashed it and try to boot with direct power, but without succes.AP isn't appearing.
    Please help, i dont understand what cause this issue.
    BK7231N/CB3S Tuya generic battery powered temperature and humidity sensor with CHT8305 sensor BK7231N/CB3S Tuya generic battery powered temperature and humidity sensor with CHT8305 sensor
  • #71
    p.kaczmarek2
    Moderator Smart Home
    Please do a full 2MB backup and try "Restore RF" and if it doesn't help then full erase and fresh OBK write.
  • #72
    ionoleinic
    Level 10  
    Worked after erase all and flashing new firmware.
    Man, you are awesome.I tried about 3 hrs to solve it, and without succes, but you solved it in 3 sec.
    Thank you very much.
  • #73
    Xinayder
    Level 5  
    p.kaczmarek2 wrote:
    @Xinayder , are you using that on Windows? I have never seen such issue, maybe try with another USB to TTL dongle?
    Or wait...
    It could also mean that you have a short somewhere and the current taken by the device is too much for USB port and it resets.
    It could also happen with a large capacitor connected between 5V and GND, that's because such capacitors are taking a large inrush current just after being connected to power, and it overloads USB port briefly.

    I've been fixing that issue in the past by desoldering large electrolytic capacitors from smart device board and only in that case I was able to do power off/on cycle without USB to TTL resetting. I was not using CEN method for flashing back then.


    Yes, it was both on Windows and Linux. Could it be that I'm using a laptop running on battery and maybe there's some current limiting going on? I could try plugging it in my desktop PC which happens to have a USB 3 port which could, in theory, overcome this issue if this is what's happening.

    In either way I have been busy with IRL stuff and I'm planning on tackling this once again, I just ordered a new 3v3 USB programmer and hopefully I can shine some light on this
  • #74
    haps123
    Level 3  
    >>20374205
    I have got exactly the same device, and I am trying to reinstall firmware with OpenBK7231 firmware following elektroda or GitHub openBK7231 wikis but without success. I have got USB/UART connected to TX/RX RX/TX of the device SoC (pin 16 and 15) to RX/TX of UART. Furthermore, I am using the BK7231Flasher apps for this purpose, but I am always getting a Bus error. It does not matter if I am trying to initialize the update via resetting power or grounding CES pin. I connected SoC's VCC to 3.3V PS, but I am not sure that I need to power up also the rest of the device?
    I have tried to upload with and without powering the rest of the device but without success.
    The simple serial terminal shows that the device sends nulls, so some kind of communication exists, but the programmer cannot init the flash upload. Any troubleshooting methodology in this matter highly appreciated.
    haps
  • #75
    p.kaczmarek2
    Moderator Smart Home
    @haps123 this is TuyaMCU ddevice, did you disconnect the MCU(the chip in SOIC or QFN) from the WiFi module?

    You need to connect 3.3V directly to WiFi module 3.3V, otherwise the MCU may disconnect the WiFI module power via transistor.

    Can you post photos of your setup?

    You can also try our python tool: hid_download_py
  • #76
    haps123
    Level 3  
    Hello, @p.kaczmarek2 many thanks for prompt response, much appreciated.

    Quote:
    You need to connect 3.3V directly to WiFi module 3.3V, otherwise the MCU may disconnect the WiFI module power via transistor.
    Yes, I connected the wifi module to 3,3V


    Quote:
    [Can you post photos of your setup?

    As you can see, I am getting some message from the board, but the programmer cannot initiate update of the flash. I have disconnected power, connected CES pin to GND without success.

    BK7231N/CB3S Tuya generic battery powered temperature and humidity sensor with CHT8305 sensor BK7231N/CB3S Tuya generic battery powered temperature and humidity sensor with CHT8305 sensor BK7231N/CB3S Tuya generic battery powered temperature and humidity sensor with CHT8305 sensor

    Quote:
    You can also try our python tool: hid_download_py

    No, I will try it :)
  • #77
    p.kaczmarek2
    Moderator Smart Home
    You may have problems related to the too long wiring. Stray inductances/capacitances can interfere with flashing. We already had a case on this forum where shortening wires helped to flash CB2S.
  • #78
    haps123
    Level 3  
    I have shortened cables as much as possible but no success. Plan B, python app. :) or send it back to scam-express.
  • #79
    p.kaczmarek2
    Moderator Smart Home
    @haps123 just to be sure, you are aware that it's a TuyaMCU device? Or is it? Post a clear photo of the top of the board.

    TuyaMCU devices are using the programming port (RX1/TX1) for communication with the MCU on the board so you may need to first disconnect RX/TX traces from the MCU (cut them or temporary desolder WiFi module, or MCU) to prevent them interfering with programming.
  • #80
    haps123
    Level 3  
    I bought it as a Tuya compatible device, but I was not able to pair with the Tuya's services. The device was recognized by the Tuya app but during sync with China services, I got always time out. I have not got tools to dis-solder the Wi-Fi module, and I am not interested in it, so the toy will go to the best place for it, e.g. rubbish bin.
    Many thanks for your support.
    BK7231N/CB3S Tuya generic battery powered temperature and humidity sensor with CHT8305 sensor
  • #82
    taggbricka
    Level 5  
    BK7231N/CB3S Tuya generic battery powered temperature and humidity sensor with CHT8305 sensor
    I have this aliexpress variant of the temp and humidity sensor. Preparing to flash openbeken onto it.
    To disable the TuyaMCU, should I cut the traces at TX2 and RX2 near the TuyaMCU?
  • #83
    p.kaczmarek2
    Moderator Smart Home
    First try without cutting, but it may be necessary. You can also desolder the MCU itself if you feel comfortable with desoldering it. It all depends on your preference.

    If you want to see how we desoldered the SOIC8 chip, watch our wall switch flashing video:
    https://youtu.be/Yb3zXtBdSnE?t=160
  • #84
    taggbricka
    Level 5  
    I tried first without cutting. It crashed in the read operation three times.
    So I unsoldered the TuyaMCU, I have good desoldering equipment so it was no problem.
    I have now flashed 1.17.166 and is up and running on local WiFi.

    I will set this autoexec.bat

    startDriver tuyaMCU
    startDriver tmSensor
    linkTuyaMCUOutputToChannel 1 val 1
    setChannelType 1 Temperature_Div10
    linkTuyaMCUOutputToChannel 2 val 2
    setChannelType 2 Humidity


    Anything else I should do before remounting the TuyaMCU?

    Added after 2 [minutes]:

    This is a full 2MB dump

    Edited later

    I realise everything I asked is in the forum already.
    Found this very device in WebApp -->Config --> Devices --> Tuya TuyaMCU TH01 Generic Temperature and Humidity Sensor
    There was a link there to a forum post about this device.

    Excellent!

    I will resolder the TuyaMCU tomorrow and see what happens.
  • #85
    taggbricka
    Level 5  
    Now up and running.
    I get MQTT messages as expected with plausible values.
    At first it sends every ten minutes then after a while every hour.

    This is Node-RED style intercepts.
    Obk_Temp_Humidity/1/get : msg : Object
    { topic: "Obk_Temp_Humidity/1/get", payload: "25.000000", qos: 0, retain: false, _msgid: "9fbabe320b542e35" }
    05/07/2023, 10:48:01node: 159f25bf776abc07
    
    Obk_Temp_Humidity/2/get : msg : Object
    { topic: "Obk_Temp_Humidity/2/get", payload: "51.000000", qos: 0, retain: false, _msgid: "9b923856c9d0fbc5" }
    05/07/2023, 10:58:22node: 159f25bf776abc07
    


    As I understand it there is a third item from tuya regarding battery status.
    In the autoexec below what shall I write in the last line?

    startDriver tuyaMCU
    startDriver tmSensor
    linkTuyaMCUOutputToChannel 1 val 1
    setChannelType 1 Temperature_Div10
    linkTuyaMCUOutputToChannel 2 val 2
    setChannelType 2 Humidity
    linkTuyaMCUOutputToChannel 3 val 3
    setChannelType 3 ????????? 
  • #86
    p.kaczmarek2
    Moderator Smart Home
    I am not sure, but if it's a "Low Mid High" enumeration, then "LowMidHigh" may be a proper channel type for that.

    See available channel types:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/channelTypes.md
  • #89
    Xinayder
    Level 5  
    >>20513499

    I finally got my hands on a new programmer and it works!!!

    I managed to read the firmware from my temperature sensor, but trying to flash any of the available firmwares results in a "CRC not equal" error. (I tried both QIO and UG/UA and both T and N) I'm using the hid_download_py tool because I'm on Linux.

    The PCB for mine is CBU and I've attached the firmware read from the memory here.

    When reading the firmware from memory this is what I got in my console:

    CRC should be 664c13c9
    CRC is 4a280325

    anyways, the firmware is attached, I couldn't unpack it because it couldn't find "encrypt" on my PC.

    EDIT: I was able to flash with the Windows tool. Device works, I loaded the config from the generic Tuya temperature and humidity sensor with a SHT30 IC.

    I also attached the config from the windows app.