Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with Tuya door/window sensor please? #5389

Closed
senadaruc opened this issue Mar 3, 2019 · 106 comments
Closed

Help with Tuya door/window sensor please? #5389

senadaruc opened this issue Mar 3, 2019 · 106 comments
Labels
Device not Supported Result - Device is not supported

Comments

@senadaruc
Copy link

senadaruc commented Mar 3, 2019

Dears,

I managed to flash this Tuya door/window sensor with Tasmota and all work perfectly except that I can't find the right configuration for the module.

The specification and pictures of the device:
Description:
1.Detect open/close status of the door/window,compatibe with Tuya
2.Battery: AAAx 2 (not included ) Standby time: 5 years
3.Use time:1 years (15 times/day) 2years(7 times/day)
4.Standby current:10uA Wireless Type:2.4GHz
5.Protocol:IEEE 802.11b/g/n Wifi distance:45m
6.Operating Temperature:0℃~ 40℃ (32°F~104°F)
7.Free APP:Tuyasmart, one key setup wifi or ap mode connection with wifi .
8.Works with Alexa Echo and google home.
Specifications:
This is a smart door sensor which can work dependently without hub , and can be compatible with Alexa and google home assistant , Besides, it can IFTTT other smart items . Also, it can associate 2 device sot work to creat your own scene and shart your devices to others directly
how to work :

  1. Run " smart life " from your smartphone desktop
    2.Register and login
  2. select device type , select " door " in the list to add the device.
    Package Included:
    1*smart sensor

https://www.aliexpress.com/item/Home-Door-Window-Detector-WiFi-App-Notification-Alerts-Battery-Operated-Home-Security-Sensor-Work-with-Alexa/32973283622.html

screenshot 2019-03-03 at 20 07 24

screenshot 2019-03-03 at 20 07 34

Picture of the board:
https://user-images.githubusercontent.com/14252382/53700281-e67e6800-3df0-11e9-85cd-8eb4a040cc78.JPG

Picture of the board:
https://user-images.githubusercontent.com/14252382/53700282-e67e6800-3df0-11e9-8d70-f2aba5dd420c.JPG

Thanks,

@meingraham
Copy link
Collaborator

Did you follow a process similar to this - https://github.com/arendst/Sonoff-Tasmota/wiki/Configuration-Procedure-for-New-Devices?

Question - where you able to flash this OTA or did you have to open it use a serial adapter? Does this device go to sleep after inactivity or with the magnet present?

Mike

@senadaruc
Copy link
Author

Hi Meingraham,

I flashed with serial adapter using the latest Tasmota firmware.

No I didn’t follow the process!

S,

@senadaruc
Copy link
Author

And yes I can confirm that the device is going to sleep mode after the magnetic switch goes on/off.

@meingraham
Copy link
Collaborator

meingraham commented Mar 3, 2019

Yes, the latest TASMOTA, but by which method - hooking up wires or wirelessly using Tuya-convert?

See if that configuration process works for you to find the GPIO configuration for the device.

@senadaruc
Copy link
Author

Soldering the RS232 USB adapter and flashing directly.

Thanks,

@DeadEnded
Copy link

DeadEnded commented Mar 4, 2019

Thanks for adding the photo's! I ordered a few of these also (have not received them yet). I was hoping they used the tywe3s board since the description listed "Tuya App" etc. I see from your photo's they also appear to have broken out the pins needed to flash firmware (as you have already done).

This will be my first adventure into Tasmota and I am hoping to use the "Tuya-Convert" method. If that doesn't work I will do as you did and use a serial to USB. One question (for anyone who knows). I see the Ground (G) and power (V) are marked. The other two are listed as N and S. Do you know which is Transmit and which is Receive? I'm new to this and wasn't sure (I'm guessing they are marked from another language?).

Thanks!
DeadEnd

EDIT: Fixed "OTA" method to "Tuya-Convert" to be clear as to what I hope to do.

@senadaruc
Copy link
Author

senadaruc commented Mar 4, 2019

Hi cbmboy,

Please wire your RS232 to USB as per picture below!
img_3884

Then use the https://github.com/nodemcu/nodemcu-flasher/tree/master/Win64/Release application to flash the device with the latest Tasmota Firmware using the following config:

Baudrate 115200, Flash size 1 MByte, Flash speed 40 MHz , SPI Mode DOUT

You need to connect GPIO 0 and GROUND while connecting the board to USB.

Good luck.

@senadaruc
Copy link
Author

meingraham, I found a partially working profile "Manzoku Strip Module" but i need to configure like sensor not like button/relay! how yo do that?

screenshot 2019-03-04 at 08 55 08

screenshot 2019-03-04 at 00 13 33

@DeadEnded
Copy link

Please wire your RS232 to USB as per picture below!

@senadaruc
Did you try using the four breakout pin holes to see if they are the Tx, Rx, Group, and Vcc?
I anticipated that this was the case - but since I am inexperienced, I could be wrong.
Also, it appears there is a button on the front, and from the pictures you attached, I see it is marked (SM1).
Were you able to identify what this is wired to?
Again, I was thinking this may be GPIO 0 to Ground as many other devices do.
This would greatly reduce the skill (soldering) needed to accomplish the Tasmota conversion.

This would make the process much easier if these assumptions are correct.

Thanks!

@Jason2866
Copy link
Collaborator

@senadaruc There has to be a extra electronic which sends ESP to off.
Because Tasmota doesnt support deep sleep. Could you post a picture of the other side of the PCB
I am interested how is this be done.
Thx!

@senadaruc
Copy link
Author

cbmboy, the button will not put the CPU to program mode so I soldered the GPIO 0 and used the ground to force the program mode.

jason2866, here is the picture of the board: https://user-images.githubusercontent.com/14252382/53700282-e67e6800-3df0-11e9-8d70-f2aba5dd420c.JPG

@Jason2866
Copy link
Collaborator

No label on the interesting IC U1 :-(
It looks like it does have a step up power converter so the 2 AAA cells are no problem for providing correct voltage for the ESP

@senadaruc
Copy link
Author

The device connects to internet only when you trigger the magnetic switch.

@Jason2866
Copy link
Collaborator

Jason2866 commented Mar 4, 2019

Mhh, you could try to measure via a DMM the different GPIOs if one goes in high state when magnetic switch is triggered.
image
Another question is has it a different behaviour for open and close?
So maybe you get just the information you can use device was "up"

@senadaruc
Copy link
Author

Mhh, you could try to measure via a DMM the different GPIOs if one goes in high state when magnetic switch is triggered.
image
Another question is has it a different behaviour for open and close?
So maybe you get just the information you can use device was "up"

This is the Voltage output while the device is connected to the internet and the magnetic switch is open!

53743623-8690cb80-3e9b-11e9-9bbf-35951c5b89ab

@senadaruc
Copy link
Author

Mhh, you could try to measure via a DMM the different GPIOs if one goes in high state when magnetic switch is triggered.
image
Another question is has it a different behaviour for open and close?
So maybe you get just the information you can use device was "up"

This is the Voltage output while the device is connected to the internet and the magnetic switch is open!

53743623-8690cb80-3e9b-11e9-9bbf-35951c5b89ab

Same voltage results while the device is connected to the internet and the magnetic switch is closed!

@senadaruc
Copy link
Author

Thanks for adding the photo's! I ordered a few of these also (have not received them yet). I was hoping they used the tywe3s board since the description listed "Tuya App" etc. I see from your photo's they also appear to have broken out the pins needed to flash firmware (as you have already done).

This will be my first adventure into Tasmota and I am hoping to use the "Tuya-Convert" method. If that doesn't work I will do as you did and use a serial to USB. One question (for anyone who knows). I see the Ground (G) and power (V) are marked. The other two are listed as N and S. Do you know which is Transmit and which is Receive? I'm new to this and wasn't sure (I'm guessing they are marked from another language?).

Thanks!
DeadEnd

EDIT: Fixed "OTA" method to "Tuya-Convert" to be clear as to what I hope to do.

The N,G,S and V board pins/holes are not connected into TX,RX or VCC !! only G is ground.

S,

@Jason2866
Copy link
Collaborator

Other GPIOs are not connected? Like Gpio 4, 12, 13 or 14?

@DeadEnded
Copy link

The N,G,S and V board pins/holes are not connected into TX,RX or VCC !! only G is ground.

Thanks for the information!
I do wonder what they are for then...

@DeadEnded
Copy link

Other GPIOs are not connected? Like Gpio 4, 12, 13 or 14?

There should be at least two correct? (Asking as I am still new and trying to learn)
One for the magnetic switch, and another for the LED?
Would there need to be a third also for the button (don't know what this does yet).

@senadaruc
Copy link
Author

Other GPIOs are not connected? Like Gpio 4, 12, 13 or 14?

There is no voltage output from other GPIO's !! is there other way to test the GPIO's ?

@senadaruc
Copy link
Author

No label on the interesting IC U1 :-(
It looks like it does have a step up power converter so the 2 AAA cells are no problem for providing correct voltage for the ESP

I managed to see the chip info ... it's 78474 .... see the picture below.

img_3891

@senadaruc
Copy link
Author

Ok so I triggered the magnetic switch and tried to see which GPIO is giving me continuity connection between GND and GPIO output but unfortunately, none of them is closing the circuit!

@Jason2866
Copy link
Collaborator

The magnetic switch does not trigger a Gpio from the ESP chip
The U1 is a MCU. This chip reacts on the magnetic switch and enables the ESP chip.
The ESP sends with orig. firmware just a message via wifi when activated...

@senadaruc
Copy link
Author

Aha ok so now I managed to get some ON/OFF messages at the Tasmota console using the Manzoku Strip Module but is not ideal since the default config is switch but I need a sensor, any help bout this?

@senadaruc
Copy link
Author

how to change the default timer for the sleep mode ??

@DeadEnded
Copy link

The ESP sends with orig. firmware just a message via wifi when activated...

I have not worked in Tasmota yet (waiting for devices) but is this something that it can be setup to do?

@Jason2866
Copy link
Collaborator

Jason2866 commented Mar 5, 2019

@senadaruc Tasmota uses NO Deep Sleep, it is not possible/wanted by design. This means CPU is always on. See https://github.com/arendst/Sonoff-Tasmota/wiki/energy-saving

Tasmota is not intended or designed to use with battery powered devices

@Jason2866
Copy link
Collaborator

@cbmboy You get a Info from device (via mqtt) that it is (or was) online. This info can be used in your Home Automation solution.
With Tasmota on this device you cant expect more, because ESP chip (where Tasmota is installed) is not powered most of the time...

@Audiothor
Copy link

Ok thanks @blakadder, so now, the LSC Door sensor is flashed with the last Tasmota version v8.1.0 Doris (only hard method works)
@blakadder : Impossible to use the definition template you shared because it's not the same hardware.

I tried to apply this config :

module 54
backlog TuyaMcu 11,1; TuyaMcu 51,51; TuyaMcu 12,3
rule1 ON Wifi#Connected DO backlog serialsend5 55 AA 00 01 00 00 00; delay 10; serialsend5 55 AA 00 02 00 01 04 06; delay 3; serialsend5 55 AA 00 05 00 01 00 05; ENDON
rule2 ON TuyaReceived#Data=55aa000200000155aa0005000501010001010d DO POWER ON ENDON
rule3 ON TuyaReceived#Data=55aa000200000155aa0005000501010001000c DO POWER OFF ENDON
restart 1

But I still have the issue with MQTT : only "Off" and never changes to "On"...
Is someone have an idea ?

@blakadder
Copy link
Collaborator

The tuya received string has two serial messages in it, something is wrong there

@Audiothor
Copy link

@blakadder
Hope it will be my last question ;)
So finaly I bought the exact same model (Earykong TYMC-1 Door Window Sensor) as your description link there : here
I apply the exact configuration like you recommandation in Tasmota 8.1.0.
POWER ON and OFF are working fine ( yes !) BUT I can't catch the mqtt message because MQTT has not enought time given by the door sensor.
Manualy it works because I prevent the device from going to sleep by actuating the reed switch constantly (approximately every 5 seconds). And I use temprary the SerialSend5 55AA000200010002 command...
But after impossible to catch any message...
Hope my question not so stupid :) Thanks a lot

@blakadder
Copy link
Collaborator

nothing you can do here, its how the sensor is designed and it depends on how long you need to connect to wifi and your broker

@dmartella
Copy link

dmartella commented Jan 25, 2020

Hi all. Thanks for all the information that you gave in this thread. I did the flash *using the 4 pin available (inverting tx/rx as they are connected to the esp). I have the tasmota loaded and it works. My problem is that I cannot see the switch On/off but only this message is received in the console when I shift the magnetic sensor:

0:00:05 TYA: Send "55aa000200010305"
00:00:05 RSL: tele/tasmota/RESULT = {"TuyaReceived":{"Data":"55AA0002000001","Cmnd":2}}

I tried to increase log to level 4 in tasmota to understand which are the dpID but no success. anything is shown in the log. can you point me in the right direction? Danilo
Thanks

@brjhaverkamp
Copy link

Hello all, I got myself this device and try to flash to tasmota-bin (v8.2) with esptool.py (v2.8)
I used the info from https://templates.blakadder.com/TYMC-1.html but it doesn't mention any special parameters or memory layout.

The flashing starts OK, but consistently gives an error at 8% of the upload.
Does anyone have any idea what could be wrong here?

sudo esptool.py --port /dev/ttyUSB0 --baud 115200 write_flash -fs 1MB -fm dout 0x0 tasmota.bin
esptool.py v2.8
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: bc:dd:c2:60:e0:8a
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Compressed 580480 bytes to 399923...
Writing at 0x00008000... (12 %)
A fatal error occurred: Invalid head of packet (0x00)

@Jason2866
Copy link
Collaborator

Bad power supply from usb serial adapter
Please, address this to the Tasmota Support Chat. The chat is a better and more dynamic channel for helping you. Github issues are meant for Tasmota Software Bug Reporting.

Please check the Contributing Guideline and Policy and the Support.

Thanks.

Support Information

See Documentation for more information.
See Chat for more user experience.
See Community for forum.
See Code of Conduct

@blakadder
Copy link
Collaborator

battery powered device as well so it could be going to sleep on you

@dmartella
Copy link

dmartella commented Mar 21, 2020 via email

@brjhaverkamp
Copy link

Brilliant! Thanks. I had it on 3.3V from the FTDI. I thought that fixed the going to sleep issue.
I powered it from the pads, not directly to the module. Maybe that was the reason?
But it is flashed now:-) Moving to phase 2.

@dmartella
Copy link

dmartella commented Mar 21, 2020 via email

@brjhaverkamp
Copy link

Hi Dmartella, will do. Meanwhile can you tell me how you kept it from switching off while configuring it? Does it make a difference if I provide power directly to the ESP8266 module? (A opposite to the broken out pins for 3v3 and GND next to the MCU)

@dmartella
Copy link

dmartella commented Mar 22, 2020 via email

@brjhaverkamp
Copy link

Hi dmartella,
I have things going with MQTT. i am however getting a flood of Stat, power and RESULT Mqtt messages. I'd like to compare notes with you. But this is not really the place for a discussion. Please send me a private mail. My address is in my profile.

@dmartella
Copy link

dmartella commented Mar 27, 2020 via email

@brjhaverkamp
Copy link

Nope, it isn't in your profile. Or I'm looking in the wrong place:-)

@AloisKlingler
Copy link

maybe this will help https://blakadder.github.io/templates/TYMC-1.html

hi blakadder,

have the same sensor now here and working already.
BUT: a question regarding "keep the module powered from the USB-to-serial adapter instead of batteries": I tried this, but I'm failing and i don't know why. I soldered pins to VCC and GND of the ESP - it looks like this:

Doorsensor

The aim is to have it - without soldering - "online" for reconfiguring, if necessary.
But the pins do not work for powering. I have measured with a multimeter, as soon as powered by battery I can see there 3.3V at the pins, so I assume it is soldered well. if I attach (without batteries) 3.3V from the USBtoSerial adapter to the pins nothing happens. If I attach the 3.3V from the adapter to the pins on the board in the middle, it boots, but the MCU disables the ESP as it does in battery mode.

I did not attach RX / TX / GPIO0 anywhere, only the power.
Is there something else necessary besides the VCC/GND pins to have it booting up and staying online?

Thanks for any hints. :-)

BR
Alois

@blakadder
Copy link
Collaborator

Like any other ESP 12F module it is required to pull EN high and GPIO15 low in order for the module to boot into the flashed firmware so your idea won't work. reference http://glyncowles.blogspot.com/2015/07/programming-and-running-esp12-e.html

@klausahrenberg
Copy link

For everyone, who is looking for a firmware for this device to connect with a MQTT broker, have a look here: https://github.com/klausahrenberg/WDoorSensor

@ascillato2 ascillato2 added the Device not Supported Result - Device is not supported label Aug 16, 2020
@mustafakarsu
Copy link

Bu cihazın bir MQTT komisyoncusu ile bağlantı kurması için bir ürün yazılımı arayan herkes için buraya bir göz atın: https://github.com/klausahrenberg/WDoorSensor

I flashed ESP-12E but I do not connect to wifi. Do you have any information about this?

@ascillato2
Copy link
Collaborator

@mustafakarsu

I flashed ESP-12E but I do not connect to wifi. Do you have any information about this?

You can ask to klausahrenberg, the author of WDoorSensor by opening an issue at https://github.com/klausahrenberg/WDoorSensor/issues

@klausahrenberg
Copy link

I flashed ESP-12E but I do not connect to wifi. Do you have any information about this?

Hi, I guess, you followed the flashing instructions here: https://github.com/klausahrenberg/WDoorSensor/blob/master/Flashing.md

Then, proceed with initial configuration (Wifi settings): https://github.com/klausahrenberg/WDoorSensor#initial-configuration

After this, the sensor should send messages to your MQTT broker at every door opening/closing in following json structure:
https://github.com/klausahrenberg/WDoorSensor#json-structure

@mustafakarsu
Copy link

ESP-12E'yi parlattım ama wifi'ye bağlanmıyorum. Bununla ilgili herhangi bir bilginiz var mı?

Merhaba, sanırım buradaki yanıp sönen talimatları izlediniz: https://github.com/klausahrenberg/WDoorSensor/blob/master/Flashing.md

Ardından, ilk yapılandırmaya devam edin (Wifi ayarları): https://github.com/klausahrenberg/WDoorSensor#initial-configuration

Bundan sonra, sensör aşağıdaki json yapısında her kapı açılış / kapanışında MQTT aracınıza mesajlar göndermelidir:
https://github.com/klausahrenberg/WDoorSensor#json-structure

I did it up to install following the instructions. I uploaded the .bin file. but I could not configure it. I power the Esp but I cannot flash the light, do you know which pin corresponds to the reset button on the TUYA in ESP8266.

Thank You.

@klausahrenberg
Copy link

I'm a little confused. Ok, flashing with esp tool was successfull, right?

  • If so, then remove all connections that you used for programming (GND, VCC, GPIO0, TX, RX).
  • Then insert the batteries, then hold the button (> 5 sec) until the led blinks.
    It's not possible to get in to the configuration in via powering the Tyua/ESP over the programmer.

@mustafakarsu
Copy link

I'm a little confused. Ok, flashing with esp tool was successfull, right?

  • If so, then remove all connections that you used for programming (GND, VCC, GPIO0, TX, RX).
  • Then insert the batteries, then hold the button (> 5 sec) until the led blinks.
    It's not possible to get in to the configuration in via powering the Tyua/ESP over the programmer.

Yes. I flashed with esp tool.

  • Then I power on VCC and GND pin
  • But I do not know the reset button in Tuya because I made it from ESP so I know that the led is on the D2 pin. Because I can't blink light
  • I'm trying to do this flashing not on the door sensor, but on the Esp8266 12E Module

@klausahrenberg
Copy link

Ok, now I know your idea. But I have to say, it will not work. The door sensor is not just an ESP12E. It has a second controller (MCU) where the reset button, the LED and complete battery management is connected to. MCU and ESP talks via serial communication to each other. ESP does only the WIFI things, the MCU is the logic itself.
So you will not be able to test my firmware with an ESP12E only, please use the door sensor.

@bernd-wechner
Copy link

Hi cbmboy,

Please wire your RS232 to USB as per picture below! img_3884

Then use the https://github.com/nodemcu/nodemcu-flasher/tree/master/Win64/Release application to flash the device with the latest Tasmota Firmware using the following config:

Baudrate 115200, Flash size 1 MByte, Flash speed 40 MHz , SPI Mode DOUT

You need to connect GPIO 0 and GROUND while connecting the board to USB.

Good luck.

Two years later but hey, got the same question, but Tuya WiFi door/window sensor now looks like this internally:

IMG_20221118_164829

and yep, the question now is, what's that chip and how to flash it?

@bernd-wechner
Copy link

bernd-wechner commented Nov 18, 2022

Ah, but here is the spec:

https://developer.tuya.com/en/docs/iot/cbu-module-datasheet?id=Ka07pykl5dk4u
https://developer.tuya.com/en/docs/iot/CBxxSerialModuleUART?id=Kajjtxaiaeh5j

In which I can clearly identify pins marks TX1, Tx2, RX1, RX2, GND and 3VC (which I suspect is your VCC) but the RX/TX confusion aside, GPIO is mentioned on 8 pins other! And needs some more skill to read than I have off-hand.

@barbudor
Copy link
Contributor

This is based on BK7231N and not an ESP. So it's not Tasmota compatible
You need to brain-swap but there doesn't appear to exist an ESP based module that would be pin-to-pin compatible. So flying wires will be needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Device not Supported Result - Device is not supported
Projects
None yet
Development

No branches or pull requests