brandond / esphome-tuya_pir

ESPHome support for cheap WiFi PIR sensors
66 stars 21 forks source link

Procedure Clarification #17

Open bit-user opened 4 years ago

bit-user commented 4 years ago

Please excuse my noob question, I just need to find the mistake I am making: 1) On PIR side, I connected wires to GND, TXD0, RXD0, GPIO0 and 3.3V. 2) I soldered a wire bridge to GND and GIO0, so they stay connected 3) Then, I connected the following pattern within the 120 seconds: USB-to-TTL-side <-> PIR-side VCC IO <-> 3.3v GND <-> GND TXD <-> RXD RXD <-> TXD

With number 3, the PIR powers on (the blue LEDs flash for a few times), but when I run esptool.py (I will run esphome as soon as esptool successfully connects) like the following, with the following error:

# python3 esptool.py get_security_info                                                                                                                                                    esptool.py v3.0-dev
Found 1 serial ports
Serial port /dev/ttyUSB0
Connecting........_____....._____....._____....._____....._____....._____....._____
/dev/ttyUSB0 failed to connect: Failed to connect to Espressif device: Timed out waiting for packet header

A fatal error occurred: Could not connect to an Espressif device on any of the 1 available serial ports.

However, there is the tty connected:

# dmesg | grep tty                         
[    0.322387] printk: console [tty0] enabled
[12788.883892] usb 1-2: FTDI USB Serial Device converter now attached to ttyUSB0
[12799.525687] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
[12808.434705] usb 1-2: FTDI USB Serial Device converter now attached to ttyUSB0

I am using the following USB-to-TTL converter (if that helps any): FTDI FT232 USB UART Board (https://www.waveshare.com/ft232-usb-uart-board-type-a.htm)

Thanks in advance, and please let me know, if you need any further information :)

ptrooms commented 4 years ago

@bit-user I do recognise your issue. It appears to me, yuou're hit by (likely) some kind of flash load protection.
Short: Do at least leave the batteries out, the 120secs period relates to MCU., I presume you have removed the batteries and only power the esp8266 via the soldered rs232-3v3 line.

A while back I wrote a story about loading firmware on the LSC/PIR on Tweakers.Net (Dutch techno board) https://gathering.tweakers.net/forum/view_message/60684526 where you can see my reply & pictures to connect the LSC/Pir device. Read below for English explanation.

The ".....___...." sequence is coming from the boot-UPloader but the esp8266 of the LSC/Pir device is or may no longer (yet or anymore) in the required state to accept the download. I believe that manufacturer may have modified something that narrow-down the time-window during which period firmware- transfer can take place.

You can bypass and (re)trigger this acceptance stage while "esptool.py" is running by actively ReSeTting the esp8266 (briefly connecting RST pin LOW for 1-2 seconds to GND). The fainted hearts will do this via 4k7 of 10kOhm buffer-resistors.

I think that newer LSC-versions are "more or less" protected against simple hacking which relatively quickly will time-out and leading into the "wait" signal which on its own will timeout. Not sure, but this behavior can also be caused while if you leave the batteries in. The STM8L051F3 MCU i the powered and will interfere with/to the same RX/TX wires as one is using to upload firmware.

Note: Normally one will connect en put the esp8266 into gpio0-flasmode and then start "esptool.py" for uploads etc. The procedure now to shorten this from an esp8266 viewpoint, is to as soon you see the start of "......" , is to ReSet the esp8266. The continues esptool.py polling then will and can see the esp8266 (flashmode). As known, GPIO0 is LOW, the "esp" will straightforward go to the pre-burned flash mode.

In addition, I always do/did, one may need to connect the ENenable-pin to HIGH dhhring the upload process. It will ensure the Tywe-piggy back is not accidentally disabled.

dimmuboy commented 3 years ago

I have a same issue. My PIR blinks fast 3 times on start but I can't flash it. Probably I'm doing something wrong in flashing procedure because it's same with two sensors. Could you add here most detailed flashing procedure please? With details like when to connect RX/TX to USB-RS232, when connect GPIO0 to GND and how long or if is needed to press pairing button on the board? Thank you so much for any help.