brandond / esphome-tuya_pir

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

PIR: Boot up / Wifi connect is taking 5 seconds with static IP #7

Open berni2288 opened 5 years ago

berni2288 commented 5 years ago

After tinkering a few hours with the motion sensor and trying to flash it, it finally worked, yeah! I configured a static IP in the pir.yaml and was also able to connect the sensor via MQTT to my Openhab server.

What is still holding me from using this productively is: It takes the motion sensor 5 seconds to send the MQTT event to my Openhab, even tho I disabled DHCP.

What is taking it so long? I would have assumed that it shouldn't take longer 1 second to connect to my WIFI and send the event, does the bootup sequence take so long?

And by the way: Thanks for the great work Brandon! You did a great job rescuing this device from the China cloud :)

20:41:59: Blue motion light blinks up

MQTT debug: 20:42:03: [mqtt:202]: MQTT Connected! 20:42:03 [app:060]: setup() finished successfully! 20:42:03 [app:096]: esphome version 1.13.6 compiled on Oct 29 2019, 21:18:34 20:42:03 [sb1:358]: Motion event: 1 20:42:04 [sb1:343]: Rebooting: SB1_STATE_EVENT_ACK 20:42:04 [app:133]: Rebooting safely...

Edit: Reducing the WIFI security to WPA-PSK and bringing the sensor closer to the access point made it a bit faster. But 3-4 seconds is still slow.

petslane commented 4 years ago

I made my own firmware that uses ESP-NOW to send out alerts, so no time wasted for wifi connection.

For me, it takes 3.5s from when blue PIR light comes on and when message is received (actually, another light switches on based on esp-now->gw->mqtt->nodered->mqtt->light, measured with stopwatch).

I have notices that ESP8266 is woken after blue lights goes off and after ESP goes back to sleep, the blue light makes short blink:

So, 3s delay is shortest that is possible with this PIR. I don't know if it's possible to configure MCU to wake ESP8266 with blue light or not. Original app did not have any settings to change PIRs behavior.