ESP8266 – Ikea Molgan light Hack – added retries to prevent battery drain.

I was on holiday over the weekend and the unit works like a charm, I was notified of all activities detected by the PIR set above my main door.

With wifi_station_set_auto_connect(TRUE) the constant tries to connect to a missing AP or wrong password will run the batteries flat in no time.

Default retries is now set to 4 in which after that the ESP8266 will go in deep sleep to conserve power.

https://github.com/terenceang/esp8266-PIR

ESP8266 – Ikea Molgan light Hack – Software and actual usage.

After hacking the hardware, the next part is programming the firmware.

The basic flow control is simple.

  1. boot
  2. log on wifi
  3. get time from NTP server (pool.ntp.org)
  4. format text with timestamp
  5. log on to MQTT broker
  6. publish formated text to MQTT broker
  7. go into deep sleep.

Full source available on GitHub.

MH6After 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.

MH7

I have to trim off some plastic to fit the everything into a small package.

Molgan_hack

Looks complete and nice as a package with it’s cover is on.

MH8

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.

MH9

I set up mqttwarn to push notification to my phone and computer (pushbullet) whenever motion is detected by the PIR.