RavenSystem / esp-homekit-devices

Advanced firmware to add native Apple HomeKit and custom configurations, compatible with any SoC based on ESP32, ESP32-S, ESP32-C and ESP8266 series. (Shelly, Sonoff, Electrodragon, Tuya...)
Other
2.66k stars 355 forks source link

Strange behavior on GPIO inputs #790

Closed ArFurik closed 4 years ago

ArFurik commented 4 years ago

I try to create a motion sensor with a NodeMCU ESP8266 v3. Your software is great and the JSON able to set all I want... but a strange behaviour occurs on the GPIOs used as inputs. I tried several GPIOs and the problem is the same :

The detection seems done once in two.

I tried several GPIOs, I tested with a physical switch or my motion detector, putting or not pulldown resistors. This strange behaviour is exactly the same in all the cases. I spent a lot of time trying to adapt the JSON, without solving the problem. I sought on the net if this could be an electronical behaviour from the ESP or the NodeMCU, but nothing about that. So I think it is a software issue.

Thank you in advance for your help, the JSON used is paste below.

{ "c": { "l": 13, "b": [{"g": 4,"t": 3}] }, "a": [ { "0": { "r": [{"g": 12,"v": 0}] }, "1": { "r": [{"g": 12,"v": 1}] }, "t": 12, "i": 7, "f1": [{"g": 14}] } ] }

vsidlu commented 4 years ago

try this JSON - {"c":{"o":1,"l":2,"i":1,"b":[{"g":0,"p":1,"t":1}]},"a":[{"t":12,"i":5,"f1":[{"g":12,"p":0,"i":1,"t":0}]}]} which PIR model are you using? do not forget that esp8266 need PIR to use 3v.

ArFurik commented 4 years ago

Hi, it's a PIR HC-SR501. No problem with it and its output is a TTL signal 3.3v. I tried both with a switch or the PIR and it is exactly the same behaviour. I will adapt your JSON to my GPIO config and try.

ArFurik commented 4 years ago

It's work !!! Thank you Uldis Some little things are not understood in the JSON commands yet for me. I put this JSON : {"c":{"l":13,"b":[{"g":4,"t":3}]},"a":[{"0":{"r":[{"g":12,"v":0}]},"1":{"r":[{"g":12,"v":1}]},"t":12,"i":7,"f1":[{"g":14,"p":0,"i":1,"t":0}]}]} The difference is on the f1 section : "f1": [ { "g": 14, "p": 0, "i": 1, "t": 0 } ]

Whatever, all works now perfectly, and I thank you very much. I spent a lot of time on this before posting a issue.

vsidlu commented 4 years ago

happy to help!!!

"i":1 is triggering motion sensor when input is low. if you use "i":0, then triggering will be when input is back to high which is when motion sensor gets back to no motion sensed. so with "i":1 motion message appears almost instantly.

"t":0 also for me is not 100% clear, but @RavenSystem pointed it out in one of opened issues and it helped. i think it is replacing boolean used in older HAA versions.

ArFurik commented 4 years ago

Ok, I'll keep that in mind for my future HAA projects. Have a nice day.