Introduction: Ultra Low Power Trigger Sensor Using ESP8266
In this project, I will show you how you can use an ESP8266, ATtiny and ESPNOW to build battery-based, low-cost, real-time, ultra-low-power trigger sensor to monitor doors and motion or make it act as a wall switch. It uses microAmps while in standby and has a trigger time of 240ms.
Part 2: The Build - https://youtu.be/LbGGeREwECc
Part 3: The Hub - https://youtu.be/VyVaxvgBpEU
New to ESP8266? Watch my Introduction to ESP8266 video.
Step 1: Watch the Video
The video has step-by-step instructions that will guide you through the design. Feel free to add your questions in the comment section of the YouTube video if you need any futher assistance.
Step 2: Order the Components
Amazon.com:
- Wemos d1 mini (4M version) - https://amzn.to/3bqzb2c
- ESP-01 module - https://amzn.to/356vxb1
- ESP-12F module - https://amzn.to/2GZUEVf
- ATtiny13a - https://amzn.to/2GYKXGx
- NPN kit - https://amzn.to/37eclLb
AliExpress:
- Wemos d1 mini (4M version) - https://s.click.aliexpress.com/e/_dXcNTYU
- ESP-01 module with programmer - https://s.click.aliexpress.com/e/_eNOrzT
- ESP-12F module - https://s.click.aliexpress.com/e/_etRdC1
- ATtiny13a (DIP) - https://s.click.aliexpress.com/e/_ePqoLb
- ATtiny13a (SMD) - https://s.click.aliexpress.com/e/_eO8tTP
- NPN kit - https://s.click.aliexpress.com/e/_eOhevR
Amazon.ca:
- Wemos d1 mini (4M version) - https://amzn.to/3fx28Lq
- ESP-01 module with programmer - https://amzn.to/3kaGfnh
- ESP-12F module - https://amzn.to/356vewT
- ATtiny13a - https://amzn.to/37epB2t
- NPN kit - https://amzn.to/3dALmuH
-- LINKS -- (When available, I use affiliate links and may earn a commission)
Step 3: The Sensor
The sensor contains an ATtiny that listens to interrupts from an external device like a reed switch, a motion sensor or a toggle switch.
After an interrupt, it wakes up and powers up the ESP8266. The ESP8266 reads the new switch state and the battery voltage and sends them over to the hub using ESPNOW. When it is done, it signals the attiny. The ATtiny then turns off the ESP8266 and goes back to sleep.
While in standby mode, the ATtiny is in power-down mode consuming around 0.15 uA and the ESP8266 is off.
In active mode, the ATtiny consumes 1.2mA and the ESP8266 averaging around 50mA with a very short 400mA spike. The active mode lasts for 240ms.
The PCB version, made using a pcb manufactorer in China called PCBWay, turns out pretty good and is very compact.
Step 4: The Hub
Inside the hub, there are 2 Wemos D1 minis. The first one acts as a receiver for ESPNOW. It passes the information it receives to the second D1 mini.
The second D1 mini uses this information to push the sensor's data to an MQTT server over a unique topic per sensor. This unique topic is created using the sensor MAC address.
Step 5: The Code
All my work has been published on my GitLab repo:
If you are interested in building this, you can watch my video here.
I plan on revisiting the power management for the ESP8266 as I have been using a Lipo battery directly. So stay tuned!
Step 6: Done
That is all! You can now build an ultra low power trigger sensor using common components and integrate it with your favorite home automation system. The common 3.7 Lipo battery should last you months if not years.
If you found this useful, please consider subscribing to my YouTube channel and if you are interested in supporting my work, you can check my Patreon page. Follow me on Twitter.
** Much of the information contained is based on personal knowledge and experience. It is the responsibility of the viewer to independently verify all information.

Participated in the
Battery Powered Contest
14 Comments
1 year ago
Its amazing the way you have it. I have one question and few suggestions.
Question: Can we use wifi and ESP-NOW at the same time either with esp32 or esp8266? i want to avoid hub. Although i am using your idea itself to do the same. Thank you for the idea.
Why are you using even ATTiny microcontroller for turning it off. Why not using esp12e or esp12f for the same? And use a parallel connection to to turn off the switch or ON the switch.
If you need a schematic diagram or code i can share with you. I have one with home assistant i am using.
Thank you for lovely video. I want to know more about new hub in depth. If you can provide PCB layout with schamatics that will be really helpful.
Reply 4 months ago
Hello, can i have the schematic without ATTiny but with a transistor (also the type you recommend)? Thank you very much in adv!
Question 1 year ago
I cannot build gateway thing. I get 'IotWebConfParameter' does not name a type. and i coundt find a solution. do you know why?
2 years ago
I´ve built similiar device with DHT22 sensor and modified the sketches to submit temperature and humidity via espnow. It should be great for power saving so it can run long time with battery i hope and the hub can also extend the wifi range. I have 2 problems. 1st. the measured vcc voltage shown doesn´t match with the real voltage. when powering the d1 mini with 5v from usb it says 3v in the sketch. when powering the 3,3v rail with powersupply set to 3,4v the vcc reading is only about 2,9v. When connecting + of the 3,4v supply to AD0 it says 3,5v. in your drawings AD0 is not connected. 2nd problem is i use one of the gpio pin to power the DHT22 sensor, set pin high, get the readings, set pin low and go to deepsleep for a while. problem is that voltage output of the pin is about 0,2 - 0,3v lower and the sensor needs at least around 3v. so the whole thing can only run by battery until about 3,3v minimum input voltage. the plan was to use a lifepo4 battery with 3,6v as direct power supply on 3,3v rail. Any helping ideas?
2 years ago
This is a very interesting project. I am looking forward to studying the code more in depth.
You have my vote.
Bob D
Reply 2 years ago
Thank you Bob.
2 years ago on Step 6
Thanks for sharing this, can you also share the wiring of battery -- > ATTiny --> esp8266?
Reply 2 years ago
Hello, I attached the schematic above, have a look.
Reply 2 years ago
Sorry but I couldn't understand the schematic, that's why requested for the diagram if possible.
Reply 2 years ago
Hello, the build video is out (with schematic)
Reply 2 years ago
Thanks so much, I'll try it out
Reply 2 years ago
Hi, I will be posting a video on my YouTube channel with a step by step instrcutions on how to put it together.
2 years ago on Step 1
Great project and very nice explanatory video. Tack from Sweden 🇸🇪
Reply 2 years ago
Thank you!