logo elektroda
logo elektroda
X
logo elektroda

[CB3S/AHT20/UM8005] Separating TH002, OpenBeken Sensor Support, and Configuration

GeorgeQW 5106 23
ADVERTISEMENT
  • #1 20468693
    GeorgeQW
    Level 5  
    Hello,
    Has anyone managed to separate the TH002 with the CB3S and the UM8005 and the AHT20 sensor?

    I partially painted it. I have uploaded SW OpenBeken, but I still don't know what to do with it...
    Thanks GW
    Translated by google

    AHT20:
    https://files.seeedstudio.com/wiki/Grove-AHT2...Humidity_Sensor/AHT20-datasheet-2020-4-16.pdf
    UM8005:
    https://www.unicmicro.com/index.php/en/show-75-126.html
    http://www.gztrchip.com/uploadfile/file/20210811/1628649277678726.pdf

    [CB3S/AHT20/UM8005] Separating TH002, OpenBeken Sensor Support, and Configuration





    [CB3S/AHT20/UM8005] Separating TH002, OpenBeken Sensor Support, and Configuration

    Data Power On Start Pair TUYA BaudRate 9600 - CB3S RXD - TTL USB RXD:
    [CB3S/AHT20/UM8005] Separating TH002, OpenBeken Sensor Support, and Configuration
    [CB3S/AHT20/UM8005] Separating TH002, OpenBeken Sensor Support, and Configuration

    Data Power On Start Pair TUYA CB3S TXD - TTL USB RXD:
    [CB3S/AHT20/UM8005] Separating TH002, OpenBeken Sensor Support, and Configuration

    Get device details iot tuya + localTuya
    {
    "result": {
    "active_time": 1645807448,
    "biz_type": 0,
    "category": "wsdcg",
    "create_time": 1645807398,
    "icon": "smart/icon/ay15427647462366edzT/61478454256bce1df83842a74a02e9e8.png",
    "id": "bfd30ca734bc7c998fszz3",
    "ip": "",
    "lat": "49.9657",
    "local_key": "68e1c0b9e73ed9b5",
    "lon": "17.0017",
    "model": "TH-02",
    "name": "WiFi T & H",
    "online": true,
    "owner_id": "21990287",
    "product_id": "q29ebws5adwye1l8",
    "product_name": "WiFi Temperature & Humidity Sensor",
    "status": [
    {
    "code": "va_temperature",
    "value": 242 ID1
    },
    {
    "code": "va_humidity",
    "value": 65 ID2
    },
    {
    "code": "battery_state",
    "value": "high" ID3
    },
    {
    "code": "temp_unit_convert",
    "value": "c" ID9
    },
    {
    "code": "maxtemp_set",
    "value": 390 ID10
    },
    {
    "code": "minitemp_set",
    "value": 0 ID11
    },
    {
    "code": "maxhum_set",
    "value": 80 ID12
    },
    {
    "code": "minihum_set",
    "value": 20 ID13
    },
    {
    "code": "temp_alarm",
    "value": "cancel" ID14
    },
    {
    "code": "hum_alarm",
    "value": "cancel" ID15
    },
    {
    "code": "temp_periodic_report",
    "value": 120 ID17
    },
    {
    "code": "hum_periodic_report",
    "value": 60 ID18
    },
    {
    "code": "temp_sensitivity",
    "value": 6 ID19
    },
    {
    "code": "hum_sensitivity",
    "value": 6 ID20
    },
    {
    "code": "switch",
    "value": true ID21
    }
    ],
    "sub": false,
    "time_zone": "+01:00",
    "uid": "eu1577721077255qzajO",
    "update_time": 1645807475,
    "uuid": "8a2677e18b9a1203"
    },
    "success": true,
    "t": 1645808115506,
    "tid": "b464348f965b11ec81c45ef357c3f605"
    }


    [CB3S/AHT20/UM8005] Separating TH002, OpenBeken Sensor Support, and Configuration

    autoexec.bat
    startDriver TuyaMCU
    startDriver tmSensor
    setChannelType 0 ReadOnly
    linkTuyaMCUOutputToChannel 0 val 0
    setChannelType 1 temperature_div10
    linkTuyaMCUOutputToChannel 1 val 1
    setChannelType 2 Humidity
    linkTuyaMCUOutputToChannel 2 val 2
    setChannelType 10 temperature_div10
    linkTuyaMCUOutputToChannel 10 val 10
    setChannelType 11 temperature_div10
    linkTuyaMCUOutputToChannel 11 val 11
    setChannelType 12 Humidity
    linkTuyaMCUOutputToChannel 12 val 12
    setChannelType 13 Humidity
    linkTuyaMCUOutputToChannel 13 val 13
    setChannelType 14 ReadOnly
    linkTuyaMCUOutputToChannel 14 val 14
    setChannelType 15 ReadOnly
    linkTuyaMCUOutputToChannel 15 val 15
    setChannelType 17 TextField
    linkTuyaMCUOutputToChannel 17 val 17
    setChannelType 18 TextField
    linkTuyaMCUOutputToChannel 18 val 18
    setChannelType 19 TextField
    linkTuyaMCUOutputToChannel 19 val 19
    setChannelType 20 TextField
    linkTuyaMCUOutputToChannel 20 val 20
    setChannelType 21 ReadOnly
    linkTuyaMCUOutputToChannel 21 val 21
  • ADVERTISEMENT
  • Helpful post
    #2 20468733
    p.kaczmarek2
    Moderator Smart Home
    Hello,
    I have moved your post to separate topic, because it has nothing to do with Qiachip Smart Switch, which is not even a battery-powered device.

    Regarding your question... I am not sure if your schematic is correct. I think that RXD/TXD connection seems strange.

    I'd suspect that your device is a TuyaMCU device, and it's using TuyaMCU protocol for battery-powered devices.
    So, you'd need to do something like here:
    https://www.elektroda.com/rtvforum/topic3914412.html
    I think that Q1 on your schematic is responsible for powering on and off the WiFi module. WiFI module is not powered by default. It is only powered when MCU decides that it's time to report data to server. Then MCU powers on WiFI module and reports measurements by TuyaMCU protocol.
    Read more here:
    https://developer.tuya.com/en/docs/iot/tuyacl...niversalserialaccessprotocol?id=K95afs9h4tjjh
    [CB3S/AHT20/UM8005] Separating TH002, OpenBeken Sensor Support, and Configuration
    See? MCU power on the WiFi module via mentioned transistor.

    You will need to check OpenBeken Web App Logs to see which dpID is used for that (or capture communication with USB to TTL converter), then adjust dpIDs in the config.

    Of course, the second option would be to desolder MCU and Q1 and convert your sensor to the deep sleep system, maybe that approach could work:
    https://www.elektroda.com/rtvforum/topic3945688.html
    but the one here is using SHT30 and not AHT20.. we would need to check how many changes to protocol are needed to support it.
    Helpful post? Buy me a coffee.
  • #3 20469338
    GeorgeQW
    Level 5  
    Hello,
    yes schematic error. I miscalculated in pins. Corrected.
    I added what the original paired T&H sensor sends after start.
    I don't know what the hex data means.

    Will there be a driver for AHT20? I'm sure I'm not the only one who feels that way. :-)


    Communication is similar to this:
    https://www.elektroda.com/rtvforum/topic3914412.html
  • ADVERTISEMENT
  • #4 20470242
    GeorgeQW
    Level 5  
    >>20468733
    @p.kaczmarek2
    Hello
    I added information from IoT Tuya localTuya (ID) to the post. Could that be enough to support?
    Of course I don't use IoT Tuya. It's just for a test ....
  • Helpful post
    #5 20470261
    p.kaczmarek2
    Moderator Smart Home
    Driver for AHT20 might be added soon, regarding the information, can you create autoexec with:
    
    startDriver TuyaMCU
    startDriver tmSensor
    

    and then open Web App log, and then wake up device (by a pairing button? or just wait for MCU to wake it up?) and copy paste here the log of received TuyaMCU packets?

    Btw, I see you also posted some hex data, but in a format of image, and I can't copy from that to the analyzer...
    Helpful post? Buy me a coffee.
  • #6 20470271
    GeorgeQW
    Level 5  
    @p.kaczmarek2
    unfortunately, RealTerm stopped working, so I installed DocLight, but it doesn't allow me to copy hex in the trial. Type on another SW?
  • #7 20470280
    p.kaczmarek2
    Moderator Smart Home
    Then just use the Web Application method, it's faster, it will also show packets in log, and it will also already decode them and display values.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #8 20470283
    GeorgeQW
    Level 5  
    >>20470261
    Info:TuyaMCU:Consumed 255 unwanted non-header byte in Tuya MCU buffer
    Info:TuyaMCU:Skipped data (part) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    Info:TuyaMCU:Consumed 255 unwanted non-header byte in Tuya MCU buffer
    Info:TuyaMCU:Skipped data (part) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    Info:TuyaMCU:Consumed 255 unwanted non-header byte in Tuya MCU buffer
    Info:TuyaMCU:Skipped data (part) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    Info:TuyaMCU:Consumed 109 unwanted non-header byte in Tuya MCU buffer
    Info:TuyaMCU:Skipped data (part) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 00 00 00 00
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: discarding packet bad expected checksum, expected 0 and got checksum 255
    Info:TuyaMCU:Consumed 1 unwanted non-header byte in Tuya MCU buffer
    Info:TuyaMCU:Skipped data (part) 00
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 00 00 01 01 01
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 0 (Hearbeat) with 8 bytes
    Info:GEN:dhcp=0 ip=xxx gate=xxx mask=255.240.0.0 mac=c8:47:8c:00:00:00
    Info:GEN:sta: 1, softap: 0, b/g/n
    Info:GEN:sta:rssi=-85,ssid=xx,bssid=xx ,channel=1,cipher_type:MIXED
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 71 32 39 65 62 77 73 35 61 64 77 79 65 31 6C 38 22 2C 22 76 22 3A 22 31 2E 30 2E 30 22 7D 50
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 1 (QueryProductInformation) with 43 bytes
    Info:TuyaMCU:TuyaMCU_ParseQueryProductInformation: received {"p":"q29ebws5adwye1l8","v":"1.0.0"}
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 02 00 00 01
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 2 (MCUconf) with 7 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 00 00 01 01 01
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 0 (Hearbeat) with 8 bytes
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 00 00 01 01 01
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 0 (Hearbeat) with 8 bytes
    Info:GEN:dhcp=0 ip=xx gate=xx mask=255.240.0.0 mac=c8:47:8c:00:00:00
    Info:GEN:sta: 1, softap: 0, b/g/n
    Info:GEN:sta:rssi=-80,ssid=xxxx,bssid=xxxx ,channel=1,cipher_type:MIXED
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 00 00 01 01 01
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 0 (Hearbeat) with 8 bytes
    Info:CMD:[WebApp Cmd 'startDriver tmSensor' Result] OK
    Info:TuyaMCU:Consumed 255 unwanted non-header byte in Tuya MCU buffer
    Info:TuyaMCU:Skipped data (part) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    Info:TuyaMCU:Consumed 255 unwanted non-header byte in Tuya MCU buffer
    Info:TuyaMCU:Skipped data (part) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    Info:TuyaMCU:Consumed 255 unwanted non-header byte in Tuya MCU buffer
    Info:TuyaMCU:Skipped data (part) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    Info:TuyaMCU:Consumed 255 unwanted non-header byte in Tuya MCU buffer
    Info:TuyaMCU:Skipped data (part) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    Info:TuyaMCU:Consumed 255 unwanted non-header byte in Tuya MCU buffer
    Info:TuyaMCU:Skipped data (part) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

    Info:GEN:sta: 1, softap: 0, b/g/n
  • #9 20470293
    p.kaczmarek2
    Moderator Smart Home
    This is not a correct approach to do this. You have to put the mentioned two commands in autoexec.bat, save that file, then you must disconnect your external power from the WiFI module (your 3.3V supply), and let the device run on the battery.

    Then, after some time, when the MCU decides that it's a time to report data to WiFi module, the MCU will wake up and send data to OBK via UART, and in this case data should contain measurements.

    There is no way around it, you can try pressing button so it maybe it will wake up and do measurements faster, but I don't know if it will work.

    This fragment of log:
    
    Info:TuyaMCU:Skipped data (part) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    

    strongly shows that you are powering WiFi module externally while the MCU is still asleep, and this is abnormal situation for that device, that will not give you correct data.
    Helpful post? Buy me a coffee.
  • #11 20470320
    GeorgeQW
    Level 5  
    >>20470293

    I'm doing this for the first time: I created an autoexec.bat, put both commands in it, and saved it to the local disk. What next? :-)
  • Helpful post
    #12 20470327
    p.kaczmarek2
    Moderator Smart Home
    Only the last file contains some dpIDs.
    [CB3S/AHT20/UM8005] Separating TH002, OpenBeken Sensor Support, and Configuration [CB3S/AHT20/UM8005] Separating TH002, OpenBeken Sensor Support, and Configuration
    [CB3S/AHT20/UM8005] Separating TH002, OpenBeken Sensor Support, and Configuration
    
    
    
    55 AA	00	05		00 05	0904000100	17	
    HEADER	VER=00	Unk		LEN	fnId=9 Enum V=0	CHK	
    
    55 AA	00	05		00 08	0A02000400000186	A3	
    HEADER	VER=00	Unk		LEN	fnId=10 Val V=390	CHK	
    
    55 AA	00	05		00 08	0B02000400000000	1D	
    HEADER	VER=00	Unk		LEN	fnId=11 Val V=0	CHK	
    
    55 AA	00	05		00 08	0C02000400000050	6E	
    HEADER	VER=00	Unk		LEN	fnId=12 Val V=80	CHK	
    
    55 AA	00	05		00 08	0D02000400000014	33	
    HEADER	VER=00	Unk		LEN	fnId=13 Val V=20	CHK	
    
    55 AA	00	05		00 08	1102000400000078	9B	
    HEADER	VER=00	Unk		LEN	fnId=17 Val V=120	CHK	
    
    55 AA	00	05		00 08	1202000400000078	9C	
    HEADER	VER=00	Unk		LEN	fnId=18 Val V=120	CHK	
    
    55 AA	00	05		00 08	1302000400000006	2B	
    HEADER	VER=00	Unk		LEN	fnId=19 Val V=6	CHK	
    
    55 AA	00	05		00 08	1402000400000006	2C	
    HEADER	VER=00	Unk		LEN	fnId=20 Val V=6	CHK	
    
    55 AA	00	05		00 05	1501000101	21	
    HEADER	VER=00	Unk		LEN	fnId=21 Bool V=1	CHK	
    
    55 AA	00	05		00 08	01020004000000E1	F4	
    HEADER	VER=00	Unk		LEN	fnId=1 Val V=225	CHK	
    
    55 AA	00	05		00 08	020200040000003D	51	
    HEADER	VER=00	Unk		LEN	fnId=2 Val V=61	CHK	
    
    55 AA	00	05		00 05	0E04000102	1E	
    HEADER	VER=00	Unk		LEN	fnId=14 Enum V=2	CHK	
    
    55 AA	00	05		00 05	0F04000102	1F	
    HEADER	VER=00	Unk		LEN	fnId=15 Enum V=2	CHK	
    
    55 AA	00	05		00 08	01020004000000E1	F4	
    HEADER	VER=00	Unk		LEN	fnId=1 Val V=225	CHK	
    
    55 AA	00	05		00 08	020200040000003D	51	
    HEADER	VER=00	Unk		LEN	fnId=2 Val V=61	CHK	
    
    55 AA	00	05		00 08	040200040000005B	71	
    HEADER	VER=00	Unk		LEN	fnId=4 Val V=91	CHK	
    
    55 AA	00	05		00 05	0304000102	13	
    HEADER	VER=00	Unk		LEN	fnId=3 Enum V=2	CHK	
    


    It seems they match the IDs you posted, right? So we can easily figure out they meaning.

    Well, so the job is almost done. We have verified that the data is sent and we know the IDs and the var types. Now you can use linkTuyaMCUOutputToChannel to map them. Do you know how?
    Helpful post? Buy me a coffee.
  • #13 20470349
    GeorgeQW
    Level 5  
    This is my first time playing with it in this form. I don't know what to do with it yet (linkTuyaMCUOutputToChannel).
    I already googled that autoexec.bat is inserted into the WebApp in the Filesystem tab... The attached file contains a list of what it sends when the batteries are powered.
  • #14 20470496
    p.kaczmarek2
    Moderator Smart Home
    Have you consulted similiar topics and docs?
    https://www.elektroda.com/rtvforum/topic3895301.html

    Basically, for each variable you do:
    1. set channel type (choose channel index at your will)
    2. link dpID to the channel
    Then it will be displayed on WWW page and also published by MQTT.

    Let's say you want this variable:
    
    "code": "va_humidity",
    "value": 65 ID2
    

    You can also see its type in my post:
    
    55 AA	00	05		00 08	020200040000003D	51	
    HEADER	VER=00	Unk		LEN	fnId=2 Val V=61	CHK	
    

    So you do:
    
    setChannelType 1 humidity
    // linkTuyaMCUOutputToChannel dpId varType channelID
    linkTuyaMCUOutputToChannel  2 val 1
    

    Then you want to add temperature, so, look at our posts, and you see that temperature here is as integer, multiplied by 10:
    
    55 AA	00	05		00 08	01020004000000E1	F4	
    HEADER	VER=00	Unk		LEN	fnId=1 Val V=225	CHK	
    

    So:
    
    setChannelType 2 temperature_div10
    // linkTuyaMCUOutputToChannel dpId varType channelID
    linkTuyaMCUOutputToChannel  1 val 2
    

    you can also set labels:
    
    setChannelLabel 1 "Some humidity 123"
    setChannelLabel 2 "My Temperaturee"
    

    they can be whatever you want.

    Now, for more custom variables, you can set channel types to, for example, TextField to get write access, or for read only fields, set ReadOnly channel type.

    Try it out, show me your first results, and I will help more if needed.

    Use search function on our forum to get more info.
    Helpful post? Buy me a coffee.
  • #15 20470526
    GeorgeQW
    Level 5  
    @p.kaczmarek2
    Great, I guess I already broke it. I put the procedure in my first post. Thank you very much :-)
  • #16 20470740
    p.kaczmarek2
    Moderator Smart Home
    Of course, there may be more steps to that. Futhermore, do you know how to receive a channel publish in Home Assistant?

    Have you enabled the "apply multiplier" flag in flags to get the result like 23.5 for temperature instead of integer 235 (which TuyaMCU uses)?
    Helpful post? Buy me a coffee.
  • #17 20470854
    GeorgeQW
    Level 5  
    Yes, everything is correct, I check it using the TUYA app, including "apply multiplier". I put the settings in the first post and it's all together.

    Yes, it already passes data:

    obk8C000000
    connected = online
    sockets = 2
    rssi = -81
    uptime = 18
    host = obk8C000000
    build = Build on Mar 3 2023 16:11:58 version 1.15.522
    mac = c8:47:8c:00:00:00
    freeheap = 73072
    ip =
    1
    get = 0
    2
    get = 0
    10
    get = 39.000000
    11
    get = 0
    12
    get = 80
    13
    get = 20
    14
    get = 2
    15
    get = 0
    17
    get = 120
    18
    get = 60
    19
    get = 6
    20
    get = 6
    21
    get = 0

    It appears for a while and then it starts deleting. Surely there must be a data-forced sequence right?


    Something else needs to be set somewhere...
    I have check:
    Flag 7 - [MQTT] [Debug] Always set Retain flag to all published values
    Flag 10 - [MQTT] Broadcast self state on MQTT connect
    Flag 19 - [MQTT] Always publish channels used by TuyaMCU
    Flag 21 - [MQTT] Retain power channels (Relay channels, etc)
    Flag 30 - [MQTT] Enable Tasmota TELE etc publishes (for ioBroker etc)
    Flag 33 - [MQTT] Apply channel type multiplier on (if any) on channel value before publishing it
    Flag 27 - [HASS] Invoke HomeAssistant discovery on change to ip address, configuration
    Flag 37 - [WiFi] Quick connect to WiFi on reboot (TODO: check if it works for you and report on github)
  • ADVERTISEMENT
  • #18 20474561
    GeorgeQW
    Level 5  
    @p.kaczmarek2
    Hello,
    I'm testing the CB3S with OpenBK and TH-002. After connecting the battery, I can see the data in MQTT explorer fine. The next round of sending data resets the IDx. Sometimes only part of the ID, sometimes all of the ID. Then the sensor will stop responding until it is reset by removing the batteries. Then it all happens again.
    The ID fits according to what I supplied before.
    I am attaching files of the original TH-002 HEX communication with the TUYA application.

    It might help.

    Thank you.
    GQ
    translate google

    [CB3S/AHT20/UM8005] Separating TH002, OpenBeken Sensor Support, and Configuration >>20470740
  • #19 20474618
    p.kaczmarek2
    Moderator Smart Home
    How do you have pins configured? Channel 2 is temperature and it gets reset to 0?
    Helpful post? Buy me a coffee.
  • #20 20474650
    GeorgeQW
    Level 5  
    After connecting the batteries, the data will be delivered to the correct ID according to how I have it set up.
    ID1 (Temp)
    setChannelType 1 temperature_div10
    linkTuyaMCUOutputToChannel 1 val 1
    ID2 (Humidity)
    setChannelType 2 Humidity
    linkTuyaMCUOutputToChannel 2 val 2
    After a few minutes (approx. 5) it resets (ID1 null, ID2 null, etc...) them and then doesn't supply any more data until the battery is disconnected and reconnected. It supplies data, then resets it and doesn't respond anymore.

    Dodano po 23 [minuty]:

    >>20474618
    WebApp log
    It's possible that I have it set up wrong :-)
  • #21 20475501
    p.kaczmarek2
    Moderator Smart Home
    Regarding zero spikes - let's try something. Let's make channels remember their values after reboot. This is because it seems that the values are sent to MQTT before TuyaMCU reports them... just try it, as a temporary solution.

    What is your current config? Which channels are you using?

    Add to config:
    
    // SetStartValue  [Channel] [Value]
    // 1 means set to 1 on start, 0 means set to 0, -1 means "remember last value"
    SetStartValue 0 -1
    SetStartValue 1 -1
    SetStartValue 2 -1
    SetStartValue 3 -1
    SetStartValue 4 -1
    


    Regarding this:
    GeorgeQW wrote:

    After a few minutes (approx. 5) it resets (ID1 null, ID2 null, etc...) them and then doesn't supply any more data until the battery is disconnected and reconnected. It supplies data, then resets it and doesn't respond anymore.

    Do you mean that device does not wake up anymore or it wakes up, but does not send data?

    Maybe we need to set something like next measurement interval as well... from our script... you have more advanced device that the ones I've seen.
    Helpful post? Buy me a coffee.
  • #22 20475586
    GeorgeQW
    Level 5  
    Thanks, I'll try that configuration when I get home. (SetStartValue 0 -1 etc.)

    I thought it wouldn't wake up again, but checking the WebApp Log, I found that:
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 02 00 00 01
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 2 (MCUconf) with 7 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 10 00 01 00 10
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 16 (Unknown) with 8 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: unhandled type 16
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 05 00 05 0E 04 00 01 02 1E

    Error: HTTP: HA discovery: No relay, PWM, sensor or power driver running. (autoexec.bat include = startDriver TuyaMCU, startDriver tmSensor)
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk8C000000/1/get
    Info:MQTT:MQTT in topic obk8C000000/1/get
    Info:MQTT:MQTT topic not handled: obk8C000000/1/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk8C000000/2/get
    Info:MQTT:MQTT in topic obk8C000000/2/get
    Info:MQTT:MQTT topic not handled: obk8C000000/2/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk8C000000/10/get
    Info:MQTT:MQTT in topic obk8C000000/10/get ...
    etc ...

    Info:MQTT:channelSet NOT 'set'
    Info:MQTT:channelSet NOT 'set'
    Info:MQTT:channelSet NOT 'set'
    Info:MQTT:channelSet NOT 'set'
    Info:MQTT:channelSet NOT 'set'
    etc ...

    Info:GEN:sta:rssi=-58,ssid=,bssid= ,channel=1,cipher_type:MIXED
    Info:MAIN:HA discovery is scheduled, but MQTT connection is not present yet
    Info:MAIN:Time 11, idle 183154/s, free 73224, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MAIN:HA discovery is scheduled, but MQTT connection is not present yet
    Info:MAIN:Time 12, idle 188014/s, free 73224, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MAIN:HA discovery is scheduled, but MQTT connection is not present yet
    Info:MAIN:Time 13, idle 374592/s, free 73224, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MAIN:HA discovery is scheduled, but MQTT connection is not present yet
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 00 00 01 01 01
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 0 (Hearbeat) with 8 bytes
    Info:MAIN:Time 14, idle 188287/s, free 73224, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MAIN:HA discovery is scheduled, but MQTT connection is not present yet

    Otherwise, the complete set is in the WebApk.txt attachment
    I have no idea why...
    Thank you.

    Dodano po 8 [godziny] 45 [minuty]:

    >>20475501

    I added autoexec.bat:
    SetStartValue 1 -1
    SetStartValue 2 -1
    SetStartValue 10 -1
    SetStartValue 11 -1

    Info:MAIN:Started TuyaMCU.
    Info:MAIN:Started tmSensor.
    Info:GEN:Channel 1 type changed to temperature_div10
    Info:GEN:Channel 2 type changed to Humidity
    Info:GEN:Channel 10 type changed to temperature_div10
    Info:GEN:Channel 11 type changed to temperature_div10
    Info:GEN:Channel 12 type changed to Humidity
    Info:GEN:Channel 13 type changed to Humidity
    Info:GEN:Channel 14 type changed to ReadOnly
    Info:GEN:Channel 15 type changed to ReadOnly
    Info:GEN:Channel 17 type changed to TextField
    Info:MAIN:Main_Init_After_Delay done
    Info:GEN:Channel 18 type changed to TextField
    Info:GEN:Channel 19 type changed to TextField
    Info:GEN:Channel 20 type changed to TextField
    Info:GEN:Channel 21 type changed to ReadOnly

    Info:MAIN:HA discovery is scheduled, but MQTT connection is not present yet
    Info:MQTT:mqtt_connection_cb: Successfully connected
    Info:MQTT:mqtt_subscribed to obk8C000000/+/set
    Info:MQTT:mqtt_subscribed to obk8C000001/+/set
    Info:MQTT:mqtt_subscribed to cmnd/obk8C000000/+
    Info:MQTT:mqtt_subscribed to cmnd/obk8C000001/+
    Info:MQTT:mqtt_subscribed to obk8C000000/+/get
    Info:MAIN:Time 1, idle 271913/s, free 72792, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:HA discovery is scheduled, but MQTT connection is not present yet
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 00 00 01 01 01
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 0 (Hearbeat) with 8 bytes
    Info:MAIN:Time 2, idle 185851/s, free 72792, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:HA discovery is scheduled, but MQTT connection is not present yet
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 71 32 39 65 62 77 73 35 61 64 77 79 65 31 6C 38 22 2C 22 76 22 3A 22 31 2E 30 2E 30 22 7D 50
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 1 (QueryProductInformation) with 43 bytes
    Info:TuyaMCU:TuyaMCU_ParseQueryProductInformation: received {"p":"q29ebws5adwye1l8","v":"1.0.0"}
    Info:MAIN:Time 3, idle 99626/s, free 72888, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:HA discovery is scheduled, but MQTT connection is not present yet
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 02 00 00 01
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 2 (MCUconf) with 7 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 71 32 39 65 62 77 73 35 61 64 77 79 65 31 6C 38 22 2C 22 76 22 3A 22 31 2E 30 2E 30 22 7D 50
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 1 (QueryProductInformation) with 43 bytes
    Info:TuyaMCU:TuyaMCU_ParseQueryProductInformation: received {"p":"q29ebws5adwye1l8","v":"1.0.0"}
    Info:MAIN:Time 4, idle 0/s, free 72888, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:HA discovery is scheduled, but MQTT connection is not present yet
    Info:MAIN:Time 5, idle 0/s, free 72888, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:HA discovery is scheduled, but MQTT connection is not present yet
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTING - 1
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4

    Info:MQTT:Channel has changed! Publishing 2 to channel 14
    Info:CFG:####### Flash Save Can't Save Channel 14 as 2 (not enough space in array) #######
    Info:MAIN:Time 7, idle 171858/s, free 73208, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MAIN:HA discovery is scheduled, but MQTT connection is not present yet
    Info:MAIN:Time 8, idle 171912/s, free 73208, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MAIN:HA discovery is scheduled, but MQTT connection is not present yet
    Info:MAIN:Time 9, idle 187904/s, free 73208, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MAIN:HA discovery is scheduled, but MQTT connection is not present yet
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 00 00 01 01 01
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 0 (Hearbeat) with 8 bytes
    Info:MAIN:Time 10, idle 190018/s, free 73208, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38

    Info:MAIN:Time 13, idle 370492/s, free 73152, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MQTT:Publishing val 192.168.10.25 to obk8C000000/ip retain=0
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 00 00 01 01 01
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 0 (Hearbeat) with 8 bytes
    Info:MAIN:Time 14, idle 182290/s, free 73152, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MQTT:Forced channel publish! Publishing val 25.299999 to 1
    Info:MQTT:Publishing val 25.299999 to obk8C000000/1/get retain=0
    Info:MAIN:Time 15, idle 185923/s, free 73152, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk8C000000/1/get
    Info:MQTT:MQTT in topic obk8C000000/1/get
    Info:MQTT:MQTT topic not handled: obk8C000000/1/get
    Info:MQTT:channelSet NOT 'set'
    Info:MQTT:Forced channel publish! Publishing val 62 to 2
    Info:MQTT:Publishing val 62 to obk8C000000/2/get retain=0
    Info:MAIN:Time 16, idle 191549/s, free 73152, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk8C000000/2/get
    Info:MQTT:MQTT in topic obk8C000000/2/get
    Info:MQTT:MQTT topic not handled: obk8C000000/2/get
    Info:MQTT:channelSet NOT 'set'
    Info:MQTT:Forced channel publish! Publishing val 39.000000 to 10
    Info:MQTT:Publishing val 39.000000 to obk8C000000/10/get retain=0
    Info:MAIN:Time 17, idle 184616/s, free 73152, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk8C000000/10/get
    Info:MQTT:MQTT in topic obk8C000000/10/get
    Info:MQTT:MQTT topic not handled: obk8C000000/10/get
    Info:MQTT:channelSet NOT 'set'
    Info:MQTT:Forced channel publish! Publishing val 0 to 11
    Info:MQTT:Publishing val 0 to obk8C000000/11/get retain=0
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 00 00 01 01 01
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 0 (Hearbeat) with 8 bytes
    Info:MAIN:Time 18, idle 183133/s, free 73152, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk8C000000/11/get
    Info:MQTT:MQTT in topic obk8C000000/11/get
    Info:MQTT:MQTT topic not handled: obk8C000000/11/get
    Info:MQTT:channelSet NOT 'set'
    Info:MQTT:Forced channel publish! Publishing val 0 to 12
    Info:MQTT:Publishing val 0 to obk8C000000/12/get retain=0
    Info:MAIN:Time 19, idle 181494/s, free 73152, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk8C000000/12/get
    Info:MQTT:MQTT in topic obk8C000000/12/get
    Info:MQTT:MQTT topic not handled: obk8C000000/12/get
    Info:MQTT:channelSet NOT 'set'
    Info:MQTT:Forced channel publish! Publishing val 0 to 13
    Info:MQTT:Publishing val 0 to obk8C000000/13/get retain=0
    Info:MAIN:Time 20, idle 183559/s, free 73152, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:GEN:dhcp=0 ip=192.168.10.25 gate=192.168.10.1 mask=255.240.0.0 mac=c8:47:8c:00:00:00
    Info:GEN:sta: 1, softap: 0, b/g/n
    Info:GEN:sta:rssi=-49,ssid=PRAMET,bssid=2c:c8:1b:37:9f:74 ,channel=1,cipher_type:MIXED
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk8C000000/13/get
    Info:MQTT:MQTT in topic obk8C000000/13/get
    Info:MQTT:MQTT topic not handled: obk8C000000/13/get
    Info:MQTT:channelSet NOT 'set'
    A_CMD_MCU_CONF, TODO!
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 71 32 39 65 62 77 73 35 61 64 77 79 65 31 6C 38 22 2C 22 76 22 3A 22 31 2E 30 2E 30 22 7D 50
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 1 (QueryProductInformation) with 43 bytes
    Info:TuyaMCU:TuyaMCU_ParseQueryProductInformation: received {"p":"q29ebws5adwye1l8","v":"1.0.0"}
    Info:MAIN:Time 4, idle 0/s, free 72888, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:HA discovery is scheduled, but MQTT connection is not present yet
    Info:MAIN:Time 5, idle 0/s, free 72888, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:HA discovery is scheduled, but MQTT connection is not present yet
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTING - 1
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4

    I put the sensor outside the window, where the temperature is about 4.6C. The temperature and humidity do not change. It is the same as measured after restarting TH-002 get = 25.700000. A low temperature alarm beeps outside. No change in data.
  • #23 20479974
    GeorgeQW
    Level 5  
    >>20475501
    @p.kaczmarek2

    Hello,
    so I completely reflashed it. It now behaves like it will send the correct data over MQTT when the battery is connected. Then it regularly sends the same values. After connecting the batteries again, the values are restored. Again, it sends the updated values over and over again. I don't know what to do with that...

    GQ

    [CB3S/AHT20/UM8005] Separating TH002, OpenBeken Sensor Support, and Configuration
  • #24 21415739
    sns1
    Level 5  
    Hi,

    I have the same device (two of them). Going to take off tuyamcu and wire everything to bk7231n chip instead.
    Only two small issues:
    1 - there are no dc-dc buck onboard, so 2.5-3.6 voltage.
    2 - will have to make voltage divider for battery measurement.

Topic summary

The discussion focuses on integrating and separating temperature and humidity sensors TH002, AHT20, and UM8005 with the CB3S device running OpenBeken firmware. The main challenge is correctly configuring the TuyaMCU protocol communication over UART, especially for battery-powered devices where the MCU controls WiFi module power to conserve energy. Users share experiences capturing and decoding TuyaMCU hex data packets, linking dpIDs to channels, and configuring autoexec.bat scripts with commands like startDriver TuyaMCU and startDriver tmSensor. Issues include sensor data resetting to zero after several minutes, requiring battery removal to reset, and difficulties in interpreting hex data and ensuring continuous data reporting. Suggested solutions involve setting channel types (e.g., temperature_div10, humidity), linking dpIDs to channels, enabling MQTT retain flags, and using SetStartValue to remember last values after reboot. The importance of proper power management—disconnecting external 3.3V supply to allow MCU-controlled WiFi power cycling—is emphasized. Some users consider bypassing TuyaMCU and wiring sensors directly to the BK7231N chip, noting hardware limitations like absence of onboard DC-DC converters and need for voltage dividers for battery measurement. Documentation and similar forum topics are referenced for protocol details and configuration examples.
Summary generated by the language model.
ADVERTISEMENT