logo elektroda
logo elektroda
X
logo elektroda

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

lars4 3750 46
ADVERTISEMENT
  • #1 21169769
    lars4
    Level 5  
    I have problems getting the values ​​out after switching to OpenBeken

    Printed circuit board with electronic components viewed from above.

    White circular device labeled Tuya Smart Air Box with Tuya, Wi-Fi, and Smart Life logos on top.

    With original firmware this is read out:
    Table with sensor values read after switching to OpenBeken.

    2 = CH2O mg/m^3, div 100
    18 = Temperature, div 10
    19 = Humidity, div 10
    21 = VOC ppm, div 10
    22 = CO2 ppm


    Autoexec.bat

    startDriver TuyaMCU
    startDriver tmSensor
    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


    After I switch to OpenBeken, this is read out
    Screenshot of a WiFi data decoding tool showing raw packets.

    Screenshot of AirBox interface showing all sensor readings at 0.00.

    Anyone have any suggestions what I have missed?
  • ADVERTISEMENT
  • #2 21169772
    divadiow
    Level 35  
    >>21169769

    at what baud did you capture original comms?

    if 115200, add tuyaMcu_setBaudRate 115200 to your autoexec
  • #3 21169777
    lars4
    Level 5  
    >>21169772

    unfortunately it doesn't help. Used 9600 as default
  • #4 21169786
    divadiow
    Level 35  
    was the CB3S removed from the PCB for flashing?

    Is there definitely continuity between the module and the pad, between the very edge of the gold contact on the module and the silver pad on PCB, eg between these dots

    CB3S module on a PCB with marked solder points.

    and then continuity onwards to the legs of the MCU it's talking to?
  • #5 21169787
    lars4
    Level 5  
    >>21169786

    No, it was not removed. No resistors had to be unsoldered either, it was still possible to flash. I have tried to flash back the original firmware and then everything works as it did before
  • #6 21169789
    divadiow
    Level 35  
    oh. what if you get rid of startDriver tmSensor
  • #7 21169796
    lars4
    Level 5  
    >>21169789

    I've tried it, it came up with different information in the serial log; unfortunately, I don't have a screenshot of it, but I can get that if needed.
  • #8 21169812
    divadiow
    Level 35  
    could do? im not sure what to suggest next.
  • ADVERTISEMENT
  • #9 21169825
    lars4
    Level 5  
    >>21169812
    without startDriver tmSensor

    Screenshot of a data packet analysis tool in hexadecimal format.
  • #10 21169837
    divadiow
    Level 35  
    oh hang on. add tuyaMcu_defWiFiState 4 under startDriver TuyaMCU
  • #11 21169842
    lars4
    Level 5  
    >>21169837

    Still no values :-(

    Screenshot of a packet decoder tool for WiFi communication.

    Autoexec.bat
    startDriver TuyaMCU
    //startDriver tmSensor
    
    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
  • Helpful post
    #12 21169855
    divadiow
    Level 35  
    I'm probably forgettng something obvious

    and if you enter command tuyaMcu_sendQueryState do you get all the current dpID statuses returned to the log?
  • #13 21169864
    lars4
    Level 5  
    >>21169855

    Now I got the values after entering the command tuyaMcu_sendQueryState Thanks!!!

    After restarting, I need to send the command again for it to display the values
  • ADVERTISEMENT
  • #15 21169869
    lars4
    Level 5  
    >>21169866

    Working autoexec.bat

    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
    

    Thanks so much for your help!
  • #16 21169896
    divadiow
    Level 35  
    no worries. is your firmware backup in credential-free state and would you mind sharing it?
  • #17 21169914
    lars4
    Level 5  
    >>21169896
    it's not in that mode, but do you still have use for it? It doesn't matter to me
  • Helpful post
    #18 21169916
    divadiow
    Level 35  
    template for device list

    Code: JSON
    Log in, to see the code


    https://github.com/OpenBekenIOT/webapp/pull/136

    Added after 1 [minutes]:

    lars4 wrote:
    it's not in that mode, but do you still have use for it? It doesn't matter to me


    only to post here and to see if there's anything else of interest from it. I would flash to my own device to see what boot log is. if you'd rather DM it me I can attempt factory reset and put fake credentials into it

    Added after 34 [minutes]:

    boot log. known patched v2.1.17 so cloudcutter no good

    Code: Text
    Log in, to see the code
  • ADVERTISEMENT
  • #19 21171036
    p.kaczmarek2
    Moderator Smart Home
    Thank you @divadiow for you activity.

    Some hints from me:
    - tmSensor is only for battery powered devices
    - tuyaMcu_sendQueryState can be send in repeating event (like every 15 seconds etc)
    - TuyaMCU baud rate can be detected from 2MB flash so there is no need to guess
    - it may be useful to enable PowerSave on this device (as on many others)

    Extra question: Is this DHT sensor of some kind? On device photo?
    Helpful post? Buy me a coffee.
  • #20 21173494
    divadiow
    Level 35  
    I wonder if it's a DHT20.

    DHT20 humidity and temperature sensor with four metal pins.

    Added after 8 [minutes]:

    How could the poster confirm apart from desoldering and trying the sensor with one of the DHT sensor driver option or just an Arduino setup?

    https://github.com/search?q=repo%3Aopenshwprojects%2FOpenBK7231T_App+dht&type=code&p=2

    DHT20 isn't mentioned but does the driver support it anyway?

    I guess if a dump of the MCU flash could be had there might be mention in there of the exact sensor
  • #21 21173538
    lars4
    Level 5  
    >>21173494

    I'll see what I can figure out. I haven't been home for a couple of days

    Added after 1 [hours] 44 [minutes]:

    >>21173494

    Yes it is a DHT20
    Close-up of an ASAIR DHT20 sensor on an electronic board.

    I can't find any information about the second sensor

    Image of a circuit board with several electronic components, including a sensor labeled BP0315-01# HMNST.

    Guess it says BP0315-01# HMNST
  • #24 21174799
    lars4
    Level 5  
    >>21174757

    Perfect, good work!
  • #26 21177061
    p.kaczmarek2
    Moderator Smart Home
    So it's DHT20 indeed. It should work well with OBK directly, without MCU:



    HGS1000, on the other hand, is not currently supported. I've checked @divadiow 's documents but I can't see any details about the communication protocol used by HGS1000 family. Maybe we would need to hook up a 10$ logic analyzer for that, like I did in some other topics: https://www.elektroda.com/rtvforum/topic4035491.html

    Added after 1 [minutes]:

    EDIT: It's UART:
    Diagram showing DHT20 and a table with pin descriptions. Fragment of technical documentation for a UART communication protocol, including a data packet structure and example code in a programming language.
    Helpful post? Buy me a coffee.
  • #27 21180371
    lars4
    Level 5  
    >>21177061

    In this case, there is no need for directly connected sensors. The values are reported correctly after the "tuyaMcu_sendQueryState" command is sent.
  • #28 21593564
    io2345
    Level 8  
    I'm thinking about an "adapted usage" of this AirBox. It should give an alarm sound when certain values are exceeded.
    To achieve that, I would connect an alarm buzzer (rated 35 mA) to one of the unused Pins of the CB3S. P8 (GPIOP_8) on Pin 13 seems to be available.

    What will I have to add in the autoexec.bat in Post#15, to set P8 to high (or low, whatever is easier), when at least one of these values are exceeded:
    - Channel 1 (temperature) is over 550 (that would be 55 degrees)
    - Channel 2 (humidity) is over 800 (80%)
    - Channel 3 (CH2O) is over 50 (0,5 mg/m3)
    - Channel 4 (VOC) is over 50 (5 ppm)
    - Channel 5 (CO2) is over 700 (700 ppm)


    For those who want to do the same: Don't connect the Buzzer directly to CB3S's IO-Pin. 35mA is too much for that. Use a simple "transitor as switch" circle instead, something like this:


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

    You can take connections from here:


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


    ===============================
    Done! Not pretty, but working:


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

    [BK7231N/CB3S] Tuya Smart Air Box Air Quality Monitor, 5 sensors
    The + Pin of the Buzzer is soldered to the 3,3V pin, the rest is "flying wiring"
  • #29 21593616
    p.kaczmarek2
    Moderator Smart Home
    Probably the simplest way would be to create a loop and check every second. The channel indexes, values and condition in sample below should be adjusted.
    
    alias ALARM_ON setChannel 10 1
    alias ALARM_OFF setChannel 10 0
    
    again:
    delay_s 1
    if $CH4==0||$CH3>50||$CH2<10 then ALARM_ON else ALARM_OFF
    goto again
    
    

    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md
    Helpful post? Buy me a coffee.
  • #30 21593801
    io2345
    Level 8  
    >>21593616 It always takes a while for my brain to catch up with you. But after some thinking I guess that the block to add at the end of the autoexec.bat should be in my case:

    alias ALARM_ON setChannel 8 1
    alias ALARM_OFF setChannel 8 0
    again:
    delay_s 10
    if $CH1>550||$CH2>800||$CH3>50||$CH4>50||$CH5>700 
    then ALARM_ON 
    else ALARM_OFF
    goto again


    and I'll have to set P8 (PWM2) for example to type "Relay" and channel 8. Or isn't that necessary at all?

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