logo elektroda
logo elektroda
X
logo elektroda

[BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module

DeDaMrAz 8076 57
ADVERTISEMENT
  • Helpful post

    CBU pin mapping for CHT8305 and GN6932

    #1 20535534
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    Here is another device with Tuya CBU module, here is the AliExpress listing for it - https://shorturl.at/sJVZ6

    It is based around CHT8305 sensor but it has a GN6932 a multi 7 segment display driver.

    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module

    This is a fast teardown with some basic info, more to come soon. Also attached is the dump from the working device if that is of any help and datasheet for that LED driver.

    EDIT:
    To make the temp sensor working in the config menu set:

    CHT pin 1 (SDA) -> CBU pin 4 (P22)
    CHT pin 6 (SCL) -> CBU pin 3 (P20)

    Led driver configuration:

    LED driver pin 6 (DIN) -> CBU pin 21 (P15)
    LED driver pin 7 (CLK) -> CBU pin 20 (P17)
    Led Driver pin 8 (STB) -> CBU pin 17 (P28)

    Button configuration:

    Button -> CBU pin 1 (P14)

    EDIT: added AliExpress listing.
    Attachments:
    • GN-Semic-GN6932_C265476.pdf (554.82 KB) You must be logged in to download this attachment.
    • readResult_BK7231N_QIO_2023-11-4--22-47-16.bin (2 MB) You must be logged in to download this attachment.
  • ADVERTISEMENT
  • #2 20535550
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    Here is the capture from the cold boot from PulseView (aka Sigrok) from the 3 data lines, DIN, CLK and STB.

    6 DIN Data Input Serial data input on clock rising edge, low bit first.
    7 CLK Clock input Input/output serial data on the rising edge of the clock
    8 STB Chip select Initializes serial interface on rising or falling edge
    Attachments:
    • cold boot org FW.rar (19.62 KB) You must be logged in to download this attachment.
  • GN6932 LED driver datasheet translation

    #3 20535551
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    Just a quick translation from the datasheet of the LED driver:

    GN6932 is a special circuit for LED (Light Emitting Diode Display) drive control, which integrates MCU digital interface, data lock
    memory, LED high voltage drive. This product has excellent performance and reliable quality. Mainly used in multi-segment display driver.
    Its main features are as follows:
    ● Using power CMOS technology
    ● Display mode (8 segments×16 bits)
    ● Brightness adjustment circuit (8-level adjustable duty cycle)
    ● Serial interface (CLK, STB, DIN)
    ● Oscillation mode: RC oscillation (450KHz±5%)
    ● Built-in power-on reset circuit
    ● Package form: SOP32
  • ADVERTISEMENT
  • #4 20535569
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14756
    Help: 659
    Rate: 12883
    This is a very interesting device. I'd rather expect it to be TuyaMCU based, but it doesn't look like it. Are you able to check where is the CHT8305 connected?

    CHT8305 driver is already in OpenBeken, is it working on this device well?

    The 2MB backup can be restored anytime, although for the new flash tool you may need to rename the dump and put it into the "firmware" directory.
    Helpful post? Buy me a coffee.
  • CHT8305 wiring and backup restore confirmed

    #5 20535581
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    p.kaczmarek2 wrote:
    This is a very interesting device. I'd rather expect it to be TuyaMCU based, but it doesn't look like it. Are you able to check where is the CHT8305 connected?

    CHT8305 driver is already in OpenBeken, is it working on this device well?

    The 2MB backup can be restored anytime, although for the new flash tool you may need to rename the dump and put it into the "firmware" directory.


    Yes I can:

    CHT pin 1 (SDA) -> CBU pin 4 (P22)
    CHT pin 6 (SCL) -> CBU pin 3 (P20)
    Alert pin is NC(?!?)
    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module

    And the CHT is working,

    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module

    Added after 14 [minutes]:

    Just to confirm renamed backup written and working.

    In my case I renamed it to OpenBK7231N_QIO_1.15.xxx and the flasher did write and device is in the original state.

    BTW consider adding backup naming and writing option to flasher.
  • #6 20535591
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14756
    Help: 659
    Rate: 12883
    That's good news. So we need a GN6932 driver.
    Here's an English translation of GN6932 datasheet:
    GN-Semic-G...-CN.en.pdf (841.94 kB)You must be logged in to download this attachment.

    Maybe we could use previous drivers as a reference and write a new one:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/src/driver/drv_tm1637.c
    https://github.com/openshwprojects/OpenBK7231...p/blob/main/src/driver/drv_max72xx_internal.c
    Helpful post? Buy me a coffee.
  • #7 20535593
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    I can provide you with the HW info that you need as the SW is the more time consuming for me (because work), as you can notice I write usually after midnight :)

    I'll update the first post for CHT config and if you need anything more from me let me know.
  • ADVERTISEMENT
  • #8 20535610
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14756
    Help: 659
    Rate: 12883
    Which GPIO are used for GN6932?

    I will give you the initial test code tomorrow so we can check if the GN6932 reacts in any way.
    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
    I haven't looked at your capture yet, only datasheet.
    Helpful post? Buy me a coffee.
  • CBU pin mapping to GN69320 SPI signals

    #9 20535616
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    CBU P15 -> DIN (GN69320)
    CBU P17 -> CLK (GN69320)
    CBU P28 -> STB (GN69320)

    As I understand DIN is the data sent from CBU, STB is something like chipselects pin, everything else I would have to read the datasheet a bit better.

    Added after 2 [minutes]:

    From Tuya datasheet:

    20 P17 I/O Common GPIO, which can be reused as SPI_MISO (Correspond to Pin 14 of the IC)
    21 P15 I/O Common GPIO, which can be reused as SPI_CS (Correspond to Pin 13 of the IC)

    I'll try tomorrow to get some captures form logic analyzer and parse data as SPI and give you the results.
  • GN6932 command sequence and multi-byte write protocol

    #10 20535619
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14756
    Help: 659
    Rate: 12883
    Thank you, the basic protocol is the following:
    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
    Code: C / C++
    Log in, to see the code

    but one can write multiple bytes if STB does not go high:
    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
    Code: C / C++
    Log in, to see the code


    The flowchart requires sending 3 commands: setup command, cmd +data, turn on command.
    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
    first setup command, single byte, 0x40 is 100 0000:
    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
    Second command has multiple bytes, it's address command + data bytes:
    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
    0b1100 0000 is 0xC0.
    Third command is 0x8F which is 1000 1111:
    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
    Here is what I come up so far:
    Code: C / C++
    Log in, to see the code



    I will push it to the source in the morning so you can get binaries and test. Curent version just sends random segments data.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • Logic analyzer capture decoded as MAX7219 data

    #11 20535915
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    Some more info from observing the HW, which can possibly influence the data format set.

    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module

    Added after 12 [minutes]:

    The data sheet and the data transfer on the board corelate, but configuration depending not all bytes (my guess GRID registers) are used.

    Here is the short snippet of the data capture from the logic analyzer and decoded as MAX7219. You can load the previously attached capture into PulseView and have a clearer picture about the data transfer structure that is based on this specific configuration.
    Attachments:
    • test.txt (579.08 KB) You must be logged in to download this attachment.
  • Bit order swapped in SPI display commands

    #12 20535970
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14756
    Help: 659
    Rate: 12883
    I haven't loaded it yet, but your text file looks very interesting.

    But it seems that bit order is swapped!

    There is basically that:
    
    17130098-17130262 SPI: MOSI transfers: 02
    17130279-17132867 SPI: MOSI transfers: 03 66 60 DA F2 60 FC FC FC 60 F1 C0 00 00 00 00 00
    17132885-17133038 SPI: MOSI transfers: F1
    

    0x02 is a first command. It sets the normal mode and auto increment.
    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
    This fragment:
    
    17130279-17132867 SPI: MOSI transfers: 03 66 60 DA F2 60 FC FC FC 60 F1 C0 00 00 00 00 00
    

    it's first 0x03, the address setting, it sets address 0x00
    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
    The next part of the data is the segments/grids data. They are using auto address increment and set all in one batch, within single STB tick.
    The last part is that:
    
    17132885-17133038 SPI: MOSI transfers: F1
    

    0xF1 hex is binary 1111 0001, but as I said, you have swapped endiannes, so it is in fact this:
    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
    It sets the brightness and enables the display.

    Your packet dumps are very helpful, I will try to push the test driver code to repository today so you can flash OBK and try it. For the start, we will set random segments.
    Helpful post? Buy me a coffee.
  • #13 20536000
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    Sorry that decoding was done as MSB-first, I changed to LSB-first and the message is clear.

    40
    C0 66 3F 5B 6D 6F 3F 3F 3F 3F 8F 0F 00 00 00 00 00
    8F

    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
  • GN6932 test driver and pin mapping added

    #14 20536026
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14756
    Help: 659
    Rate: 12883
    Suprisingly enough, it matches well what I've written yesterday, just by basing on the datasheet:
    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module

    Ok, I will push that test driver in a hour or two, I am looking into door sensors protocol now:
    https://www.elektroda.com/rtvforum/topic3937723-90.html#20535974

    Added after 55 [minutes]:

    This protocol looks the same as TM1637, except the addition of the STB pin and lack of the ACK. One could say that GN6932 is SPI version of TM1637 ?

    Anyway, I added test code:
    https://github.com/openshwprojects/OpenBK7231...mmit/0b8a78fa2b6420cf1a2af3cc629b15c603681c97
    It assumes pin indices:
    
    int g_clk = 17;
    int g_stb = 28;
    int g_din = 15;
    

    Usage:
    1. enter command startDriver GN6932
    2. enter command GN6932_TestAddressIncreaseMode , random segments should lit up.
    Helpful post? Buy me a coffee.
  • GN6932 command changes bus pattern; byte order corrected

    #15 20536357
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    It does work, there is a changing pattern with every GN6932_TestAddressIncreaseMode command, here is the analyzer screenshot (sorry decoding is wrong by my mistake it is MSB first should be the other way around)

    tested with 680 build.

    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module

    EDIT:
    corrected byte order

    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
  • #16 20536367
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14756
    Help: 659
    Rate: 12883
    For anyone reading, here's the code from example above:
    https://github.com/openshwprojects/OpenBK7231...mmit/6ed64af07cef12ebb25cf6b8a83497b02c730f99
    https://github.com/openshwprojects/OpenBK7231...cf6b8a83497b02c730f99/src/driver/drv_gn6932.c

    I will add ability to change dimmer level (3 bits can determine brightness) soon.
    Helpful post? Buy me a coffee.
  • #17 20536418
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    Brightness control does work!

    Build 681

    Enter in command line:

    1) GN6932_TestAddressIncreaseMode
    2) GN6932_Dimmer 1 3 - syntax is GN6932_Dimmer [bOn] [brightness], (bOn is 0 for OFF and 1 for ON, brightness level 0-7)
    3) GN6932_TestAddressIncreaseMode - to apply changes (also lit characters will change)
  • Merged TM1637 and GN6932 driver with test commands

    #18 20536515
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14756
    Help: 659
    Rate: 12883
    I have pushed merged TM1637 + GN6932 driver.
    https://github.com/openshwprojects/OpenBK7231...mmit/3b25aee97370775559e279f879bb016c0f1304fd
    It currently uses your pins by default.
    
    		i2c.pin_clk = 17;// PIN_FindPinIndexForRole(IOR_TM1637_CLK, 16);
    		i2c.pin_data = 15;// PIN_FindPinIndexForRole(IOR_TM1637_DIO, 14);
    		i2c.pin_stb = 28;// PIN_FindPinIndexForRole(IOR_TM1637_DIO, 14);
    

    (yes, I know, that's not I2C...)

    usage:
    1. start and try to print something:
    
    backlog startDriver GN6932 ; TMGN_Print 0 0 123456
    // NOTE: TMGN_Print [Ofs] [MaxLen]
    // If MaxLen=0, then no lenght limit
    

    Is it printing anything?

    2. check brightness changes:
    
    backlog TMGN_Brightness 5; TMGN_Print 0 0 123456
    // NOTE: TMGN_Brightness [Brightness0to8] [bOn]
    // The bOn is optional, default is 1
    
    
    backlog TMGN_Brightness 2; TMGN_Print 0 0 123456
    
    
    backlog TMGN_Brightness 7; TMGN_Print 0 0 123456
    

    Are they working?


    3. try to create character codes
    
    TMGN_Char 0x00 123
    // Note: TMGN_Char CharIndex CharCode
    

    This is 7 segment display, I assume.
    So we can display: 0, 1, 2, etc etc 9, A, B, C, etc F.
    But we need to know which segments are displayed for each letter.
    That function can set code for given index.
    For example, TMGN_Char 0 123 sets code for 0.
    The TMGN_Char 10 33 sets code for A (A is 10)
    etc etc.

    You can play around it by:
    - first use TMGN_Char 0 33 , replace 33 with anything
    - then use TMGN_Print 0 0 00000 - does it print proper 0?

    You can also do a tricky way and just use character codes from your capture
    
    40
    C0 66 3F 5B 6D 6F 3F 3F 3F 3F 8F 0F 00 00 00 00 00
    8F
    

    ok so 3F most likely is 0 here? What was the display showing when you captured that data?
    Try:
    
    TMGN_Char 0 0x3F
    TMGN_Print 0 0 00000 - does it print proper 0?
    
    Helpful post? Buy me a coffee.
  • #20 20537108
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14756
    Help: 659
    Rate: 12883
    Following script should work with both GN6932 and TM1637 and create a simple clock.
    
    //startDriver GN6932
    startDriver TM1637
    startDriver NTP
    TMGN_Clear
    
    again:
    // TMGN_Print  offset len value bPadToLenWithZeros
    TMGN_Print 4 2 $second 1
    TMGN_Print 2 2 $minute 1
    TMGN_Print 0 2 $hour 1
    delay_s 0.1
    goto again
    
    Helpful post? Buy me a coffee.
  • Working GN6932/TM1637 clock script and grid mapping

    #21 20537116
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    p.kaczmarek2 wrote:
    Following script should work with both GN6932 and TM1637 and create a simple clock.
    
    //startDriver GN6932
    startDriver TM1637
    startDriver NTP
    //edit for your time zone
    //ntp_timeZoneOfs  +2:00 
    TMGN_Clear
    
    again:
    // TMGN_Print  offset len value bPadToLenWithZeros
    TMGN_Print 4 2 $second 1
    TMGN_Print 2 2 $minute 1
    TMGN_Print 0 2 $hour 1
    delay_s 0.1
    goto again
    


    Build 688.
    Just to confirm, this is the script that is working for the clock (refer to previous picture explaining GRID placement index starts from 0-8 not 1-9) and seconds are where humidity should be (GRID1 or index 0) for now.

    //startDriver GN6932
    startDriver TM1637
    startDriver NTP
    TMGN_Clear

    again:
    // TMGN_Print offset len value bPadToLenWithZeros
    //GRID1_2digits_seconds
    TMGN_Print 0 2 $second 1
    //GRID8_2digits_minutes
    TMGN_Print 7 2 $minute 1
    //GRID6_2digits_hours
    TMGN_Print 5 2 $hour 1
    delay_s 0.1
    goto again

    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
  • TMGN_Print can map channel values to display

    #22 20537575
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14756
    Help: 659
    Rate: 12883
    We can use the same approach to map any values from channels to the display. For example, if channel 1 is humidity, then you should be able to do:
    
    TMGN_Print 7 2 $CH1 1
    

    I am not sure about the scaled values yet. This is because we may have a temperature value like 21.5C stored as 215... I will think about it, but maybe it will just work as is.

    I am attaching a C source code for hybrid TM1263/GN6932 driver.
    drv_tm_gn_...230412.zip (3.26 kB)You must be logged in to download this attachment.
    Helpful post? Buy me a coffee.
  • Working GN6932 autoexec script for BK7321N display

    #23 20537716
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    Got it working, that approach worked. Here is the pictures and the script that worked for me. All that is left is the always on LED's.

    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module

    Script that works for me now on build 688.

     startDriver GN6932
    startDriver NTP
    ntp_timeZoneOfs  +2:00
    TMGN_Clear
    
    again:
    // TMGN_Print  offset len value bPadToLenWithZeros
    //TMGN_Print 0 2 $second 1
    TMGN_Print 7 2 $minute 1
    TMGN_Print 5 2 $hour 1
    TMGN_Print 2 3 $CH1 1
    TMGN_Print 0 2 $CH0 1
    delay_s 0.1
    goto again 


    EDIT: confirmed working with Build 691.

    Added after 1 [hours] 36 [minutes]:

    To conclude this is the working script, I created autoexec.bat and it works as intended.

     startDriver GN6932
    startDriver NTP
    ntp_timeZoneOfs  +2:00
    TMGN_Clear
    //adjust brightness if needed (0-7) - default is 7
    TMGN_Brightness 7
    TMGN_SetBit 9 1 1
    TMGN_SetBit 9 2 1
    TMGN_SetBit 9 3 1
    TMGN_SetBit 9 7 1
    TMGN_SetBit 9 0 1
    TMGN_SetBit 10 2 1
    TMGN_SetBit 10 3 1
    
    again:
    // TMGN_Print  offset len value bPadToLenWithZeros
    //TMGN_Print 0 2 $second 1
    TMGN_Print 7 2 $minute 1
    TMGN_Print 5 2 $hour 1
    TMGN_Print 2 3 $CH1 1
    TMGN_Print 0 2 $CH0 1
    delay_s 0.1
    //blinking : on the clock
    TMGN_SetBit 10 0 0
    TMGN_SetBit 10 1 0
    delay_s 1
    TMGN_SetBit 10 0 1
    TMGN_SetBit 10 1 1
    delay_s 1
    goto again 


    And a picture to prove it :)

    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
  • #24 20537859
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14756
    Help: 659
    Rate: 12883
    Very nice progress! This device seems almost fully supported.

    We could try to convert C to F somehow. Maybe use extra channel as a variable. Is temperature in channel 0?
    
    setChannel 10 $CH0*1.8+32
    TMGN_Print 0 2 $CH10 1
    

    Math expressions are supported already, but we also would need to support that extra '1' digit first? Or maybe not... 100F is not a common temperature.
    Helpful post? Buy me a coffee.
  • Script for 100°F display limit and °C conversion

    #25 20537947
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    This script works up to 100'F, there is also a provision to convert to 'C in the script. Measurement above 100'F requires some logic and multiple changes to work due to current temp reading (without decimal point). Attached are the scripts that you can load to your device.

     startDriver GN6932
    startDriver NTP
    ntp_timeZoneOfs  +2:00
    TMGN_Clear
    //adjust brightness if needed (0-7) - default is 7
    TMGN_Brightness 7
    TMGN_SetBit 9 1 1
    TMGN_SetBit 9 2 1
    TMGN_SetBit 9 3 1
    TMGN_SetBit 9 7 1
    TMGN_SetBit 9 0 1
    TMGN_SetBit 10 2 1
    TMGN_SetBit 10 3 1
    
    again:
    // TMGN_Print  offset len value bPadToLenWithZeros
    //TMGN_Print 0 2 $second 1
    TMGN_Print 7 2 $minute 1
    TMGN_Print 5 2 $hour 1
    //TMGN_Print 2 3 $CH1 1
    //comment upper one line and uncomment the next 4 linet to convert to F and vice versa for C
    setChannel 10 $CH1*1.8+320
    TMGN_Print 2 3 $CH10 1
    TMGN_SetBit 9 7 0
    TMGN_SetBit 9 4 1
    TMGN_Print 0 2 $CH0 1
    delay_s 0.1
    //blinking : on the clock
    TMGN_SetBit 10 0 0
    TMGN_SetBit 10 1 0
    delay_s 1
    TMGN_SetBit 10 0 1
    TMGN_SetBit 10 1 1
    delay_s 1
    goto again 
    Attachments:
    • files.tar (10 KB) You must be logged in to download this attachment.
  • #26 20539367
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    It would be good if somebody else can confirm this but I noticed that the CHT sensors are having +2'C offset on them - on at least 3 converted devices. Here is a picture of temperature comparison after more then 3 hours of measurements and stabilizing (k Type probe is inside the housing very close to the CHT)

    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
  • #27 20539472
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14756
    Help: 659
    Rate: 12883
    It seems that the driver contributor, @dheenhasty , has added a calibrate function already:
    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
    SHT_Calibrate
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    Helpful post? Buy me a coffee.
  • SHT_Calibrate not supported on CHT8305 sensor

    #28 20539486
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    p.kaczmarek2 wrote:
    It seems that the driver contributor, @dheenhasty , has added a calibrate function already:
    [BK7321N] Generic USB powered thermostat and humidity sensor with LED display - CBU module
    SHT_Calibrate
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md


    That command doesn't work on CHT8305 :) tried already

    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:27.354543C Humidity:19.824522%
    Info:MAIN:Time 87358, idle 184978/s, free 73208, MQTT 0(5460), bWifi 1, secondsWithNoPing 1, socks 2/38 
    Error:CMD:cmd SHT_Calibrate NOT found (args -2 10)
    Info:CMD:[WebApp Cmd 'SHT_Calibrate -2 10' Result] Unknown command
    Info:GEN:CHANNEL_Set channel 1 has changed to 274 (flags 0)


    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:27.384756C Humidity:19.848936%
    Info:MAIN:Time 87447, idle 186866/s, free 61512, MQTT 0(5465), bWifi 1, secondsWithNoPing 1, socks 3/38 
    Error:CMD:cmd SHT3X_Calibrate NOT found (args -2 10)
    Info:CMD:[WebApp Cmd 'SHT3X_Calibrate -2 10' Result] Unknown command
    Info:GEN:No change in channel 1 (still set to 273) - ignoring
  • Helpful post
    #29 20539583
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14756
    Help: 659
    Rate: 12883
    I will add a calibration function today. I confused drivers. CHT8305 indeed lacks calibration.
    Helpful post? Buy me a coffee.
  • CHT_Calibrate working with temperature and humidity offsets

    #30 20539841
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    Build 701, CHT_Calibrate is working!!! :)

    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:27.505607C Humidity:17.523460%
    Info:MAIN:Time 101, idle 181167/s, free 72976, MQTT 0(6), bWifi 1, secondsWithNoPing 1, socks 2/38 
    Info:SENSOR:Calibrate SHT: Calibration done temp -2.000000 and humidity 10.000000 
    Info:CMD:[WebApp Cmd 'CHT_Calibrate -2 10' Result] OK
    Info:GEN:CHANNEL_Set channel 1 has changed to 255 (flags 0)


    this is the final script with everything working (for me)

    startDriver GN6932
    startDriver NTP
    ntp_timeZoneOfs  +2:00
    //check the reading of you sensor against a good known and calibrate in this case -2
    CHT_Calibrate -2 10 
    TMGN_Clear
    //adjust brightness if needed (0-7) - default is 7 max
    TMGN_Brightness 7
    TMGN_SetBit 9 1 1
    TMGN_SetBit 9 2 1
    TMGN_SetBit 9 3 1
    TMGN_SetBit 9 7 1
    TMGN_SetBit 9 0 1
    TMGN_SetBit 10 2 1
    TMGN_SetBit 10 3 1
    
    again:
    // TMGN_Print  offset len value bPadToLenWithZeros
    //TMGN_Print 0 2 $second 1
    TMGN_Print 7 2 $minute 1
    TMGN_Print 5 2 $hour 1
    TMGN_Print 2 3 $CH1 1
    TMGN_Print 0 2 $CH0 1
    delay_s 0.1
    //blinking : on the clock
    TMGN_SetBit 10 0 0
    TMGN_SetBit 10 1 0
    delay_s 1
    TMGN_SetBit 10 0 1
    TMGN_SetBit 10 1 1
    delay_s 1
    goto again


    For other users syntax is:
    CHT_calibrate [+/- temperature value] [+/- humidity value] you can omit + symbol as that is the default so:
    CHT_calibrate -2 10 = change temp-2 and humidity+10 in this case.
    (SHT_Calibrate works exactly the same)

    Attached are the files that you can uplaod to your LFS
    Attachments:
    • files_final.tar (10 KB) You must be logged in to download this attachment.

Topic summary

LABEL_AI_GENERATED
The discussion focuses on a generic USB-powered thermostat and humidity sensor device based on the Tuya CBU module, featuring a CHT8305 sensor and a GN6932 multi 7-segment LED display driver. Detailed hardware pin mappings were established: CHT8305 SDA to CBU P22, SCL to CBU P20; GN6932 DIN to CBU P15, CLK to P17, and STB to P28. The GN6932 driver was reverse-engineered, revealing it as a serial interface LED driver with 8-level brightness control and SPI-like communication, similar to TM1637 but with an added STB pin and no ACK. A test driver and example scripts were developed and integrated into the OpenBK7231T firmware, enabling display of temperature, humidity, and time with brightness adjustment and segment control via commands like TMGN_Print and TMGN_SetBit. Calibration for the CHT8305 sensor was initially missing but later implemented, allowing temperature offset correction. Newer device models reportedly use the CHT8310 sensor, which is similar but requires updated drivers. Firmware builds sometimes disable the GN6932 driver due to flash size constraints, requiring manual enabling in the configuration. Users shared scripts for clock display and sensor data visualization, including temperature unit conversion between Celsius and Fahrenheit. Additional support and clarifications on command usage (e.g., TMGN_SetBit parameters) were provided, along with links to source code and documentation. The community also addressed static IP configuration during OpenAP mode for device network setup. Overall, the device is now well-supported in OpenBeken firmware with active development on display drivers and sensor calibration.
AI summary based on the discussion. May contain errors.

FAQ LABEL_AI_GENERATED

TL;DR: For this BK7231N/CBU USB thermostat, 3 GN6932 lines and “bit order is swapped” are the key clues: use CHT on P22/P20, GN6932 on P15/P17/P28, then script TMGN for temperature, humidity, and time in OpenBeken. [#20535970] Why it matters: This turns a generic Tuya LED thermostat into a locally controlled OpenBeken sensor-display device without relying on Tuya cloud firmware.

Alternative Sensor or driver Thread-specific status Key command or setting
CHT8305 I2C temperature/humidity Original teardown sensor SDA P22, SCL P20
CHT8310 I2C temperature/humidity Seen in newer units Needs newer OpenBeken support
GN6932 8×16 LED driver Disabled in some newer builds #define ENABLE_DRIVER_TMGN 1
TM1637/TM1638 Related LED drivers Similar TMGN command family TMGN_Print, TMGN_SetBit

Key insight: The display is not TuyaMCU-driven. OpenBeken can drive it directly when the GN6932/TMGN driver is enabled and the three display pins are mapped correctly.

Quick Facts

  • CHT8305 wiring found in the device: SDA uses CBU pin 4/P22, SCL uses CBU pin 3/P20, and the alert pin was not connected. [#20535581]
  • GN6932 wiring found in the device: DIN uses CBU pin 21/P15, CLK uses CBU pin 20/P17, and STB uses CBU pin 17/P28. [#20535534]
  • GN6932 supports an 8-segment × 16-bit display mode, 8 brightness duty-cycle levels, an RC oscillator at 450 kHz ±5%, and an SOP32 package. [#20535551]
  • A working display command sequence used LSB-first bytes: 40, then C0 ..., then 8F; decoding it MSB-first made the packet look wrong. [#20536000]
  • Build 701 added working CHT_Calibrate; the example CHT_Calibrate -2 10 applies −2 °C temperature and +10 %RH humidity offsets. [#20539841]

How do I configure the CHT8305 sensor pins on a Tuya CBU BK7321N/BK7231N USB thermostat in OpenBeken?

Configure CHT8305 as I2C on CBU P22 and P20. Set CHT pin 1, SDA, to CBU pin 4/P22. Set CHT pin 6, SCL, to CBU pin 3/P20. The alert pin was reported as not connected. The thread confirmed the CHT sensor worked after this wiring map. [#20535581]

What is the GN6932 LED display driver and how does it communicate with the CBU module?

GN6932 is the multi-segment LED driver used by this thermostat display. "GN6932 is a display-driver IC that controls multi-segment LED displays, using a serial CLK, STB, and DIN interface with 8-segment × 16-bit output and 8 brightness levels." It receives low-bit-first serial data on CLK rising edges. [#20535551]

How do I start and test the GN6932 display driver in OpenBeken using TMGN commands?

Start the GN6932 driver, then send a TMGN test or print command. Use this 3-step check:
  1. Run startDriver GN6932.
  2. Run GN6932_TestAddressIncreaseMode to light random segments.
  3. Run TMGN_Brightness 7 and TMGN_Print 0 0 123456 to test output. Build 680 already showed changing patterns with the test command. [#20536357]

Why does OpenBeken say “Driver GN6932 is not known in this build” and how do I enable it?

OpenBeken says this when the build excludes the rarely used GN6932/TMGN driver. Newer builds disabled it to reduce flash usage and avoid LittleFS OTA problems. Enable it by compiling with #define ENABLE_DRIVER_TMGN 1 in obk_config.h. A custom build or pull-request build can also include it. [#20979746]

How can I create an autoexec.bat script to show temperature, humidity, and time on the GN6932 LED display?

Create autoexec.bat with GN6932, NTP, brightness, static bits, and a loop. The working example starts GN6932, starts NTP, sets timezone +2:00, prints minutes at offset 7, hours at offset 5, temperature at offset 2, and humidity at offset 0. It also blinks the clock colon by toggling bits 10:0 and 10:1 every 1 second. [#20537716]

What do the numbers mean in the OpenBeken command TMGN_Print 7 2 $minute 1?

7 is the start offset, and 2 is the maximum length. TMGN_Print uses the format TMGN_Print [StartOffset] [MaxLenOr0] [Text]. So TMGN_Print 7 2 $minute 1 prints the two-digit minute value starting at display position 7, with zero padding enabled by the final 1. [#21210176]

How does TMGN_SetBit work for controlling individual LED display segments on TM1637, TM1638, or GN6932 displays?

TMGN_SetBit 9 1 1 means display index 9, bit 1, value on. The first number selects a display byte or digit index, usually within 0–15. The second number selects one of 8 bits, matching 7 segments plus dot. The third number sets that segment off or on, using 0 or 1. [#21205196]

How do I calibrate CHT8305 temperature and humidity readings in OpenBeken with CHT_Calibrate?

Use CHT_Calibrate [temperature offset] [humidity offset] after starting the sensor driver. Build 701 confirmed CHT_Calibrate -2 10 worked. That example subtracts 2 °C from temperature and adds 10 %RH to humidity. Earlier SHT_Calibrate and SHT3X_Calibrate commands failed on CHT8305 because they targeted other drivers. [#20539841]

CHT8305 vs CHT8310: what are the differences and which sensor is used in newer versions of this USB thermostat?

Original units used CHT8305, while newer tested units used CHT8310. The newer board otherwise looked identical in the thread. An older OpenBeken build with GN6932 support lacked newer CHT8310 support, so readings became incorrect. The reported GUI value reached −265 while the LED showed a divided-by-10 temperature figure. [#20980349]

How can I set a static IP address for an OpenBeken device while it is still in AP mode?

Set the static IP from the OpenBeken configuration page while the device runs in AP mode. Choose an address that is unique on your target network. This solves the case where you can join Wi-Fi but cannot access the router page to discover the DHCP address. [#20629101]

What is OpenBeken and why is it used instead of the original Tuya firmware on BK7231N/CBU devices?

OpenBeken is alternative firmware for BK7231N/CBU devices that gives local control, scripting, sensor drivers, and display drivers. In this thermostat, users replaced Tuya firmware to read CHT8305 or CHT8310 data, drive GN6932 LEDs, run NTP time, and restore a working clock-temperature-humidity display without the Tuya cloud. [#20537716]

What is PulseView/Sigrok and how can it help decode DIN, CLK, and STB signals from a GN6932 display?

PulseView/Sigrok captures logic-analyzer traces from GN6932 DIN, CLK, and STB lines. "PulseView/Sigrok is a logic-analysis toolchain that records and decodes digital bus signals, letting users inspect byte order, chip-select timing, and serial display commands." In this case, it revealed LSB-first data and the sequence 40, C0 ..., 8F. [#20536000]

How can I restore the original 2 MB firmware backup to a Tuya CBU device after flashing OpenBeken?

Restore the original 2 MB backup by renaming it for the flasher and placing it in the firmware directory. One user renamed the backup to OpenBK7231N_QIO_1.15.xxx, flashed it, and confirmed the device returned to its original state. This gives a recovery path after OpenBeken testing. [#20535581]

What ESPHome configuration could be used for a BK7231N thermostat with CHT8305 or CHT8310 sensor and GN6932 LED display?

The thread did not provide a working ESPHome configuration for this thermostat. It only requested one in December 2024. The tested path used OpenBeken, a custom build with GN6932 enabled, CHT sensor support, and TMGN scripts. For ESPHome, the missing piece is GN6932 display support equivalent to OpenBeken TMGN commands. [#21350125]

Why might a GN6932 display show humidity and temperature in the wrong positions, and how can channel mapping or TMGN_Map fix it?

The display can show values in wrong positions when channel order or digit mapping does not match the physical grid. One user had to set CHT SDA channels as 1:0 because temperature appeared on the humidity line. For TM1637 mapping issues, the maintainer advised using TMGN_Map instead of TMGN_SetBit. [#20980349]
AI summary based on the discussion. May contain errors.
ADVERTISEMENT