logo elektroda
logo elektroda
X
logo elektroda

TX-E gas detector with shut-off valve control function - interior of unit

Samezrp1 1197 22
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
📢 Listen (AI):
  • TX-E gas detector with shut-off valve control function - interior of unit .
    I will show here the interior of the Gas Leak detector, model: TX-E
    Gas leak detector with gas shut-off valve control.

    edit:
    I have highlighted the used pins on the CB3S, you can see that all the communication goes through the UART, there is no peripheral support through the CB3S. The rest of the pins not soldered on.

    Cool? Ranking DIY
    About Author
    Samezrp1
    Level 13  
    Offline 
    Samezrp1 wrote 90 posts with rating 7, helped 2 times. Been with us since 2003 year.
  • ADVERTISEMENT
  • #2 21321408
    p.kaczmarek2
    Moderator Smart Home
    So the device from TuyaMCU. Protocol description:
    TuyaMCU protocol - communication between microcontroller and WiFi module .
    A broad description of the how-to run approach:
    TuyaMCU flashing, installation and configuration guide - configure dpID for Home Assistant

    But summarising (TLDR):
    - try to retrieve dpID meanings from Tuya cloud .
    - also it is worth to do UART communication interception with analyzer TuyaMCU analyzer - UART packet decoder for Tuya devices - dpID detector , I do it with two USB to UART converters, but if you have one, it is supposedly enough to listen to what WiFi sends to MCU when you change something in the app and what MCU sends to WiFi periodically....
    - make a flash backup https://github.com/openshwprojects/BK7231GUIFlashTool , any flashing will probably require you to put the MCU into RESET mode or cut the UART lines or solder off the MCU or WiFi module....

    Additional question - is this a regular TuyaMCU, or battery-powered TuyaMCU where the MCU turns on the WiFi module just to report data to the cloud? Is 3.3V still on the VDD of the WiFi module? Or is the WiFi module connected to the power supply via the MOSFET transistor that the MCU controls? This is to be checked, battery devices require a driver in the OBK tmSensor enabled next to the main TuyaMCU .
    Helpful post? Buy me a coffee.
  • #3 21321688
    Samezrp1
    Level 13  
    p.kaczmarek2 wrote:
    But summarising (TLDR):
    .
    Thanks, I'm already reading, I've already analysed part of it, but not all of it.
    Quote:
    .
    when you have one, it's supposedly enough to listen to what WiFi sends to the MCU as you change something in the app and what the MCU sends to WiFi periodically....
    .
    I have two, no problem with that, the problem is that the WiFi RX communication is quietly eavesdropping, but when I connect anything to listen to the WiFi TX (just physically connect the cable), a gas detection alarm appears on the display and the unit loses connection to the cloud. Tested on two, different converters.
    Quote:
    .
    - make a flash backup https://github.com/openshwprojects/BK7231GUIFlashTool , any flashing will probably require putting the MCU in RESET mode or cutting the UART line or soldering out the MCU or WiFi module....
    .
    Done, attached. It went off without a problem. I did not try to flash.
    Quote:
    .
    Additional question - is this a regular TuyaMCU, or battery-powered TuyaMCU .
    .
    Module without battery, power supply via USB-C. Display non sop on, also shows temperature (although it misrepresents, looks like a local measurement), retrieves date and outside temperature from the cloud, device also controls actuator to close gas valve.

    -----------
    edit: .

    So far I have managed thanks to this link from the logs:
    
    {
      "1": "Gas Detection State",
      "2": "Detected Gas",
      "7": "Alarm Time",
      "8": "Test",
      "9": "Test Result",
      "10": "Preheat",
      "11": "Fault Alarm",
      "12": "Lifecycle",
      "16": "Silence",
      "18": "Temperature state",
      "19": "Temperature",
      "101": "Heat Alarm Value",
      "102": "Detector Language",
      "104": "Calibration (Do this in clear air)"
    }
    
    .
    and from developer Tuya:
    
    gas_sensor_status	Enum	
    {
      "range": [
        "alarm",
        "normal"
      ]
    }
    
    gas_sensor_value	Integer	
    {
      "unit": "%LEL",
      "min": 0,
      "max": 100,
      "scale": 0,
      "step": 1
    }
    
    alarm_time	Integer	
    {
      "unit": "m",
      "min": 0,
      "max": 60,
      "scale": 0,
      "step": 1
    }
    
    self_checking	Boolean	
    "{true,false}"
    
    checking_result	Enum	
    {
      "range": [
        "checking",
        "check_success",
        "check_failure",
        "others"
      ]
    }
    
    preheat	Boolean	
    "{true,false}"
    
    fault	Bitmap	
    {
      "label": [
        "fault",
        "serious_fault",
        "sensor_fault",
        "probe_fault",
        "power_fault"
      ]
    }
    lifecycle	Boolean	
    "{true,false}"
    
    muffling	Boolean	
    "{true,false}"
    
    co_state	Enum	
    {
      "range": [
        "alarm",
        "normal"
      ]
    }
    
    co_value	Integer	
    {
      "unit": "℃",
      "min": -55,
      "max": 125,
      "scale": 0,
      "step": 1
    }
    
    .

    And now the events extracted from TuyaMCUAnalyzer.exe.

    Here the triggering of the gas detection alarm:
    
    Dir.,Header,Vers.,Cmd,Length,DPid,Type,DataLen,Data,Decoded,Checksum
    IN,55 AA,03,00,00 01,,,,01,Heartbeat,04
    IN,55 AA,03,07,00 08,02,02,00 04,00000005,dpId=2 Val V=5,1E
    IN,55 AA,03,07,00 05,10,01,00 01,01,dpId=16 Bool V=1,21
    IN,55 AA,03,07,00 08,13,02,00 04,00000013,dpId=19 Val V=19,3D
    IN,55 AA,03,07,00 05,01,04,00 01,00,dpId=1 Enum V=0,14
    IN,55 AA,03,07,00 08,02,02,00 04,0000000D,dpId=2 Val V=13,26
    IN,55 AA,03,07,00 08,13,02,00 04,00000015,dpId=19 Val V=21,3F
    IN,55 AA,03,07,00 08,13,02,00 04,00000016,dpId=19 Val V=22,40
    IN,55 AA,03,07,00 08,02,02,00 04,0000000C,dpId=2 Val V=12,25
    IN,55 AA,03,07,00 08,02,02,00 04,0000000A,dpId=2 Val V=10,23
    IN,55 AA,03,07,00 08,02,02,00 04,00000008,dpId=2 Val V=8,21
    IN,55 AA,03,07,00 08,02,02,00 04,00000007,dpId=2 Val V=7,20
    IN,55 AA,03,07,00 08,02,02,00 04,00000006,dpId=2 Val V=6,1F
    IN,55 AA,03,07,00 08,02,02,00 04,00000005,dpId=2 Val V=5,1E
    IN,55 AA,03,07,00 08,13,02,00 04,00000017,dpId=19 Val V=23,41
    IN,55 AA,03,07,00 05,01,04,00 01,01,dpId=1 Enum V=1,15
    IN,55 AA,03,07,00 08,02,02,00 04,00000000,dpId=2 Val V=0,19
    IN,55 AA,03,07,00 05,10,01,00 01,00,dpId=16 Bool V=0,20
    IN,55 AA,03,07,00 08,13,02,00 04,00000018,dpId=19 Val V=24,42
    IN,55 AA,03,07,00 08,13,02,00 04,00000019,dpId=19 Val V=25,43
    IN,55 AA,03,07,00 08,13,02,00 04,0000001A,dpId=19 Val V=26,44
    IN,55 AA,03,07,00 08,13,02,00 04,0000001B,dpId=19 Val V=27,45
    
    .
    when gas is detected, 12V appears on the valve control output, read U61 is responsible for boosting the voltage to 12V.

    TX-E gas detector with shut-off valve control function - interior of unit .

    The device consumes approx.180mA in the idle state.

    TX-E gas detector with shut-off valve control function - interior of unit .
    and here pressing the Test button:
    
    Dir.,Header,Vers.,Cmd,Length,DPid,Type,DataLen,Data,Decoded,Checksum
    IN,55 AA,03,07,00 05,08,01,00 01,01,dpId=8 Bool V=1,19
    IN,55 AA,03,07,00 05,09,04,00 01,00,dpId=9 Enum V=0,1C
    IN,55 AA,03,07,00 05,09,04,00 01,01,dpId=9 Enum V=1,1D
    IN,55 AA,03,07,00 05,08,01,00 01,00,dpId=8 Bool V=0,18
    
    .
    system reboot:
    
    Dir.,Header,Vers.,Cmd,Length,DPid,Type,DataLen,Data,Decoded,Checksum
    IN,55 AA,03,01,00 2A,,,,7B2270223A22366A7132307736776E6E346661773239222C2276223A22312E302E30222C226D223A327D,"{""p"":""6jq20w6wnn4faw29"",""v"":""1.0.0"",""m"":2}",41
    IN,55 AA,03,02,00 00,,,,,McuConf,04
    IN,55 AA,03,03,00 00,,,,,WifiState,05
    IN,55 AA,03,07,00 05,01,04,00 01,01,dpId=1 Enum V=1,15
    IN,55 AA,03,07,00 08,02,02,00 04,00000000,dpId=2 Val V=0,19
    IN,55 AA,03,07,00 08,07,02,00 04,00000001,dpId=7 Val V=1,1F
    IN,55 AA,03,07,00 05,08,01,00 01,00,dpId=8 Bool V=0,18
    IN,55 AA,03,07,00 05,0A,01,00 01,01,dpId=10 Bool V=1,1B
    IN,55 AA,03,07,00 05,0B,05,00 01,00,dpId=11 Bitmap V=0,1F
    IN,55 AA,03,07,00 05,0C,01,00 01,01,dpId=12 Bool V=1,1D
    IN,55 AA,03,07,00 05,10,01,00 01,00,dpId=16 Bool V=0,20
    IN,55 AA,03,07,00 05,12,04,00 01,01,dpId=18 Enum V=1,26
    IN,55 AA,03,07,00 08,13,02,00 04,0000001C,dpId=19 Val V=28,46
    IN,55 AA,03,07,00 08,65,02,00 04,00000039,dpId=101 Val V=57,B5
    IN,55 AA,03,07,00 05,66,04,00 01,01,dpId=102 Enum V=1,7A
    IN,55 AA,03,03,00 00,,,,,WifiState,05
    IN,55 AA,03,03,00 00,,,,,WifiState,05
    IN,55 AA,03,20,00 1C,,,,06772E74656D700A772E68756D696469747904772E181B04772E181B,Unk,73
    IN,55 AA,03,1C,00 00,,,,,Date,1E
    IN,55 AA,03,07,00 08,13,02,00 04,0000001C,dpId=19 Val V=28,46
    IN,55 AA,03,1C,00 00,,,,,Date,1E
    IN,55 AA,03,1C,00 00,,,,,Date,1E
    IN,55 AA,03,1C,00 00,,,,,Date,1E
    IN,55 AA,00,21,00 00,,,,,Unk,20
    IN,55 AA,03,1C,00 00,,,,,Date,1E
    IN,55 AA,03,07,00 05,09,04,00 01,01,dpId=9 Enum V=1,1D
    IN,55 AA,03,07,00 05,0A,01,00 01,00,dpId=10 Bool V=0,1A
    
    .

    ---------
    edit2
    The cd of the search, the polecernia issued from the app and what was sent to the device:
    
    turn on gas decode
    55AA00060005080100010115
    OUT,55 AA,00,06,00 05,,,,0801000101,dpId=8 Bool V=1,15
    
    turn OFF gas decode
    55AA00060005080100010014
    OUT,55 AA,00,06,00 05,,,,0801000100,dpId=8 Bool V=0,14
    
    set alarm time to 2 mins
    55AA0006000807020004000000021C
    OUT,55 AA,00,06,00 08,,,,0702000400000002,dpId=7 Val V=2,1C
    
    mute alarm
    55AA0006000510010001011D
    OUT,55 AA,00,06,00 05,,,,1001000101,dpId=16 Bool V=1,1D
    
    umute alarm
    55AA0006000510010001001C
    OUT,55 AA,00,06,00 05,,,,1001000100,dpId=16 Bool V=0,1C
    
    heat alarm value = 61
    55AA00060008650200040000003DB5
    OUT,55 AA,00,06,00 08,,,,650200040000003D,dpId=101 Val V=61,B5
    
    lang Chineese
    55AA00060005660400010075
    OUT,55 AA,00,06,00 05,,,,6604000100,dpId=102 Enum V=0,75
    
    lang English
    55AA00060005660400010176
    OUT,55 AA,00,06,00 05,,,,6604000101,dpId=102 Enum V=1,76
    
    start calibration
    55AA00060005680100010175
    OUT,55 AA,00,06,00 05,,,,6801000101,dpId=104 Bool V=1,75
    
    stop calibration
    55AA00060005680100010074
    OUT,55 AA,00,06,00 05,,,,6801000100,dpId=104 Bool V=0,74
    
    .
  • #4 21324432
    Samezrp1
    Level 13  
    OK, I'm ready to configure, I think I have everything I need. CB3S falsified, connects to WiFi. Soldered in and time to configure.
    I've read the guide , I'm on the Import page on the device and I've relented.

    I don't quite understand the connection between setChannelType and data type, the data type doesn't agree with my definition, e.g.
    TX-E gas detector with shut-off valve control function - interior of unit .

    Could you explain from the example below how to define for the following channel values?

    dpID 1, gas_sensor_status, sent by tuyaMCU, enum, takes the values 0 and 1
    dpID 2, gas_sensor_value, sent by tuyaMCU, val, accepts values 0..100
    dpID 8, gas_decode, received by tuyaMCU, bool, assumes values 0 and 1
    dpID 102, language, received by tuyaMCU, enum, shall have values 0 and 1

    How this relates to the definition:

    dpID 1 .
    gas_sensor_status Enum
    {
    "range": [
    "alarm",
    "normal"
    ]
    }

    dpID 2 .
    gas_sensor_value Integer
    {
    "unit": "%LEL",
    "min": 0,
    "max": 100,
    "scale": 0,
    "step": 1
    }

    The device sends data to the MQTT server:
    TX-E gas detector with shut-off valve control function - interior of unit .
    But it does this randomly, When I call the alarm, it does not send it.

    I also don't really know how to send data to it, e.g. force a calibration:
    
    start calibration
    55AA00060005680100010175
    OUT,55 AA,00,06,00 05,,,,6801000101,dpId=104 Bool V=1,75
    
    .

    And I can see that about every minute it hangs up for a while and sends connection info again, and I think it might be some kind of MCU watchdog, because I don't inform it that there is a WiFi connection. Am I right?
    For now, I am sending this configuration:
    
    ClearIO // clear old GPIO/channels
    lfs_format // clear LFS
    StartupCommand ""  // clear STARTUP
    
    stopDriver *  // kill drivers
    startDriver TuyaMCU
    tuyaMcu_setBaudRate 9600
    tuyaMcu_defWiFiState 4
    
    setChannelType 1 Default
    linkTuyaMCUOutputToChannel 1 val 4
    linkTuyaMCUOutputToChannel 1 MQTT
    
    setChannelType 2 Default
    linkTuyaMCUOutputToChannel 2 val 2
    linkTuyaMCUOutputToChannel 2 MQTT
    
    setChannelType 8 Default
    linkTuyaMCUOutputToChannel 8 val 1
    linkTuyaMCUOutputToChannel 8 MQTT
    
    setChannelType 102 Default
    linkTuyaMCUOutputToChannel 102 val 4
    linkTuyaMCUOutputToChannel 102 MQTT
    
    .
  • #5 21324468
    p.kaczmarek2
    Moderator Smart Home
    Then perhaps let's start there:
    Samezrp1 wrote:
    .
    Well, and I see that about every minute or so it crashes for a while, resends the connection info, and I'm thinking it might be some watchdog from the MCU, because I'm not informing it that there is a WiFi connection. Am I right?
    .
    I posted a topic about this yesterday, it's still further down on the main page:
    How to make the TuyaMCU device send more data? Why are dpIDs not being sent? .
    Read it in its entirety and try to determine if, in your MCUConf (0x02), the packet has any payload (pin indexes) or not?

    I'll add a printf log for ease of reference:
    https://github.com/openshwprojects/OpenBK7231...mmit/e5c407eb1b102b87c94fe4b0b4439b7602fd47a3
    Just be careful with the OTA, because if your MCU resets the chip in the process I don't know if you won't have to solder the wires again.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #6 21324859
    Samezrp1
    Level 13  
    Not directly, but you helped. Indeed the WiFi connection indicator was not stable on the display, sometimes it appeared sometimes it disappeared, but reading the recommended threads I came across a setting that I had not used:
    
    startDriver NTP
    
    .
    after that the module updates the time and sends messages on MQTT.

    And now again I ask for help, I don't know how to find this: how to send a command to Tuya?
    For example, I would like to send a command:
    55AA0021001F0106772E74656D700004000000060A772E68756D696469747900040000005D28
    .
    Which sets the outside temperature and humidity.
    Unfortunately the result I get is:
    Error:CMD:cmd 55AA0021001F0106772E74656D700004000000060A772E68756D696469747900040000005D28 NOT found (args )
    Info:CMD:[WebApp Cmd '55AA0021001F0106772E74656D700004000000060A772E68756D696469747900040000005D28' Result] Unknown command
    .
    As I will know how from the consoli, I should be able to manage with MQTT, unless there's some kind of a trick.

    BTW my autostart looks like this:

    ClearIO // clear old GPIO/channels
    lfs_format // clear LFS
    StartupCommand ""  // clear STARTUP
    stopDriver *  // kill drivers
    startDriver TuyaMCU
    startDriver NTP
    ntp_setLatlong -33.729720 151.160990
    ntp_timeZoneOfs 1
    //tuyaMcu_setBaudRate 9600
    tuyaMcu_defWiFiState 4
    
    setChannelType 1 Default
    linkTuyaMCUOutputToChannel 1 enum 1
    linkTuyaMCUOutputToChannel 1 MQTT
    
    setChannelType 2 Default
    linkTuyaMCUOutputToChannel 2 val 2
    linkTuyaMCUOutputToChannel 2 MQTT
    
    setChannelType 7 Default
    linkTuyaMCUOutputToChannel 7 val 7
    linkTuyaMCUOutputToChannel 7 MQTT
    
    setChannelType 8 Default
    linkTuyaMCUOutputToChannel 8 bool 8
    linkTuyaMCUOutputToChannel 8 MQTT
    
    setChannelType 9 Default
    linkTuyaMCUOutputToChannel 9 enum 9
    linkTuyaMCUOutputToChannel 9 MQTT
    
    setChannelType 10 Default
    linkTuyaMCUOutputToChannel 10 val 10
    linkTuyaMCUOutputToChannel 10 MQTT
    
    setChannelType 11 Default
    linkTuyaMCUOutputToChannel 11 bool 11
    linkTuyaMCUOutputToChannel 11 MQTT
    
    setChannelType 12 Default
    linkTuyaMCUOutputToChannel 12 bool 12
    linkTuyaMCUOutputToChannel 12 MQTT
    
    setChannelType 16 Default
    linkTuyaMCUOutputToChannel 16 bool 16
    linkTuyaMCUOutputToChannel 16 MQTT
    
    setChannelType 18 Default
    linkTuyaMCUOutputToChannel 18 enum 18
    linkTuyaMCUOutputToChannel 18 MQTT
    
    setChannelType 19 Default
    linkTuyaMCUOutputToChannel 19 val 19
    linkTuyaMCUOutputToChannel 19 MQTT
    
    setChannelType 101 Default
    linkTuyaMCUOutputToChannel 101 val 101
    linkTuyaMCUOutputToChannel 101 MQTT
    
    setChannelType 102 Default
    linkTuyaMCUOutputToChannel 102 enum 102
    linkTuyaMCUOutputToChannel 102 MQTT
    
    setChannelType 104 Default
    linkTuyaMCUOutputToChannel 104 bool 104
    linkTuyaMCUOutputToChannel 104 MQTT
    
    .

    I wonder if I can use channels like this, like dpId, or for example for dpId=7 I should use channel #3.

    setChannelType 3 Default
    linkTuyaMCUOutputToChannel 7 val 3
    linkTuyaMCUOutputToChannel 7 MQTT
    
    
    .
  • #7 21324878
    p.kaczmarek2
    Moderator Smart Home
    Samezrp1 wrote:
    Not directly, but you helped. Indeed the WiFi connection indicator was not stable on the display, sometimes it appeared sometimes it disappeared, but reading through the recommended threads I came across a setting that I had not used:
    
    startDriver NTP
    
    .
    after that the module updates the time and sends messages on MQTT.

    And now again I ask for help, I can't find it: how to send a command to Tuya?
    .
    Interesting, so without time it won't send data? You can add this to the thread about dpID, maybe it will help someone:
    https://www.elektroda.pl/rtvforum/topic4089722.html
    And you didn't have it mentioned in the Web App Log:
    
    
    	case TUYA_CMD_SET_TIME:
    		addLogAdv(LOG_INFO, LOG_FEATURE_TUYAMCU, "ProcessIncoming: received TUYA_CMD_SET_TIME, so sending back time");
    		TuyaMCU_Send_SetTime(TuyaMCU_Get_NTP_Time(), false);
    		break;
    
    .




    Samezrp1 wrote:
    .
    And now again I ask for help, I can't find it: how do I send a command to Tuya?
    For example, I would like to send a command:
    55AA0021001F0106772E74656D700004000000060A772E68756D696469747900040000005D28
    .
    Which sets the outside temperature and humidity.
    .
    The preferred solution is to do a linkTuyaMCUOutputToChannel and map the dpID to the channel, but if you want to send without mapping the dpID value then you have the command tuyaMcu_sendState [b]. It will count the checksum itself. Unless you want to send hex, then you have [b]uartSendHex .
    Here are some examples:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md
    Here you have a list of commands:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md



    Samezrp1 wrote:
    .
    As I know how from consola, I should be able to handle MQTT, unless there is some kind of myc.
    .
    You can send anything via MQTT as a command and obk will execute it. Or you can specify an alias and then send the alias content itself.
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/mqttTopics.md
    And what do you want to send from MQTT to this device[/b][/b]?

    Added after 7 [minutes]: .

    Samezrp1 wrote:
    .
    setChannelType 3 Default
    linkTuyaMCUOutputToChannel 7 val 3
    linkTuyaMCUOutputToChannel 7 MQTT
    
    .
    This will not work . This is also redundant.
    As you are already mapping dpID 7 as a value to channel 3, when dpID 7 changes, channel 3 will also change and OBK will execute publish under that channel.... unless it doesn't execute, then attach a flag:
    
    19	[MQTT] Always publish channels used by TuyaMCU
    
    .
    or set channel 7 a type of some kind, e.g. Temperature or Temperature_div10.

    You should do:
    setChannelType 3 Default
    linkTuyaMCUOutputToChannel 7 val 3
    
    .
    And then in Home Assistant you listen to (or send to) channel 3.

    In addition, if channel 3, for example, has the Temperature type set, Home Assistant Discovery from OBK will add it to HA itself
    Helpful post? Buy me a coffee.
  • #8 21324887
    Samezrp1
    Level 13  
    OK, thanks, I will analyse the posting.
    Quote:
    .
    And what do you want from MQTT to send to this device?
    .
    I don't use homeAssistant, I use Node-RED and all communication goes over MQTT. I have all the appliances in the house serviced on this, including the recuperator, lights, partly the air conditioning, I collect temperature information etc.
    De facto I'm unlikely to play with sending, well, but as I'm going to create a definition for this device, it would be good to define all the possibilities to use.
    And you can send the following:
    
    turn on gas decoding
    55AA00060005080100010115
    OUT,55 AA,00,06,00 05,,,,0801000101,dpId=8 Bool V=1,15
    
    turn OFF gas decoding
    55AA00060005080100010014
    OUT,55 AA,00,06,00 05,,,,0801000100,dpId=8 Bool V=0,14
    
    set alarm time to 2 mins
    55AA0006000807020004000000021C
    OUT,55 AA,00,06,00 08,,,,0702000400000002,dpId=7 Val V=2,1C
    
    mute alarm
    55AA0006000510010001011D
    OUT,55 AA,00,06,00 05,,,,1001000101,dpId=16 Bool V=1,1D
    
    umute alarm
    55AA0006000510010001001C
    OUT,55 AA,00,06,00 05,,,,1001000100,dpId=16 Bool V=0,1C
    
    heat alarm value = 61
    55AA00060008650200040000003DB5
    OUT,55 AA,00,06,00 08,,,,650200040000003D,dpId=101 Val V=61,B5
    
    lang Chineese
    55AA00060005660400010075
    OUT,55 AA,00,06,00 05,,,,6604000100,dpId=102 Enum V=0,75
    
    lang English
    55AA00060005660400010176
    OUT,55 AA,00,06,00 05,,,,6604000101,dpId=102 Enum V=1,76
    
    start calibration
    55AA00060005680100010175
    OUT,55 AA,00,06,00 05,,,,6801000101,dpId=104 Bool V=1,75
    
    stop calibration
    55AA00060005680100010074
    OUT,55 AA,00,06,00 05,,,,6801000100,dpId=104 Bool V=0,74
    
    .

    plus you can send the external temperature and humidity (although it does not show it) for display. Normally this is done by the Tuya server based on location.
  • ADVERTISEMENT
  • #9 21324920
    p.kaczmarek2
    Moderator Smart Home
    In my opinion, you should first make a mapping to channels within the OBK according to our examples, e.g:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md
    
    // start MCU driver
    startDriver TuyaMCU
    // let's say that channel 1 is dpid1 - fan on/off
    setChannelType 1 toggle
    // map dpid1 to channel1, var type 1 (boolean)
    linkTuyaMCUOutputToChannel 1 1 1
    // let's say that channel 2 is dpid9 - light on/off
    setChannelType 2 toggle
    // map dpid9 to channel2, var type 1 (boolean)
    linkTuyaMCUOutputToChannel 9 1 2
    //channel 3 is dpid3 - fan speed
    setChannelType 3 LowMidHigh
    // map dpid3 to channel3, var type 4 (enum)
    linkTuyaMCUOutputToChannel 3 4 3
    //dpId 17 = beep on/off
    setChannelType 4 toggle
    linkTuyaMCUOutputToChannel 17 1 4
    //
    //
    //dpId 6, dataType 4-DP_TYPE_ENUM = set timer
    setChannelType 5 TextField
    linkTuyaMCUOutputToChannel 6 4 5
    //
    //
    //dpId 7, dataType 2-DP_TYPE_VALUE = timer remaining
    setChannelType 6 ReadOnly
    linkTuyaMCUOutputToChannel 7 2 6
    
    .
    then once you have this on the panel, you send from Node-Red the values to the channels to set them, and receive publishe from the channels as things change.


    Samezrp1 wrote:
    .
    plus you can send the outside temperature and humidity (although it doesn't show it) for display. Normally this is done by the Tuya server based on location.
    .
    As above, supposedly you can send this command via tuyaMCU_sendState, but it's better to make a TextField and test first in OBK:
    
    setChannelType 5 TextField
    linkTuyaMCUOutputToChannel 6 4 5
    
    .
    Make a TextField and see if it even works to send this. Then you can think about what to do next, maybe I would try to prepare a driver which gets this data from some free service from the internet?
    Helpful post? Buy me a coffee.
  • #10 21325118
    Samezrp1
    Level 13  
    OK, it's slowly becoming clearer.
    Quote:
    .
    Make a TextField and see if it even works to send that. Then you can think about what to do next, maybe I would try to prepare a driver which gets this data from some free service from the internet?

    command:
    setChannelType 2 Default

    doesn't expose any element on the panel, which is why I was dumbfounded, and not sure which one, so I assumed with Default it would be safe. Error. The text field is cool and universal.
    I now have working fields on the panel, I can set their values, I can read them, the system sends the data, it seemed almost, almost, but....

    Two issues.

    First: .
    resolved, for some reason the time on the device set itself to 2070 and stayed that way, despite a reset. Obviously the 2000 was added by the device itself, because as you can see it's just a Unix Epoch start time, the Chinese assumed you had to add 2000 to the date.
    The solution is to force the time to be sent from the TuyaMCU to the MCU (from CB3S to the device MCU), with the command:
    tuyaMcu_sendCurTime
    .
    TX-E gas detector with shut-off valve control function - interior of unit .
    Second: .
    Channels with dpID pow 100 do not appear on my panel, read: 101, 102 and 104.
    TX-E gas detector with shut-off valve control function - interior of unit .

    On configuration:
    TX-E gas detector with shut-off valve control function - interior of unit .

    edit: .
    It looks like there is a dpID counter up to 100, it bugs me that I read that up to 100 are Tuya ID and above user, you can see that those pow 100 overwrite the values from zero:
    TX-E gas detector with shut-off valve control function - interior of unit .

    these values according to the screenshot above should be 1 and 0 respectively:
    TX-E gas detector with shut-off valve control function - interior of unit .

    edit2: .
    I changed the configuration of the channels, I started from 1 to 14, and according to this below already looks like everything is ok :) .
    Now just testing and changing the read-only value (e.g. temp sent by MCU) to ReadOnly:

    
    //co_value	Integer, temperature value
    setChannelType 11 TextField
    setChannelLabel 11 co_value_(dpId=19)
    linkTuyaMCUOutputToChannel 19 val 11
    
    //heat_alarm_value integer
    setChannelType 12 TextField
    setChannelLabel 12 heat_alarm_value_(dpId=101)
    linkTuyaMCUOutputToChannel 101 val 12
    
    //lang Chineese=0, EN=1
    setChannelType 13 TextField
    setChannelLabel 13 Lang_(0=CN,1=EN)(dpId=102)
    linkTuyaMCUOutputToChannel 102 enum 13
    
    //calibration, start = 1, stop = 0
    setChannelType 14 TextField
    setChannelLabel 14 calibration_start=1,stop=0 (dpId=104)
    linkTuyaMCUOutputToChannel 104 bool 14
    
    .

    Sorry for the edits, but sometimes while writing something I came up with another idea to check :)
  • #11 21325209
    p.kaczmarek2
    Moderator Smart Home
    Samezrp1 wrote:
    .
    command:
    setChannelType 2 Default
    .
    doesn't expose any element on the panel, which is why I was dumbfounded, and wasn't sure which one, so I assumed with Default it would be safe. Error. The text field is cool and universal.
    .
    It seems to me that the ReadOnly field will be read-only and also visible on the panel. Default is the default mode, if Default was visible on the panel then after uploading the firmware there would be 64 channels visible on the panel....


    Samezrp1 wrote:
    .
    The solution is to force the time to be sent from the TuyaMCU to the MCU (from CB3S to the device MCU), with the command:
    tuyaMcu_sendCurTime
    .
    TX-E gas detector with shut-off valve control function - interior of unit .
    .
    Possibly, supposedly in theory the MCU should ask itself, but it varies:
    TX-E gas detector with shut-off valve control function - interior of unit

    Samezrp1 wrote:
    .
    Second: .
    Channels with dpID pow 100 do not appear on my panel, read: 101, 102 and 104.
    TX-E gas detector with shut-off valve control function - interior of unit .
    On configuration:
    TX-E gas detector with shut-off valve control function - interior of unit .
    .
    Unfortunately the channels are only up to 64, so it is not possible to do as nice a mapping as you would like. This is due, among other things, to memory savings and the fact that TuyaMCU support was added gradually, at first I thought the dpIDs were always from 1, not that they suddenly jump to 100....

    Samezrp1 wrote:
    .
    
    //co_value	Integer, temperature value
    setChannelType 11 TextField
    setChannelLabel 11 co_value_(dpId=19)
    linkTuyaMCUOutputToChannel 19 val 11
    
    //heat_alarm_value integer
    setChannelType 12 TextField
    setChannelLabel 12 heat_alarm_value_(dpId=101)
    linkTuyaMCUOutputToChannel 101 val 12
    
    //lang Chineese=0, EN=1
    setChannelType 13 TextField
    setChannelLabel 13 Lang_(0=CN,1=EN)(dpId=102)
    linkTuyaMCUOutputToChannel 102 enum 13
    
    .
    .
    If you want a specific channel type I can add on request, although ultimately I intend to add customisation of these.
    Additionally, for pretty custom devices there is an option to do a custom panel in HTML and Javascript, with no restrictions:
    Alternative HTML control page for TOMPD-63-WIFI .


    So what's left now? Those moisture/temperature retrievals for latitude and longitude from the network, do I understand correctly?
    Helpful post? Buy me a coffee.
  • #12 21325415
    Samezrp1
    Level 13  
    Quote:
    It seems to me that the ReadOnly field would be read-only and also visible on the panel. Default is the default mode, if Default was visible on the panel, then 64 channels would be visible on the panel after uploading the firmware....
    .
    So it's all clear.
    Quote:
    Possible, supposedly in theory the MCU should query itself, but it varies:
    .
    I'll keep observing, as I get the impression that it has lost time after a while, but this I need to confirm.
    Quote:
    Unfortunately, the channels are only up to 64, so it's not possible to do as nice a mapping as you'd like.

    I will survive :) .
    Quote:
    If you want a particular type of channel then I can add on request, although ultimately I intend to add their customisation.
    .
    I was thinking of a toggle type channel, but only for reading, ew options for each RO channel.
    This is useful for flagging out. E.g. here you turn on an internal test and the device puts a separate FAIL flag high as long as the test passes. After a positive test it changes to low.
    Quote:
    So what is left now? Those moisture/temperature retrievals for latitude and longitude from the grid, I understand correctly?
    .
    I'm honestly wondering because to no avail with this information, the temperature measurement is that I have 32 degrees in my room, so I wouldn't use the device for that, and the time spent on it may not be worth the effect,
  • #13 21325830
    p.kaczmarek2
    Moderator Smart Home
    Samezrp1 wrote:
    .
    I will be observing, as I have the impression that it has lost time after some time, but this I need to confirm.
    .
    You can send time at regular intervals using addRepeatingEvent . It is worth including TuyaMCU queue in the flags for stability.



    Samezrp1 wrote:
    .
    I was thinking about a toggle type channel, but only for reading, ew options for each RO channel.
    .
    And what would such a toggle look like?


    Samezrp1 wrote:
    .
    I honestly wonder because to no avail with this information, the temperature measurement is that I have 32 degrees in my room, so I wouldn't use the device for that, and the time spent on it might not be worth the effect,
    .
    Maybe for sport I'll give it a try.
    Or would it make sense to connect e.g. the DHT11 to the WiFi module and configure it to give these measurements?


    PS: I think you are pasting autoexec.bat in the wrong place;


    .
    Helpful post? Buy me a coffee.
  • #14 21326278
    Samezrp1
    Level 13  
    p.kaczmarek2 wrote:
    .
    You can send time at regular intervals using addRepeatingEvent . It is worthwhile to enable TuyaMCU queue in flags for stability.

    OK
    Quote:
    .
    And what would such a toggle look like?
    .
    I was thinking exactly like the current one, but with no clickability, possibly with a little information in the year: RO, czt ReadOnly

    Quote:
    .
    Maybe I will try it for sport.
    Or would it make sense to connect e.g. a DHT11 to the WiFi module and configure it to give these measurements?
    .
    Presumably this command is used to do this:
    TX-E gas detector with shut-off valve control function - interior of unit .
    
    55AA0320001C06772E74656D700A772E68756D696469747904772E181B04772E181B73
    
    .
    But I can't send it without soldering it to the MCU. I couldn't find the dpId to it. BTW it also sends humidity but doesn't display anywhere.
    That's what I'm thinking anyway, I don't know if there's any point in connecting a physical sensor. I would sooner make it so that from the outside (MQTT, HA, whatever) it sends this value to some channel, the problem I see is that there is no dpId that can be connected to this channel. I have attached the logs, as for me the unknown long ones are responsible for this, but without checking i.e. sending a pure message to the MCU for the moment I am not able to confirm.
    Quote:
    .
    PS: probably in the wrong place you paste autoexec.bat;
    .
    And I put autoexec.bat in FS, in the import tab I just put its contents, because there it tells me immediately if there are errors. Then I put it into the file system.
  • #15 21326734
    p.kaczmarek2
    Moderator Smart Home
    Samezrp1 wrote:
    .
    
    55AA0320001C06772E74656D700A772E68756D696469747904772E181B04772E181B73
    
    .
    But I can't send it without soldering it to the MCU. I have not found the dpId to it.
    .
    If you're stubborn, you can use UartSendHex, but then you have to count the checksum yourself as you change the contents of the packet. tuyaMcu_sendState you won't use, because it's not a dpID, it's a 0x20 type command:
    TX-E gas detector with shut-off valve control function - interior of unit .
    It is best to use tuyaMcu_sendCmd here:
    https://www.elektroda.com/rtvforum/find.php?q=tuyaMcu_sendCmd
    Helpful post? Buy me a coffee.
  • #16 21327165
    Samezrp1
    Level 13  
    >>21326734 .
    UartSendHex works , I made myself a checksum calculator:
    
    UartSendHex 55AA0021001F0106772E74656D700004000000160A772E68756D696469747900040000005B36
    .
    The temperature value in hex is on 20 byte, higher = 16 i.e. 22 dec.
    For negative temperatures:
    
    Hex	Dec	Temp
    76	118	118
    77	119	119
    78	120	120
    79	121	121
    80	128	-28
    88	136	-20
    92	146	-10
    96	150	-6
    99	153	-3
    9C	156	0
    9D	157	-99
    9F	159	-97
    A0	160	-96
    AA	170	-86
    CC	204	-52
    DD	221	-35
    DF	223	-32
    E0	224	not read
    E1	225	not read
    EE	238	not read
    FF	255	not read
    
    .
  • #17 21327447
    p.kaczmarek2
    Moderator Smart Home
    You don't have to count the checksum yourself, tuyaMcu_sendCmd will do it for you. There are two arguments - the command and the payload. The length of the payload is determined by itself, as is the checksum.

    It is now a question of how negative values are encoded....
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #18 21327590
    Samezrp1
    Level 13  
    p.kaczmarek2 wrote:
    .
    It is now a question of how negative values are encoded...
    .
    I'm looking and generally from -28 degrees (0x80) to zero (0x9C) they go linearly, upwards, missing from -29 to -31, then from -32 (0xDF) to -99 (0x9D) also linearly.

    BTW I extracted the flash and got dumbfounded.... I was expecting some kind of uboot, and there.... looks like the MSDOS 5.0 partition is sitting, although binwalk doesn't recognise it :/.

    TX-E gas detector with shut-off valve control function - interior of unit .
    TX-E gas detector with shut-off valve control function - interior of unit .
    I have sub-mapped it with losetup on Ubuntu, but it shows some of the contents (system.zip). I need to poke around more.

    It looks like only the media is in the eeprom.

    As for the encoding of the negative values it looks like this (the few values useful for russian, between 29..32 IMHO can be ignored, or all lower than 28):
    
    int DecodeTemp(int temperature) {
        if (temperature >= 0) {
            return temperature;
        }
    
        int decodedTemp = 256;
    
        if (temperature >= -28 && temperature <= 0) {
            decodedTemp = decodedTemp + temperature - 100;
        } else if (temperature >= -99 && temperature <= -33) {
            decodedTemp = decodedTemp + temperature;
        } else {
            decodedTemp = temperature;
        }
    
        return decodedTemp;
    }
    
    .
  • #19 21328336
    p.kaczmarek2
    Moderator Smart Home
    So a function that sends data in a packet of type 0x20 with ASCII names and with number conversion according to your function is useful?



    I was interested in the topic of "weather" for a given position on the map, no problem with that, I will add a driver of that to OBK:
    TX-E gas detector with shut-off valve control function - interior of unit .

    Added after 28 [seconds]: .

    PS: I don't know if you've seen: OpenBeken IoT device simulator - first early alpha version for testing
    Helpful post? Buy me a coffee.
  • #20 21328349
    Samezrp1
    Level 13  
    p.kaczmarek2 wrote:
    Is it useful to have a function that sends data in a packet of type 0x20 with ASCII names and with number conversion according to your function?
    .
    Yes, then the functionality remains 1:1 after de-clouding.
    Quote:
    .
    I have taken an interest in the subject of "weather" for a given position on the map, no problem with that, I will add a driver for that to OBK:
    .
    Then the temperature could be taken either from your thermometer, or as in the original based on downloaded data.
    Quote:
    .
    Yes, I hit it, but I couldn't find CB3S in the library and gave up. Too soon?

    Hm... falsepositive?
    TX-E gas detector with shut-off valve control function - interior of unit

    BTW I have at least 3 more devices to add.
    Smoke, CO and flood detector, none of my models are in the library.
    It might be worse than here, because here I didn't have to embrace the TuyaMCU pins, everything flew on the UART. But what are long winter evenings for :) .
  • #21 21328381
    p.kaczmarek2
    Moderator Smart Home
    You don't need to download the old zip from the forum, there is the latest zip with the simulator on the repository:
    https://github.com/openshwprojects/OpenBK7231T_App
    In Releases.

    The simulator "doesn't know" about WiFi modules, there is one module there rigidly, everything works (almost) the same between different BK7231. So more precisely it is a Windows OBK port, so it does not simulate BK registers, but it is suitable anyway for testing drivers, scripts, MQTT, page.

    As the OpenWeatherMap support I will give to the driver which will write the results to the channels, the whole thing can be modularly incorporated and also replaced e.g. via DHT11, both versions will work.

    I am happy to help with further devices, if you want, please create a topic in the appropriate forum.
    Helpful post? Buy me a coffee.
  • #22 21330469
    p.kaczmarek2
    Moderator Smart Home
    Progress with OpenWeatherMap integration:

    TX-E gas detector with shut-off valve control function - interior of unit .
    Helpful post? Buy me a coffee.
  • #23 21330551
    Samezrp1
    Level 13  
    And how do we send the data?
    I think the most convenient way would be to send an HTTP request from:
    
    tuyaMcu_sendCmd komenda payload
    
    .
    and the payload created by "that" which would call tuyaMcu_sendCmd, only in this case it's TuyaMCU itself....
📢 Listen (AI):

Topic summary

The discussion centers on the TX-E gas leak detector featuring a gas shut-off valve controlled via a TuyaMCU-based system communicating over UART. The device is powered via USB-C, lacks a battery, and integrates a display showing gas detection status, temperature (local and cloud-based), and alarm functions. Communication analysis revealed all signals pass through UART with no peripheral support on the CB3S chip. Users explored TuyaMCU protocol details, including dpID mappings for gas sensor status, alarm time, and control commands such as toggling gas decoding and muting alarms. Challenges included unstable WiFi connection indicators, time synchronization issues resolved by forcing time updates via tuyaMcu_sendCurTime, and handling dpIDs above 64 which are not natively supported in channel mapping. Negative temperature encoding was reverse-engineered, revealing a linear scale with gaps. Flash memory extraction showed an unexpected MSDOS 5.0 partition structure. Solutions involved using OpenBK7231T firmware tools for flashing and UART packet decoding, leveraging MQTT for integration with Node-RED, and configuring channel types and mappings for device control and monitoring. The discussion also touched on extending functionality with OpenWeatherMap integration and custom HTML panels for advanced device control. Commands for sending raw hex data and using tuyaMcu_sendCmd were detailed for precise device communication.
Summary generated by the language model.
ADVERTISEMENT