A back door sensor with a coin Cell and a reed contact to detect the state of the back door

This is the page url: /domotica/Nodes/BackDoorSensor/

Principles

  • Limit power consumption:

https://forum.mysensors.org/topic/1287/door-window-sensor-consuming-more-power-when-closed/5

  • For the reed contact pin D3, a 3.3 MOhm pull up resistor is used and the internal pull-up is disabled.
  • Use an Arduino Pro Mini 3V3 to keep the cost down (compared to the sensebender).
  • Use no debouncing, and not the software debouncing library, since that one is guaranteed to give trouble combined with sleep mode.
  • The Arduino 3.3V 8mhz can handle down to roughly 2.8V and the Nrf24l01+ down to 1.9V. Hence the batteries can not be NiMH rechargeables - Alkaline or Lithium required. We use a CR2450 coin cell which gives 3V.

Future extensions

  • Add a Si7021 module to measure temperature and humidity.

The result

The SMD solder work

The SMD solder work

The connection of the reed contact

The connection of the reed contact

Wiring: supply, resistor, capacitor

Wiring: supply, resistor, capacitor

Used Components

Wiring

NRF24L01+ Function Arduino Mini Pro pin
+3.3V connected with wire
GND connected with wire
CE D9
CSN D10
SCK D13
MOSI D11
MISO D12
IRQ Not Connected
Component Pin Wire/Component Pin Component
Arduino Pro Mini VCC orange plus Battery CR2450
Arduino Pro Mini GND black min Battery CR2450
Arduino Pro Mini GND Reed Contact D3 Arduino Pro Mini
Arduino Pro Mini VCC Resistor 3M3 Ohm D3 Arduino Pro Mini

Programming

This project uses Platformio, see platformio.ini

Use the following commands:

$ pio run
$ pio run -t upload
$ pio run -t monitor

Code at: BackDoorSensor.ino

First sign of life

__  __       ____
|  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
| |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
| |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
|_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
        |___/                      2.3.2

104 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=8,REL=255,VER=2.3.2
167 TSM:INIT
174 TSF:WUR:MS=8000
190 TSM:INIT:TSP OK
200 TSF:SID:OK,ID=14
212 TSM:FPAR
223 ?TSF:MSG:SEND,14-14-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
260 TSF:MSG:READ,0-0-14,s=255,c=3,t=8,pt=1,l=1,sg=0:0
288 TSF:MSG:FPAR OK,ID=0,D=1
595 TSF:MSG:READ,13-13-14,s=255,c=3,t=8,pt=1,l=1,sg=0:1
825 TSF:MSG:READ,10-10-14,s=255,c=3,t=8,pt=1,l=1,sg=0:1
1071 TSF:MSG:READ,7-7-14,s=255,c=3,t=8,pt=1,l=1,sg=0:1
2263 TSM:FPAR:OK
2271 TSM:ID
2277 TSM:ID:OK
2285 TSM:UPL
2304 TSF:MSG:SEND,14-14-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
2340 TSF:MSG:READ,0-0-14,s=255,c=3,t=25,pt=1,l=1,sg=0:1
2369 TSF:MSG:PONG RECV,HP=1
2385 TSM:UPL:OK
2394 TSM:READY:ID=14,PAR=0,DIS=1
2422 TSF:MSG:SEND,14-14-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
2461 TSF:MSG:READ,0-0-14,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
2500 TSF:MSG:SEND,14-14-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
2547 TSF:MSG:SEND,14-14-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
2584 TSF:MSG:READ,0-0-14,s=255,c=3,t=6,pt=0,l=1,sg=0:M
2650 TSF:MSG:SEND,14-14-0-0,s=255,c=3,t=11,pt=0,l=16,sg=0,ft=0,st=OK:Back Door Sensor
2697 TSF:MSG:SEND,14-14-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
2750 TSF:MSG:SEND,14-14-0-0,s=1,c=0,t=0,pt=0,l=18,sg=0,ft=0,st=OK:BDS - Reed contact
2793 MCO:REG:REQ
2838 !TSF:MSG:SEND,14-14-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=NACK:2
2877 TSF:MSG:READ,0-0-14,s=255,c=3,t=27,pt=1,l=1,sg=0:1
2906 MCO:PIM:NODE REG=1
2920 MCO:BGN:STP
Back Door Sensor 1.0 - Online!
2938 MCO:BGN:INIT OK,TSP=1
Wake up - now minute -1
2975 TSF:MSG:SEND,14-14-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=1,st=OK:1
Reed contact changed without interrupt - now open
3037 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
3063 TSF:TDI:TSL
3074 MCO:SLP:WUP=1
3084 TSF:TRI:TSB
3104 TSF:MSG:SEND,14-14-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0
Reed contact changed - now closed
3158 MCO:SLP:MS=100,SMS=0,I1=255,M1=255,I2=255,M2=255
3186 TSF:TDI:TSL
3196 MCO:SLP:WUP=-1
3207 TSF:TRI:TSB
Wake up - now minute 0
3239 TSF:MSG:SEND,14-14-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0
Reed contact repeat last message - now closed
3299 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
3328 TSF:TDI:TSL
3336 MCO:SLP:WUP=1
3346 TSF:TRI:TSB
3362 TSF:MSG:SEND,14-14-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1
Reed contact changed - now open
3416 MCO:SLP:MS=100,SMS=0,I1=255,M1=255,I2=255,M2=255
3442 TSF:TDI:TSL
3452 MCO:SLP:WUP=-1
3463 TSF:TRI:TSB
Wake up - now minute 1
3495 TSF:MSG:SEND,14-14-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1
Reed contact repeat last message - now open
3555 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
3584 TSF:TDI:TSL
3592 MCO:SLP:WUP=1
3602 TSF:TRI:TSB
3618 TSF:MSG:SEND,14-14-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0
Reed contact changed - now closed
3672 MCO:SLP:MS=100,SMS=0,I1=255,M1=255,I2=255,M2=255
3700 TSF:TDI:TSL
3710 MCO:SLP:WUP=-1
3721 TSF:TRI:TSB
Wake up - now minute 2
3753 TSF:MSG:SEND,14-14-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1
Reed contact changed without interrupt - now open
3815 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
3844 TSF:TDI:TSL
3852 MCO:SLP:WUP=-1
3864 TSF:TRI:TSB
Wake up - now minute 3
3901 TSF:MSG:SEND,14-14-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1
Reed contact repeat last message - now open
3960 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
3987 TSF:TDI:TSL
3997 MCO:SLP:WUP=-1
4007 TSF:TRI:TSB
Wake up - now minute 4
4040 TSF:MSG:SEND,14-14-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1
Reed contact repeat last message - now open
4100 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
4126 TSF:TDI:TSL
4136 MCO:SLP:WUP=-1
4147 TSF:TRI:TSB
Wake up - now minute 5
4179 TSF:MSG:SEND,14-14-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1
Reed contact repeat last message - now open
4239 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
4265 TSF:TDI:TSL
4276 MCO:SLP:WUP=-1
4286 TSF:TRI:TSB
Wake up - now minute 6
4319 TSF:MSG:SEND,14-14-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1
4366 TSF:MSG:SEND,14-14-0-0,s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=OK:104
Wake up - a long period has passed - update all data.
4431 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
4460 TSF:TDI:TSL
4468 MCO:SLP:WUP=1
4478 TSF:TRI:TSB
4495 TSF:MSG:SEND,14-14-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0
Reed contact changed - now closed
4548 MCO:SLP:MS=100,SMS=0,I1=255,M1=255,I2=255,M2=255
4577 TSF:TDI:TSL
4587 MCO:SLP:WUP=-1
4597 TSF:TRI:TSB
Wake up - now minute 0
4626 TSF:MSG:SEND,14-14-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0
Reed contact repeat last message - now closed
4685 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
4712 TSF:TDI:TSL
4722 MCO:SLP:WUP=1
4732 TSF:TRI:TSB
4749 TSF:MSG:SEND,14-14-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1
Reed contact changed - now open
4800 MCO:SLP:MS=100,SMS=0,I1=255,M1=255,I2=255,M2=255
4829 TSF:TDI:TSL
4839 MCO:SLP:WUP=-1
4849 TSF:TRI:TSB
Wake up - now minute 1
4882 TSF:MSG:SEND,14-14-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1
Reed contact repeat last message - now open
4941 MCO:SLP:MS=60000,SMS=0,I1=1,M1=1,I2=255,M2=255
4968 TSF:TDI:TSL
Tags: domotica nodes
Comments: