Project showcase
Low Power Door Monitor

Low Power Door Monitor © GPL3+

Add an Arduino door monitor to your project, without worrying the power will run out with the 0ma consumption when idle!

  • 0 respects

Components and supplies

Apps and online services

About this project

We wanted to add a door monitor into our monitoring and automation system which seems simple....

The problem always becomes power, as running our board constantly even in a low power mode will run the battery down if left a long time (and depending on the door you fit it to it may be waiting a while).

So we need a solution which would consume nothing when off, and only stay on as long as needed to send our messaging.

General Hardware

The part that does all the work here is actually a latching switch which we have created using a transistor latch circuit. A small latching relay could also be used to do the same job.

The switch will need to trigger both ways around (so we can log open and closed).

To do this we need the door to go beyond the switch slightly when it is shut, so the switch is pressed and released as the door opens / closes.

The Circuit

NOTE - check the power rating of your board and the power input. Check the power being sunk from the Digital Pin is within your tolerances (we get around 5v from our batteries, and only need to sink 0.7v to turn the circuit off)

Coding for the Circuit

As our board will be truly off when powered down, we need to store our state in EEPROM, which is accessed via FlashStorage on the Nano33 IoT.

To power down the whole circuit simply run pull the pin LOW (connected to Digital Pin on the diagram) to power down the circuit. Next time the switch is triggered, it will power up our board again to repeat via the momentary switch.

In our project we were sending a message to a server, but as you can see this could fit any project, with the addition of the standard EEPROM Libraries and a simple write from any pin to turn the circuit off.

Using Visual Micro with Arduino this only takes a few clicks to add the libraries, and other code.

Try It Out

Once you have the code on the board and it all wired up, give it a go.

Then its just a case of deciding which door you want to know about.....


Example Nano33 IoT Software for Power LatchArduino
Add SSID and Pass and edit the end of Setup() to perform the actions you want while the board is on.

Alter FlashStorage to store all variables needed, and ONLY write when neccesary!
// Based on WebClient:: 
#include <FlashStorage.h>
#include <FlashAsEEPROM.h>
#include <SPI.h>  
#include <WiFiNINA.h>

char ssid[] = "********";        // your network SSID (name)
char pass[] = "********";    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;            // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)
char server[] = "";    // name address forour website

bool LASTSTATE = false;
FlashStorage(state, int);

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
WiFiClient client;

void setup() {


	//Initialize serial and wait for port to open:
	while (!Serial) {
		; // wait for serial port to connect. Needed for native USB port only

	// check for the WiFi module:
	if (WiFi.status() == WL_NO_MODULE) {
		Serial.println("Communication with WiFi module failed!");
		// don't continue
		while (true);

	String fv = WiFi.firmwareVersion();
		Serial.println("Please upgrade the firmware");

	// attempt to connect to Wifi network:
	while (status != WL_CONNECTED) {
		Serial.print("Attempting to connect to SSID: ");
		// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
		status = WiFi.begin(ssid, pass);

		// wait 10 seconds for connection:
	Serial.println("Connected to wifi");

	Serial.println("\nStarting connection to server...");
	// if you get a connection, report back via serial:
	if (client.connect(server, 80)) {
		Serial.println("connected to server");
		// Make a HTTP request:
		if (LASTSTATE) {
			client.println("GET /data?v=1 HTTP/1.1");
		else {
			client.println("GET /data?v=0 HTTP/1.1");
		client.println("Connection: close");

	// Add our state data to EEPROM
	LASTSTATE =; // Get last state
	state.write(!LASTSTATE); // Invert it (as we trigger on inversion by hardware this is reliable)

	// We can simply power down now
	digitalWrite(12, LOW);
void loop() {
// Nothing to do


Latching Transistor Wiring
Diagram to show how to wire up the latching part of the circuit.
Circuit w83cw0xyvx


Add projectSign up / Login