Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By Mikejstb
#12830 did you get it to work?
I've been fighting for two weeks trying to have the PIR sensor trigger a mqtt message.

I find that the PIR sensor output gets false triggers whenever the ESP radio is on.

I've finally gotten the crazy logic to work to turn the radio off when waiting for the PIR signal, then turning the radio on, publishing the mqtt message, and turning the radio back off.

Even then running the PIR on the same 3.3v supply as the ESP was just never reliable - more false triggers.
I finally powered the PIR separately and cured that issue.

Then I found that every 60 seconds I was getting another PIR trigger - turns out the ESP wdt was causing that.

Now after thinking I was finally successful I'm finding that after about 5 minutes or so of inactivity, when I got to reconnect radio and publish mqtt the radio connects to my AP but I no longer get my mqtt connection.

I tried raising the mqtt keep alive duration but that hasn't helped so far.
Everything works as long as I have PIR activity every < 5 minutes - but any pause in PIR over 5 minutes I no longer get mqtt connection...

I was going to just try to make the ESP reset if I get AP connection but no mqtt connection within 15 seconds - after a reset the whole thing seems to work... but as of late last night I couldn't get my "reset on no response" code to work.

Very frustrating.

This morning I was going to try the reset code again when I saw the announcement of the Arduino IDE ESP port and the first example is a mqtt publisher.
Once I get that to compile(a whole other issue ) I'm going to see if it works publishing every 5 or 10 minutes to see if I have the same problem.

Anyway - let me know if you have gotten your setup to work reliably - if so I'd love to see how you did it.
User avatar
By Mikejstb
#12831 Argh! I forgot to check the notify me of replies button again! Twice this morning - I think I need another cup of coffee...
User avatar
By terenceang
#12837 Read my blog, I had it running for a week +, no false trigger.

The radiation from the ESP is causing the false trigger. I can't fix that as well, I tried running the esp more than 1 foot away from the PIR and I still get false trigger. My current solution is to use an optocoupler to pull CH_PD high when triggered and that boots the ESP up, get time from NTP and publish a formatted text on mosquito, then go into deep sleep. Once in deep sleep the PIR is not affected any more, after the trigger pulse, the light goes off and release the CH_PD pin and turns off the ESP.

I think a more elegant solution is to use a pin to wake the ESP up, saving the need to get time from the NET every time and conserving some battery power.
User avatar
By terenceang
#12838
Mikejstb wrote:did you get it to work?

Even then running the PIR on the same 3.3v supply as the ESP was just never reliable - more false triggers.
I finally powered the PIR separately and cured that issue.



solder a large cap close the ESP or to the ESP's header pin, that solves my trigger problem. now I have the ESP stuffed into the PIR light.

Image