maximkulkin / esp-homekit-demo

Demo of Apple HomeKit accessory server library
MIT License
803 stars 233 forks source link

Question: Motion Sensor Accessory #112

Closed peros550 closed 5 years ago

peros550 commented 5 years ago

I'm thinking to build a motion sensor accessory.
The sensor would be something like this HC-SR501 and if bought on ebay cost would be around 1USD.

As my esp platform I would use Wemos D1 mini.

There is no special library needed for the sensor to work. It basically has one digital output which should be connected to EPS's digital input and turns high (or low depending on the selected logic) when motion is detected.

My question would be, how could I create a homekit "motion" accessory in the first place.

maccoylton commented 5 years ago

See my example here:- https://github.com/maccoylton/esp-homekit-motion-sensor

renssies commented 5 years ago

Small tip: Do not use the HC-SR501 with any ESP if the ESP is close to the sensor. The ESP's radio seems to interfere with the sensor, causing it to give false triggers. The AM312 has the proper shielding for the ESP and works fine. Only downsides are the higher price, smaller area, and non-adjustable sensitivity.

peros550 commented 5 years ago

@maccoylton Thanks it worked perfectly! I'm going to study your implementation and see if I can enhance it in any way. My goal would be to have a few accessories ( mainly sensors i.e. temperature, motion and light) integrated in the same hardware device.

@renssies Many thanks for the tip. I will try AM312, just need to wait a few weeks until I receive it :)

maccoylton commented 5 years ago

You can fix the interference issue on the HC-SR501 with a solution I found with an internet search

"You simple need to solder a 220nF ceramic capacitor across pin12 und pin13 of the chip (BISS0001) so that the high-frequency interference coming from the ESP8266 don't influece the gain stage anymore".

BTW the HC-SR501's I recently don't seem to be suffering any interference, whereas the ones I bought a couple of years back need the capacitor trick

@peros550 happy to take an enhancements you want to push

peros550 commented 5 years ago

@maccoylton here is a multi sensor example I have just created.

https://github.com/peros550/esp-homekit-multiple-sensors

Many thanks for your help. I hope this example could be helpful to anyone.