{"id":37702050,"url":"https://github.com/uspass/tuya-water-leak-sensor","last_synced_at":"2026-01-16T13:00:55.646Z","repository":{"id":41966169,"uuid":"167725625","full_name":"uspass/Tuya-Water-Leak-Sensor","owner":"uspass","description":"Tuya Water Leak Sensor 8266ex based","archived":false,"fork":false,"pushed_at":"2025-04-08T14:00:48.000Z","size":27759,"stargazers_count":17,"open_issues_count":7,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-19T07:00:34.985Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uspass.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-26T18:47:42.000Z","updated_at":"2025-04-08T14:00:52.000Z","dependencies_parsed_at":"2022-08-12T00:50:35.264Z","dependency_job_id":null,"html_url":"https://github.com/uspass/Tuya-Water-Leak-Sensor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/uspass/Tuya-Water-Leak-Sensor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uspass%2FTuya-Water-Leak-Sensor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uspass%2FTuya-Water-Leak-Sensor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uspass%2FTuya-Water-Leak-Sensor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uspass%2FTuya-Water-Leak-Sensor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uspass","download_url":"https://codeload.github.com/uspass/Tuya-Water-Leak-Sensor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uspass%2FTuya-Water-Leak-Sensor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478886,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-16T13:00:54.719Z","updated_at":"2026-01-16T13:00:55.611Z","avatar_url":"https://github.com/uspass.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tuya Water Leak Sensor SKU-S2502 Converted to Tasmota\nMCU Product ID: {\"P\":\"SmFKLTOcGHbPQvmh\",\"v\":\"1.x.x\"} \nWifi 8266ex \n\n![20190119_102556x](https://user-images.githubusercontent.com/42880649/120639804-6dac6180-c47a-11eb-85a8-bf8dbfecacb2.jpg)\n\nBasically the sensor works like this:\nThe MCU (U3) is powered by the battery through Q2 which acts like a diode (with a low drop-off voltage) protecting it from reverse polarity.\nThis micro-controller takes care of:\n  1. water leak tips reading p1.0\n  1. battery low reading p1.2. \n  1. push button K1 reading p0.2. For WiFi pairing.\n  1. Buzzer B2 writing p0.6. Sound alarm.\n  1. LED D1 writing p0.7. WiFi and visual alarm.\n  1. Reset ESP (EXT_RSTB) writing p1.5.\n  1. ESP power writing p1.7. Power control to save battery.\n  1. GPIO5 linked to p0.0.\n  \nIn order to save power, ESP (U1) is powered through Q3 which is normally closed (VM0=0).\n\nThe event sequence is as follows:\n\nWhen an event shows, water over the terminals, MCU powers on ESP by opening Q3.\n\nESP gets the event type (water leak and battery status) using Tuya protocol, connects to WiFi, establish the communication with the cloud and sends info to the cloud. \n\nAfter that, MCU cuts down ESP power and looks for the next event.\n\nAll that takes like 3-5 seconds.\n\n\nFlashing:\n\nUse Tx Rx GND VMO(+3V) and GPIO0 to GND to flash Tasmota. See Tasmota docs for USB-serial device.\n\nFrom now on, every single change in Tasmota should be done touching the water leak tips quickly with your fingers wet .\n\nI assume you have worked before with Tasmota.\n\n\nProgramming:\n\n#### Set the wifi credentials.\n\n#### Set the Mqtt config.\n\nConsole in the following programming sequence:\n\n#### Module 54\n\n#### TuyaMCU 51,21\n\n#### Backlog SetOption1 1; SetOption65 1; SetOption66 0; SetOption36 0; SetOption19 0; SwitchMode 1\n\nIn next command change 'Water_Leak' name with whatever name you want for the sensor\n\n#### Backlog DeviceName Water_Leak; FriendlyName1 Water_Leak\n\nInfo for Rule1 and Rule2:\n\nTuya CmndData:\n\n65010001006604000101\n\nThat translates to:\n\nLook for 650100010 (Rule1): \n\n6501000101 ON (Wet)\n\n6501000100 OFF (Dry)\n\nLook for 660400010 (Rule2):\n\n6604000100 Battery Full\n\n6604000101 Battery High\n\n6604000102 Battery Medium\n\n6604000103 Battery Low\n\n\n#### Rule1 ON TuyaReceived#Data$|6501000101 DO publish2 stat/%topic%/STATUS ON ENDON ON TuyaReceived#Data$|6501000100 DO publish2 stat/%topic%/STATUS OFF ENDON\n\n#### Rule2 ON TuyaReceived#Data$|6604000100 DO publish2 stat/%topic%/BATT Full ENDON ON TuyaReceived#Data$|6604000101 DO publish2 stat/%topic%/BATT High ENDON ON TuyaReceived#Data$|6604000102 DO publish2 stat/%topic%/BATT Medium ENDON ON TuyaReceived#Data$|6604000103 DO publish2 stat/%topic%/BATT Low ENDON\n\nThe next rule creates a device in Home Assistant. Change 'Water Leak' name with whatever name you want. If you have more than one sensor make sure you have different names for each sensor:\n\n#### Rule3 ON system#boot DO publish2 homeassistant/binary_sensor/%macaddr%_moisture/config {\"name\":\"Water Leak\",\"unique_id\":\"%topic%_%macaddr%\",\"device_class\":\"moisture\",\"device\":{\"identifiers\":[\"%macaddr%\"],\"name\":\"Water Leak\",\"manufacturer\":\"Tasmota\",\"model\":\"SKU-S2502\"},\"state_topic\":\"%topic%/stat/STATUS\"} ENDON ON system#boot DO publish2 homeassistant/sensor/%macaddr%_battery/config {\"name\":\"Water Leak Battery\",\"unique_id\":\"%topic%_Battery_%macaddr%\",\"icon\":\"hass:battery\",\"device\":{\"identifiers\":[\"%macaddr%\"],\"name\":\"Water Leak\",\"manufacturer\":\"Tasmota\",\"model\":\"SKU-S2502\"},\"state_topic\":\"%topic%/stat/BATT\"} ENDON\n\nActivate rules\n\n#### Backlog Rule1 1; Rule2 1; Rule3 1\n\nImportant!!!!!\n\nDON'T USE TASMOTA VERSION 9.5. IT HAS A BUG. IT WON'T WORK!\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuspass%2Ftuya-water-leak-sensor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuspass%2Ftuya-water-leak-sensor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuspass%2Ftuya-water-leak-sensor/lists"}