1technophile / OpenMQTTGateway

MQTT gateway for ESP8266 or ESP32 with bidirectional 433mhz/315mhz/868mhz, Infrared communications, BLE, Bluetooth, beacons detection, mi flora, mi jia, LYWSD02, LYWSD03MMC, Mi Scale, TPMS, BBQ thermometer compatibility & LoRa.
https://docs.openmqttgateway.com
GNU General Public License v3.0
3.5k stars 776 forks source link

General Question and Issue: AM312 possible replacement for HC-SR501? #306

Closed djraidar closed 4 years ago

djraidar commented 5 years ago

Hi! I was wondering if I can use an AM312 instead of the HC-SR501 for motion detection.

And, the issue: I am using the ESP32 with a DHT22 and a Motion Sensor. In the serial monitor, it keeps looping 'creating hcsr501 buffer' hundreds of times, barring any info from BT or DHT info, any insight why? Could it be me not using 5V power and trying to operate this from the 3.3v pin of the ESP32?

1technophile commented 5 years ago

Hi,

maybe try to put further the motion sensor, they can causes perturbation to the chip.

thewillwilson commented 5 years ago

I've also got this issue.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

chesterbr commented 4 years ago

Interestingly, I just tried the HC-SR501 and got the same output:

23:13:16.201 -> Creating HCSR501 buffer
23:13:16.201 -> Pub json into:
23:13:16.201 -> home/OpenMQTTGateway/HCSR501toMQTT
23:13:16.237 -> {"hcsr501":"true"}
23:13:16.237 -> Creating HCSR501 buffer
23:13:16.237 -> Creating HCSR501 buffer
23:13:16.237 -> Creating HCSR501 buffer
23:13:16.237 -> Creating HCSR501 buffer
23:13:16.237 -> Creating HCSR501 buffer
23:13:16.237 -> Creating HCSR501 buffer
23:13:16.237 -> Creating HCSR501 buffer
23:13:16.237 -> Creating HCSR501 buffer
23:13:16.237 -> Creating HCSR501 buffer
23:13:16.237 -> Creating HCSR501 buffer
23:13:16.237 -> Creating HCSR501 buffer
...

I have uncommented the #define ZsensorHCSR501 as described in https://github.com/1technophile/OpenMQTTGateway/wiki/User-guide-PIR (the #include doesn't need to be uncommented, because it is gated by the define, I'll submit a PR for the docs as I tinker a bit more with this.

chesterbr commented 4 years ago

Oh, looking again at the code, I see that I should have plugged it to D5 (for an ESP8266), not a D7 (seems like another patch to the docs is upcoming).

But most interesting is that it works: I get a home/OpenMQTTGateway/HCSR501toMQTT {"hcsr501":"true"} when there is movement, and false after a few seconds leaving the sensor alone. So the only bug here is the spamming of "Creating HCSR501 buffer" messages, let me look at that...

Kinetik commented 4 years ago

Put the HCSR501 on 5v (and for data D5 pin) and the DHT sensor on 3v3 (for data D2 pin). That should do it. Cheers

Keima645 commented 3 years ago

HCSSR501 is much more susceptible to Wifi Noises than AM312. You might want to consider that as a better alternative