logo elektroda
logo elektroda
X
logo elektroda

[BK7231N/CB3S] Tuya Smart Air Box Air Quality Monitor, 5 sensors

lars4 4242 47
ADVERTISEMENT
  • #31 21595031
    p.kaczmarek2
    Moderator Smart Home
    Just like our docs says:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/README.md
    setChannel sets given channel to given value, so it will not affect P8 directly if you don't set P8 role and channel, you need to assign a channel to P8 and also set it to Relay (or Rel_n, or LED, or LED_n, etc), in this case, channel 8, but in reality it can be any channel ...
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #32 21595589
    io2345
    Level 8  
    >>21595031 Surprisingly enough: Not working. This is the autoexec.bat:

    tuyaMcu_defWiFiState 4
    tuyaMcu_setBaudRate 9600
    setChannelType 1 Temperature_div10
    linkTuyaMCUOutputToChannel 18 val 1
    setChannelType 2 Humidity_div10
    linkTuyaMCUOutputToChannel 19 val 2
    setChannelType 3 Custom
    SetChannelLabel 3 CH2O mg/m^3
    linkTuyaMCUOutputToChannel 2 val 3
    setChannelType 4 Custom
    SetChannelLabel 4 VOC ppm
    linkTuyaMCUOutputToChannel 21 val 4
    setChannelType 5 Custom
    SetChannelLabel 5 CO2 ppm
    linkTuyaMCUOutputToChannel 22 val 5
    tuyaMcu_sendQueryState
    
    alias ALARM_ON setChannel 8 1
    alias ALARM_OFF setChannel 8 0
    again:
    
    delay_s 5
    if $CH1>265
    then ALARM_ON 
    else ALARM_OFF
    goto again
    

    Channel 8 (for IO 8) is set as LED, but doesn't change when the value of 265 is exceeded (more than 26,5°C) . When toggled manually from the Webpage, there is power on IO 8.

    Startup commands are:

    backlog startdriver tuyamcu
    PowerSave 1



    I tried using IO 20 instead of 8 and type relay instead of LED,without success.
  • #33 21595612
    p.kaczmarek2
    Moderator Smart Home
    We do not have multiline if else syntax.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #34 21595628
    io2345
    Level 8  
    >>21595612 Thank you for your fast response. Now it's working fine!

    For all others out there who are noobs like me: The autoexec.bat is now

    startDriver TuyaMCU
    tuyaMcu_defWiFiState 4
    tuyaMcu_setBaudRate 9600
    setChannelType 1 Temperature_div10
    linkTuyaMCUOutputToChannel 18 val 1
    setChannelType 2 Humidity_div10
    linkTuyaMCUOutputToChannel 19 val 2
    setChannelType 3 Custom
    SetChannelLabel 3 CH2O mg/m^3
    linkTuyaMCUOutputToChannel 2 val 3
    setChannelType 4 Custom
    SetChannelLabel 4 VOC ppm
    linkTuyaMCUOutputToChannel 21 val 4
    setChannelType 5 Custom
    SetChannelLabel 5 CO2 ppm
    linkTuyaMCUOutputToChannel 22 val 5
    tuyaMcu_sendQueryState
    alias ALARM_ON setChannel 8 1
    alias ALARM_OFF setChannel 8 0
    again:
    delay_s 10
    if $CH1>580||$CH2>890||$CH3>50||$CH4>200||$CH5>1200 then ALARM_ON else ALARM_OFF
    goto again
  • #35 21600458
    io2345
    Level 8  
    >>21595612 One problem still: When powering on the device, all values are zero - and stay on zero until I press the restart button on the webpage. The restart takes quite long (53 seconds), but then all values are ok.
    How can I get the device to report the correct readings instantly?
    About the config: Autoexec.bat in Post #34, Startup commands in Post # 32, Flags 10 + 19 are set.
  • #36 21629226
    io2345
    Level 8  
    >>21600458 Can this be fixed? It's not a big deal - but if there is a power outage, I probably will not remember it in a year or so. So it would be better, if device starts without issue.
  • #37 21629426
    p.kaczmarek2
    Moderator Smart Home
    Maybe just use setStartValue [channel] -1 to remember those values between reboots?
    Helpful post? Buy me a coffee.
  • #38 21629713
    io2345
    Level 8  
    >>21629426 I have this in autoexec.bat:

    tuyaMcu_defWiFiState 4
    tuyaMcu_setBaudRate 9600
    setChannelType 1 Temperature_div10
    linkTuyaMCUOutputToChannel 18 val 1
    setChannelType 2 Humidity_div10
    linkTuyaMCUOutputToChannel 19 val 2
    setChannelType 3 Custom
    SetChannelLabel 3 CH2O mg/m^3
    linkTuyaMCUOutputToChannel 2 val 3
    setChannelType 4 Custom
    SetChannelLabel 4 VOC ppm
    linkTuyaMCUOutputToChannel 21 val 4
    setChannelType 5 Custom
    SetChannelLabel 5 CO2 ppm
    linkTuyaMCUOutputToChannel 22 val 5
    tuyaMcu_sendQueryState
    alias ALARM_ON setChannel 8 1
    alias ALARM_OFF setChannel 8 0
    again:
    delay_s 10
    if $CH1>580||$CH2>890||$CH3>50||$CH4>200||$CH5>1200 then ALARM_ON else ALARM_OFF
    goto again


    Will I have to set "setStartValue [channel] -1" only for self-defined channels 1 to 5, or also for 2, 18-19 and 21-22 (these five are MCUoutput)? Saying this I notice now, that the value 2 is existing two times: as MCUoutput channel and as self defined channel. I guess that this isn't clever, right?
    What about channel 8? Needs "setStartValue" as well?
  • #39 21636330
    kevinkorowin
    Level 1  
    Hello

    is it possible to add a battery on the board
    ?with tp4056 and 18650 battery ?

    Thanks
  • ADVERTISEMENT
  • #40 21655487
    ngocnguyenme
    Level 4  
    >>21169869 Thank you so much. I was able to get my air box to show all values. But every time when I reboot the device (plug out and in), then I have to run the autoexec.bat manually to get all values to be shown again. How can I configure to run this script automatically at boot? Sorry, if my question sounds a bit silly. I am a total newbie to this custom fw stuff. Thanks in advance
  • #41 21655497
    p.kaczmarek2
    Moderator Smart Home
    How do you save autoexec.bat?

    The correct way:


    Helpful post? Buy me a coffee.
  • #42 21655612
    ppikart
    Level 1  
    Just because it's the only online discussion I can find about this sensor:

    Does anyone know how it dares to report a CO2-Value? Is it just the output of the VOC-sensor that is calculated into a CO2, VOC and formaldehyde-value?
  • #43 21655666
    ngocnguyenme
    Level 4  
    >>21655497 that already done, but I still get this after physically rebooting the device

    AirQualBox1 device interface screen with technical data and control buttons.
  • #44 21655679
    p.kaczmarek2
    Moderator Smart Home
    How your autoexec.bat looks like?

    Maybe you need to add a state query after startup, but probably not, that's tmSensor device.

    Simple work-around could also work - use low channels number for variables and then in configure startup set them to -1, to the value is kept between reboots.
    Helpful post? Buy me a coffee.
  • #45 21656298
    ngocnguyenme
    Level 4  
    >>21655679 I just copied from >>21169869, nothing changed. I really don't know how to start with "low channels number"? Could you explain it further please!
  • #46 21694892
    ngocnguyenme
    Level 4  
    Does someone still have a backup of the original fw (bin file)? If yes, please share it! I lost mine. I want to flash my airbox with esphome to utilise some spare pins for other purposes (ir control for example). Now I don't know to change from openbeken to esphome without a backup of the original fw. Any help is appreciated!
  • ADVERTISEMENT
  • #47 21694989
    p.kaczmarek2
    Moderator Smart Home
    ngocnguyenme wrote:
    really don't know how to start with "low channels number"?

    Like with channels 1, 2, 3, 4 etc not 40, 45, 50. And then you can use setStartValue 1 -1 to make channel 1 remember state between reboots. The same for channel 2, 3, 4, etc. If that's what's the problem?

    OBK has IR driver I think.

    Added after 1 [minutes]:

    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    Helpful post? Buy me a coffee.
  • #48 21699862
    ngocnguyenme
    Level 4  
    >>21694989 I've just switched to ESPHome to utilise some free pins for other purposes and it's working fine now. Thanks again :)

Topic summary

The discussion addresses issues with reading sensor values from the Tuya Smart Air Box Air Quality Monitor (BK7231N/CB3S) after switching to OpenBeken firmware. The original firmware correctly outputs sensor data including CH2O, temperature, humidity, VOC, and CO2 via specific data points (DPIDs). Initial troubleshooting involved verifying baud rates (default 9600), module connection integrity, and driver configurations in autoexec.bat. The key solution was to send the command "tuyaMcu_sendQueryState" after startup to retrieve sensor values, as values do not appear automatically on reboot. The working autoexec.bat includes starting the TuyaMCU driver, setting WiFi state, baud rate, defining channel types and labels, linking DPIDs to channels, and issuing the query state command. Further discussion identified the temperature/humidity sensor as a DHT20 and the VOC sensor as an HGS1000 from Hefei Micro Nano Sensing Technology Co. Ltd (HMNST), which uses UART communication but lacks direct OpenBeken support. Suggestions included periodic sending of the query state command and enabling power-saving modes. An additional topic explored adding an alarm buzzer on GPIO P8 (Pin 13) triggered by threshold exceedances on sensor channels, implemented via autoexec.bat scripting with conditional loops and channel control commands. The conversation also referenced firmware backup sharing and device templates for integration.
Summary generated by the language model.
ADVERTISEMENT