After hacking the hardware, the next part is programming the firmware.
The basic flow control is simple.
- boot
- log on wifi
- get time from NTP server (pool.ntp.org)
- format text with timestamp
- log on to MQTT broker
- publish formated text to MQTT broker
- go into deep sleep.
Full source available on GitHub.
After I have a decently working firmware, it is time to put everything together. I added a capacitor to the power rails to stabilize and eliminate false trigger. I think the sudden power draw by the ESP8266 somehow caused the BISS0001 to reset and kept the light on.
I have to trim off some plastic to fit the everything into a small package.
Looks complete and nice as a package with it’s cover is on.
Everything works almost perfectly but I think it will be more practical to run it off a wall plug, As I can imagine that the battery would last less than 2 weeks in this config, that will limit it’s usefullness.
I set up mqttwarn to push notification to my phone and computer (pushbullet) whenever motion is detected by the PIR.
Why is there a big capacitor on ESP8266? Is it common usage?
The cap is what I have on hand, it some what helped to prevent the ESP8266 to reset when the PIR is activated. You won’t need it if you have a proper regulator for 3.3v.
Nice work and thanks for writing this up! How has the battery life held up?
New alkaline batt in use since the 29th March, all the ultra bright LEDs on the PIR and the red power LED on the ESP8266 has been removed.
Updated the code to put the ESP8266 into deep sleep after 4 reconnects, preventing it running the batteries flat in cases where the AP is down or not connectable for some reason.
Hi,
What is green card on photo ?
In first post there are just a small regulator.
Sorry for my english.
Yannick
it is the LM1117 regulator, to convert the 4.5v from the batteries to 3.3v fro the esp8266.
Thanks for reply.
It’s same like that ?
http://goo.gl/e3pLVO
Hi,
I have an issue with the PIR … it’s in ON state because of the ESP’s radio
If the ESP is at 50 cm away from the PIR, the LED is off … if the ESP it’s closer then the PIR turn on the LED
any thoughts ?