Ultra Low Power Trigger Sensor Using ESP8266

4,931

51

12

Introduction: Ultra Low Power Trigger Sensor Using ESP8266

About: I am a techie DIYer who loves tinkering with electronics. Twitter @MrDIYca. For more info and my full contacts, please visit www.MrDIY.ca

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.

Battery Powered Contest

Participated in the
Battery Powered Contest

Be the First to Share

    Recommendations

    • Reclaimed Materials Contest

      Reclaimed Materials Contest
    • Sewing Challenge

      Sewing Challenge
    • Halloween Contest

      Halloween Contest

    12 Comments

    0
    serkan887
    serkan887

    Question 5 months ago

    I cannot build gateway thing. I get 'IotWebConfParameter' does not name a type. and i coundt find a solution. do you know why?

    0
    arumpel
    arumpel

    8 months 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?

    0
    Build_it_Bob
    Build_it_Bob

    11 months ago

    This is a very interesting project. I am looking forward to studying the code more in depth.
    You have my vote.
    Bob D

    0
    MrDIYLab
    MrDIYLab

    Reply 9 months ago

    Thank you Bob.

    0
    chancsc
    chancsc

    1 year ago on Step 6

    Thanks for sharing this, can you also share the wiring of battery -- > ATTiny --> esp8266?

    0
    MrDIYLab
    MrDIYLab

    Reply 1 year ago

    Hello, I attached the schematic above, have a look.

    0
    chancsc
    chancsc

    Reply 1 year ago

    Sorry but I couldn't understand the schematic, that's why requested for the diagram if possible.

    0
    MrDIYLab
    MrDIYLab

    Reply 10 months ago

    Hello, the build video is out (with schematic)

    0
    chancsc
    chancsc

    Reply 10 months ago

    Thanks so much, I'll try it out

    0
    MrDIYLab
    MrDIYLab

    Reply 11 months ago

    Hi, I will be posting a video on my YouTube channel with a step by step instrcutions on how to put it together.

    0
    MarceloM91
    MarceloM91

    1 year ago on Step 1

    Great project and very nice explanatory video. Tack from Sweden 🇸🇪

    0
    MrDIYLab
    MrDIYLab

    Reply 11 months ago

    Thank you!