logo elektroda
logo elektroda
X
logo elektroda

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

lars4 3222 38
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.
  • 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.
  • ADVERTISEMENT
  • #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.
  • ADVERTISEMENT
  • #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

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