Wireless Contact Sensor


[Pre-Release] This is my ultra-low power wireless contact sensor. It consumes a single digit μA (~5μA) while in standby. Along with an ESPNow hub, it can achieve real-time response of <150ms. It can also be used in a stand-alone mode, without the hub, to connect directly to Wi-Fi. It was designed using an ESP8266 Wi-Fi module, an ATtiny microcontroller and LDO. It has a built-in Lithium-Ion/Lithum-Polymer charger, a JST PH2.0 plug for the battery and USB-C plug for charging.

Want the PCB only? click here.

Availability: In stock

SKU: MDY00520 Category:

This is the third iteration of my contact sensor. I designed this sensor because I had a need for a wireless, non-proprietary, cloud-free doors/windows sensor. Unlike a button sensor, which is simpler to design, a contact sensor needs to trigger on both ON and OFF states. I optimized the design to use small Lipo batteries and picked components, like the LDO, to be efficient and are low in power consumption in both active and standby modes. The ESP8266 module spends the majority of its time completely off consuming no current. The ATtiny stays in deep sleep until the switch status changes. The sensor can be paired with an ESPNow hub to minimize the sensor’s uptime using ESPNow. This enables a ~150ms trigger time needing <50mA on average. The sensor has a ~5μA standby current.

Standby current
Trigger duration & consumption

In Action

I used it as a door sensor along with the hub to send MQTT updates to a home automation system. The home automation system turns the smart light on or off depending on the door status.


The sensor has been designed and tested with single cell 3.7 Volt Li-Ion/Li-Polymer batteries. It uses a JST PH2.0 as the battery plug. It has a built-in Lithium battery charger using MCP73831 which is a miniature single-cell, fully integrated Li-Ion, Li-Polymer charge management controller. To charge the battery, connect a USB-C cable from a static 5V source or a USB-C Power Delivery adapter. A red LED will turn ON while the battery is charging and turn OFF when it is fully charged.

Here are some very rough estimates to provide a sense on how long a 400mAh would last:

  • In stand by = 400mAh/5μA = 400,000μAh/5μA = 80,000h ~= 9 years
  • Each trigger consumes  50mA * 0.15s/60/60 = 50mA * 0.00004h = 0.002mAh
  • Number of triggers per full charge = 400mAh / 0.002mAh = 20,000 triggers
  • These numbers don’t take into consideration the battery self discharge.
  • If I have to guess, a more realistic number would be 2-3 years of battery life with a ~50 triggers a day.


If you are soldering a PH2.0 cable or using a non-MrDIY battery, check the polarity of the wires going into the battery port. A backwards battery will destroy the sensor!
  • Check, double check, then triple check the battery polarity before plugging it in. Reverse polarity WILL destroy the sensor.
  • DO NOT plug the USB-C charging cable when using the sensor with non-rechargable or non Li-Ion/LiPo batteries.
  • The LDO, in theory, should accept any battery voltage in the 3.3v – 16v range but the voltage divider was designed for a 4.2v max voltage. I highly encourage you to stick with single cell 3.7v li-ion/lipo batteries unless you REALLY know what you are doing.

Source Code

The sensor already comes pre-flashed with the latest firmware. The complete source code is available on my Gitlab repository.

To program the ESP-12F

You will need a FT232R USB to serial programmer (3.3V only). The pins are accessible on the back of the sensors and are labelled. No need to put the ESP in programming mode since the FT232R takes care of that if you use all 6 pins. Please make sure the battery is disconnected before flashing the ESP8266.


The Hub

The sensor can be used to send updates directly over Wi-Fi but, if you want to unleash its full potentials or get the instant response time and long battery life, you will want to pair it with the Hub. You can read more about the Hub here. Here is a preview of the Hub interface.


YouTube Video

Coming soon …



Weight 7 g
Dimensions 4.75 × 2.35 × 0.7 cm

You may also like…

Shopping Cart