logo elektroda
logo elektroda
X
logo elektroda

Tuya TYTE-D1 Smart Switch: Relay Works, Temperature Sensor find

marcolueck1976 6723 39
Best answers

How can I make the external temperature sensor on a Tuya TYTE-D1 smart switch work in OpenBeken?

The TYTE-D1 uses a DS18B20/DS1820-style one-wire sensor on GPIO P26, so the relay can work while temperature stays empty unless that pin is configured and the DS18B20 driver is running [#21147604][#21138205] The device template shown in the thread maps this as `one_wire_pin: 26`, and the sensor was later identified as a Sensylink CT1820B clone, which still needs the DS18B20/DS1820 driver support [#21147604][#21158431] In OpenBeken, start the driver with `startDriver DS1820` and make it persistent in startup if needed [#21155826][#21501442] If you want the temperature to appear properly in MQTT/Home Assistant, set the temperature channel type to `Temperature_div100` for the DS1820/DS18B20 channel and rerun HA discovery [#21688949][#21689034][#21689056][#21689460]
Generated by the language model.
ADVERTISEMENT
  • #1 21135669
    marcolueck1976
    Level 8  
    Posts: 32
    Rate: 1
    Hi there!

    Here is my new project:
    Tuya Smart Switch
    TYTE-D1 Wifi / bluetooth temperature relay

    I've flashed it, works fine, get the power parameters, relay is working, but I can not get the temperature.

    White Tuya smart switch model TYTE-D1 with visible technical specifications. Tuya Smart Switch circuit board with electronic components including CB3S module.


    Code: JSON
    Log in, to see the code

    Screenshot of a web interface showing relay status.

    I want to use the relay to work with my aquarium heater, there is an external temperature sensor.

    Where is my fault?
    Attachments:
    • readResult_BK7231N_QIO_SmartSwitch_2024-28-6-12-25-12.bin (2 MB) You must be logged in to download this attachment.
  • ADVERTISEMENT
  • #2 21135733
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14406
    Help: 650
    Rate: 12345
    Hello, what kind of sensor is there? Which GPIO is used? Is it supported?
    Helpful post? Buy me a coffee.
  • #3 21135746
    marcolueck1976
    Level 8  
    Posts: 32
    Rate: 1
    >>21135733
    It's an external sensor via 3.5mm plug.
    External sensor connected via a 3.5 mm plug to a white device on a measurement grid.
    I don't know the GPIO pin.

    That's the output from the flasher.

    Code: JSON
    Log in, to see the code
  • #4 21135749
    divadiow
    Level 38  
    Posts: 4850
    Help: 421
    Rate: 854
    I flashed your dump and factory reset it. This is the boot log

    Code: Text
    Log in, to see the code


    obviously I don't have the sensor attached, but it looks quite clear from the reset fail messages it's a DS18B20 sensor from Analog Devices

    https://www.analog.com/en/products/ds18b20.html

    Tuya API response gives this a model of 1-POTH
    Attachments:
    • ds18b20.pdf (382.99 KB) You must be logged in to download this attachment.
  • #5 21135907
    marcolueck1976
    Level 8  
    Posts: 32
    Rate: 1
    Sorry, I don't understand much of coding. Can you say what I could do to bring the sensor to work?
  • #6 21138205
    divadiow
    Level 38  
    Posts: 4850
    Help: 421
    Rate: 854
    If you have a multimeter you could trace to where it goes on the CB3S module. But still, a driver would need writing for the DS18B20 I imagine.
  • #7 21139176
    marcolueck1976
    Level 8  
    Posts: 32
    Rate: 1
    That sounds not so good for me. Is it possible that someone can write a driver and help me at this project. I ordered more of these things. some days ago, somebody added this thing to the database, but temperature is not working there...

    Thank you for your help :-)

    Hinzugefügt nach 1 [Stunden]:

    >>21138205I try, but can´t find anything
  • Helpful post
    #8 21139326
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14406
    Help: 650
    Rate: 12345
    I can look into it once I finish IR2 driver for remotes. Maybe.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • Helpful post
    #9 21147604
    divadiow
    Level 38  
    Posts: 4850
    Help: 421
    Rate: 854
    The GPIO for DS18B20 on the TYTE-D1 is P26

    "sel_pin_pin":"9",
    "bt1_pin":"7",
    "vi_pin":"6",
    "netled_pin":"14",
    "one_wire_pin":"26",
    "ele_pin":"24",
    "rl1_pin":"8"

    one_wire_pin could be a new detection for Easy Flasher I guess. I've not seen this for any other device though.

    I didn't know One Wire was a standard

    Code: Text
    Log in, to see the code


    for the record here is what the Tuya app options look like for TYTE-D1

    Tuya app interface showing current temperature. Tuya app on a phone displaying temperature and automation options. Screenshot from the Tuya app for TYTE-D1 with an error message and statistics. Screenshot of the Tuya app showing humidity statistics for TYTE-D1. Tuya app interface on TYTE-D1 showing current temperature 24.4°C, autowork settings, and options: timer, countdown. Tuya app screen with added device.
  • #10 21147863
    marcolueck1976
    Level 8  
    Posts: 32
    Rate: 1
    Hi :-)

    Sounds very good! Maybee i can test it tomorrow.

    Is there an option that after an power failure the relay switches in the state before? Like at led´s. That would be great, because the relay should be for my aquarium heater, would not good to have an power failure or something else. I look in the config but can not find ???
  • Helpful post
    #11 21147868
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14406
    Help: 650
    Rate: 12345
    Maybe in "Configure startup" tab? You can set channel there to remember it's state.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #12 21147893
    divadiow
    Level 38  
    Posts: 4850
    Help: 421
    Rate: 854
    marcolueck1976 wrote:
    Sounds very good! Maybee i can test it tomorrow.

    but! I only added more information. The DS18B20 still needs a driver...
  • ADVERTISEMENT
  • #13 21150110
    marcolueck1976
    Level 8  
    Posts: 32
    Rate: 1
    Sorry, i forgot :-(
  • #14 21155826
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14406
    Help: 650
    Rate: 12345
    Helpful post? Buy me a coffee.
  • Helpful post
    #15 21158223
    divadiow
    Level 38  
    Posts: 4850
    Help: 421
    Rate: 854
    Tuya TYTE-D1 Smart Switch: Relay Works, Temperature Sensor find
  • #16 21158425
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14406
    Help: 650
    Rate: 12345
    Wait @divadiow, is DS18B20 working for you now?
    Helpful post? Buy me a coffee.
  • Helpful post
    #17 21158431
    divadiow
    Level 38  
    Posts: 4850
    Help: 421
    Rate: 854
    I have not progressed since last post on closed PR comments. I was posting 3.5mm jack continuity findings for the record

    Added after 10 [hours] 50 [minutes]:

    with an adapted single Arduino sketch to combine the print_family, check_fake and discover_fake examples from https://github.com/koendv/CheckDS18B20/tree/main with the DQ (data) pin connected to D4/GPIO2 of an ESP8266 NodeMCU we can see that the DS18B20 in my TYTE-D1 is a Sensylink clone - CT1820B

    Code: Arduino
    Log in, to see the code


    Screenshot of results checking DS18B20 chip for clone.

    https://en.sensylink.com/html/web/product/wdcgq/xpbdcw/1662800678185840642.html

    ESP8266 NodeMCU board connected to a breadboard with wires.
    Attachments:
    • sensylink_ct1820b.pdf (241.22 KB) You must be logged in to download this attachment.
  • #19 21177195
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14406
    Help: 650
    Rate: 12345
    DS18B20 driver has progressed a lot since last time. @divadiow , is the DS18B20 working for you?
    Helpful post? Buy me a coffee.
  • #20 21177339
    divadiow
    Level 38  
    Posts: 4850
    Help: 421
    Rate: 854
    well. the latest I know is that on BL602 the driver seems good https://github.com/openshwprojects/OpenBK7231T_App/pull/1294

    but regarding the TYTE-D1 and Beken the latest is that with startDriver DS1820 18 the fewest CRC errors are seen with PR build 1296_merge_7117258cf00e with powersave 0. I don't think I found a working timing with powersave 1

    https://www.elektroda.com/rtvforum/topic4056286-30.html#21165621

    I think @max4elektroda was going to do something with a logic analyser
  • #22 21254905
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14406
    Help: 650
    Rate: 12345
    That's nice, did anyone already test that? I can merge it today.
    Helpful post? Buy me a coffee.
  • #23 21255243
    divadiow
    Level 38  
    Posts: 4850
    Help: 421
    Rate: 854
    Not sure. I don't get the impression it has been tested reading the GH chat. 4 PR builds awaiting approval.
  • #24 21255609
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14406
    Help: 650
    Rate: 12345
    I see, I've approved the build.
    Helpful post? Buy me a coffee.
  • #26 21316992
    Lawk1961
    Level 1  
    Posts: 1
    Looks as if there is a sub GHz radio as well. Coiled antenna opposite the WiFi module. Top label says 433MHz
  • #27 21379314
    teriall
    Level 1  
    Posts: 1
    Hello everyone, I am trying to set up a DS18B20 temperature sensor with OpenBeken on a BK7231N chip, but unfortunately, I am unable to get it to display any temperature readings.

    I have already configured GPIO 26 as DS1820_IO and made sure to start the DS18B20 driver. However, the web interface keeps showing "0 drivers active," and no temperature data is available.

    I have tested the sensor on another platform, and it works fine there. The MQTT connection is working, but no temperature readings are being published to the MQTT broker either.

    All other components, such as the relay, button, and WiFi LED, are working perfectly. I checked the logs and did not find any errors related to the DS18B20 sensor.

    Could someone please guide me on what might be going wrong or suggest any additional steps I should try? I really appreciate any help you can provide. Thank you!
  • #28 21382258
    divadiow
    Level 38  
    Posts: 4850
    Help: 421
    Rate: 854
    what version of OpenBeken are you running?
  • #29 21382890
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14406
    Help: 650
    Rate: 12345
    I am waiting for final shipment of DS18B20 set from China, so I will be most likely soon able to add DS18B20 to my test boards. I'll check this out and let you know. Please remind me if I forget (like in a week or two).
    Helpful post? Buy me a coffee.
  • #30 21382943
    divadiow
    Level 38  
    Posts: 4850
    Help: 421
    Rate: 854
    OK for me on latest on P26


    OpenBK7231N_E5B79F33 settings screen displaying temperature and Wi-Fi information

Topic summary

✨ The discussion centers on the Tuya TYTE-D1 smart switch featuring a BK7231N chip and an external DS18B20 temperature sensor connected via a 3.5mm jack. The relay and power measurement functions operate correctly, but temperature readings are initially unavailable due to missing driver support. GPIO 26 is identified as the One-Wire data pin for the DS18B20 sensor. Community members have been developing and porting a DS18B20 driver for the OpenBeken firmware, with progress including pull requests and testing on the CB3S board variant. The One-Wire protocol characteristics and sensor clone identification (Sensylink CT1820B) were discussed. Users seek guidance on enabling temperature reporting to MQTT and Home Assistant, with suggestions to start the DS1820 driver via custom commands and configure startup scripts. Additional features like relay state retention after power failure were queried, with configuration options suggested. Some users report partial success with the driver on GPIO 26, while others face issues with driver activation and temperature data publishing. The relay's load capacity and behavior under varying heater loads were also discussed. The latest OpenBeken builds include a DS18B20 driver and device template for TYTE-D1, facilitating integration of temperature sensing alongside relay control and power monitoring.
Generated by the language model.

FAQ

TL;DR: For TYTE-D1 owners, the fix is simple: map the 3.5 mm probe to GPIO P26, then start the DS18B20 driver. As one expert put it, "The GPIO for DS18B20 on the TYTE-D1 is P26." This FAQ solves the common OpenBeken problem where relay and BL0937 power metering work, but temperature does not. [#21147604]

Why it matters: If you use the TYTE-D1 for heaters or aquariums, correct sensor setup determines whether the device can switch loads based on real probe temperature instead of relay state alone.

Option GPIO / Setting Status in thread Main limitation
TYTE-D1 on BK7231N/CB3S P26 + DS1820_IO Eventually working in later builds Early builds needed manual driver start and had CRC/timing issues
BL602 test path startDriver DS1820 18 discussed Better results reported earlier Not the TYTE-D1 hardware
Power metering path BL0937 on P6/P9/P24 Worked from the start Unrelated to probe detection

Key insight: GPIO mapping alone was not enough. The thread shows the TYTE-D1 needed both the correct pin assignment on P26 and a working DS18B20 driver path in OpenBeken before temperature, MQTT, and Home Assistant reporting became reliable. [#21276251]

Quick Facts

  • TYTE-D1 template data identified a BK7231N chip on a CB3S module, with relay on P8, button on P7, Wi-Fi LED on P14, and BL0937 metering on P6/P9/P24. [#21135746]
  • Tuya configuration exposed one_wire_pin:"26", which directly led to the TYTE-D1 external probe being mapped to GPIO P26. [#21147604]
  • The final OpenBeken template added "26": "DS1820_IO;2" and device keywords including DS18B20, DS1820B, and sensylink. [#21276251]
  • One user reported the relay is labeled AC85-250V, 3000W/16A, yet with a heater it could trip after about 5 seconds when load rose slightly above 1 kW. [#21445968]
  • For Home Assistant, setting the sensor channel type to Temperature_div100 made the external probe appear as a separate temperature entity after HA Discovery. [#21689034]

How do I get the temperature sensor working on a Tuya TYTE-D1 after flashing OpenBeken when the relay and power metering already work?

Set the probe pin to P26 as DS1820_IO and start the DS18B20 driver. The thread shows relay and BL0937 metering can work first, while temperature stays missing until the one-wire probe is mapped and the driver is active. The later TYTE-D1 template explicitly added "26": "DS1820_IO;2", which was the turning point for temperature support on this device. [#21276251]

Which GPIO pin is used for the external temperature probe on the Tuya TYTE-D1, and how was P26 identified as the one-wire pin?

The external temperature probe uses GPIO P26. It was identified from the extracted Tuya configuration, which exposed one_wire_pin:"26"; that matched the device’s external probe design and later template work. A key thread conclusion stated directly: "The GPIO for DS18B20 on the TYTE-D1 is P26." [#21147604]

What does the OpenBeken command "startDriver DS1820" do, and where should I add it so the DS18B20 driver starts automatically after reboot?

startDriver DS1820 starts the DS18B20 one-wire temperature driver in OpenBeken. To make it persistent, add it once under Execute Custom Command for testing, then place the same command in Configure Startup so it runs after every reboot. A later user confirmed this exact startup method, alongside other startup commands like NTP, on March 30, 2025. [#21501442]

Why does the TYTE-D1 boot log show repeated "ds18b20 reset fail" messages, and what does that usually mean during troubleshooting?

Those messages usually mean OpenBeken is trying to talk to a DS18B20-class sensor but the bus is not responding. In the thread, repeated ds18b20 reset fail lines appeared because the test unit was booted without the sensor attached, so the firmware could not complete one-wire reset detection. During troubleshooting, treat that log as a sign to check probe presence, wiring, driver start, and the selected GPIO. [#21135749]

How can I configure GPIO 26 as DS1820_IO correctly on a BK7231N / CB3S-based TYTE-D1 in OpenBeken?

Configure P26 as DS1820_IO and bind it to a data channel, typically channel 2 on this device. The working TYTE-D1 template for the BK7231N / CB3S hardware used "26": "DS1820_IO;2", which means GPIO 26 carries the one-wire sensor and reports into channel 2. After that, start the driver so readings actually begin. [#21276251]

What is One-Wire, and how does it relate to DS18B20 temperature probes used in Tuya devices like the TYTE-D1?

One-Wire is the protocol used by the TYTE-D1’s DS18B20-style probe on P26. "One-Wire" is a serial communication standard that uses a single data line, supports uniquely addressed devices, and is commonly used by DS18B20-class temperature sensors for simple low-speed sensing over minimal wiring. That is why the Tuya config named the probe line one_wire_pin. [#21147604]

What is the CB3S module in the TYTE-D1, and why does it matter when setting up OpenBeken on a BK7231N device?

CB3S is the TYTE-D1’s Wi-Fi module, and it matters because it tells you the device uses a BK7231N platform. "CB3S" is a Tuya Wi-Fi module that hosts the BK7231N chip, defines the device’s GPIO environment, and determines which OpenBeken firmware and pin mapping you must use. In this thread, the extracted Tuya config explicitly identified module:"CB3S". [#21135746]

How do I make the TYTE-D1 relay remember its last state after a power failure using OpenBeken's startup configuration?

Use the Configure startup tab and set the relay channel to remember its previous state. The thread answer was short but clear: OpenBeken lets you configure the channel there so it restores the last known relay state after power returns. That matters for heater use, where an unexpected off-state after an outage can be a practical problem. [#21147868]

What's the difference between a genuine DS18B20 and a Sensylink CT1820B clone, and could that affect compatibility on the TYTE-D1?

Yes, the difference can affect compatibility because the TYTE-D1 probe in one tested unit was identified as a Sensylink CT1820B clone, not a genuine Maxim/Analog DS18B20. The thread linked that finding to driver maturity and timing behavior, which helps explain why early OpenBeken work showed CRC problems and inconsistent results on BK7231N. A clone can look compatible yet still stress marginal timing. [#21158431]

How do I trace the 3.5 mm temperature probe wiring on a TYTE-D1 with a multimeter to find where the sensor connects on the board?

Use continuity mode and trace from the 3.5 mm jack to the CB3S module or nearby routing points. 1. Put one probe on each jack contact. 2. Check continuity to exposed pads, vias, or module pins. 3. Match the traced line against known TYTE-D1 GPIO assignments, especially P26. The thread suggested this method before the one-wire pin was fully confirmed. [#21138205]

Why does OpenBeken show "0 drivers active" even after setting P26 to DS1820_IO, and what additional steps should I check?

OpenBeken can show "0 drivers active" if you mapped the pin but did not actually start the DS18B20 driver. Check three things: 1. P26 is set to DS1820_IO. 2. startDriver DS1820 was executed. 3. The firmware version is recent enough to include the working driver path. In January 2025, this exact symptom appeared even though relay, button, LED, and MQTT were already working. [#21379314]

How can I publish the TYTE-D1 external temperature to MQTT and Home Assistant instead of only seeing the raw channel value?

Map the DS18B20 reading to a channel and then expose that channel with the correct type so Home Assistant treats it as temperature. A later thread fix showed that once the sensor value sat on channel 2 and the channel type was set properly, HA Discovery created a usable temperature entity instead of only leaving a raw numeric channel. That also solved the MQTT/HA visibility issue for at least two users. [#21689460]

Which OpenBeken channel settings are needed so a DS18B20 reading appears properly in Home Assistant, including the Temperature_div100 channel type?

Use the DS18B20 data channel, then set its type to Temperature_div100. One working example used channel 2, where a raw value of 2468 represented 24.68°C, and after a new HA Discovery run the external probe appeared as a separate temperature entity. You can also set it by command: setChannelType 2 Temperature_div100. [#21689056]

BK7231N vs BL602 for DS18B20 support in OpenBeken — which platform had better results in the thread and what timing or powersave issues were reported?

BL602 showed better DS18B20 results earlier in the thread. For BK7231N on the TYTE-D1, the best report was with startDriver DS1820 18, PR build 1296_merge_7117258cf00e, and powersave 0; the user said they did not find a working timing with powersave 1. That makes BK7231N the trickier platform here, especially during the driver’s development phase. [#21177339]

How can I troubleshoot a TYTE-D1 relay that disconnects a heater after about 5 seconds when the load goes slightly above 1 kW, and what options exist to handle that safely?

Treat it as a protection or load-handling limit and do not raise limits blindly. In the thread, a user saw shutdown after about 5 seconds when a heater exceeded roughly 1 kW, despite a 3000W/16A label. Safe options from the thread are limited: verify real load with metering, test with lower power, and avoid modifying protection thresholds without understanding the hardware. The discussion did not provide a safe +10% increase method. [#21445968]
Generated by the language model.
ADVERTISEMENT