Door and window sensor

This battery powered MySensors node offers the following functionalities:

  • Door and window opening detection (Reed switch)

The node is built with the Mini-BT-pcb-328p board which has multiple power options and supports both radio modules: RFM69 (868 Mhz) and NRF24 (THT and SMD), but keep in mind that the instructions and the 3d printable case that you will find here are for a build based on a RFM69 radio module and a CR2032 battery.

In this configuration the expected batteries life should be more than 1 year.

4 LEDs are present:

  • Radio Error → RED
  • Radio Transmission → YELLOW
  • Radio Reception → GREEN
  • External power / low battery → YELLOW

By default this LEDs are enabled, but if you don't wont too much annoying light in your home, you can easily change this behaviour in the firmware. The LED are always visible, especially if you use a white filament, because the case has 2 windows in which the thickness of the wall is reduced and consequently the transparency is more elevated.

Visit the dedicated topic in the forum if you want to share your experience with this node.

The d-diot d-diot door and window sensor is based on the d-diot Mini-BT-pcb-328p board.

Both versions of the board are suitable for this node.

The schematic and the entire Kicad project are available for download in the dedicated d-diot github repository. You can easily get 10 boards with about 5€ using an online PCB manufacturer like JLCPCB or PCB way.

Click the button below to download the complete set (zip) of gerber files necessary for the manufacturing of the board.

Download Gerber Mini-BT-Pcb-328P v.1.0

Download Gerber Mini-BT-Pcb-328P v.2.0

Or order the PCB directly from PCBWay.

Order your board with PCBWay

The brain of the node is the well known microcontroller ATMega328P-AU, which is the same MCU used in the Aruino UNO, Arduino Nano and Arduino Pro mini, so the sketches and the libraries of the Arduino platform are fully compatible. The MCU is available in generic e-commerce platforms for 1 - 2 euros.

For the radio module the board support multiple choices. You can use an RFM69HW (868 Mhz) radio module or an NRF24L01+ radio module (SMD or THT), but keep in mind that the 3d printable case and this instructions are for a RFM69 radio module.

With the RFM69HW radio module, you need also an external antenna that can be a helical antenna like the one in the picture below, but also a piece of solid wire with the length of 8.6 cm should work fine.

This two components are responsible for the opening and close of the door or window. The reed switch can be found for few cents in generic e-commerce platform (for example, see here and here).

The 3d printable case for the magnet is designed to hold up to 5 circular magnets of 10 x 5mm, but in most cases 2 or 3 units are more than enough. The number of units required depends on the distance between the nodes and the magnet when the door or window is closed; if the distance is small a single unit could be sufficient.

The Mini-BT-Pcb-328P board is designed to work with both, CR2032 and AAA batteries, but this door and window node is designed to hold a CR2032 battery.

For the CR2032 battery, any holder with a footprint like the Keystone 1058 is suitable. For example, I have used this.

For the AAA batteries, SMD contacts like the Keystone 55 are suitable.

The list of all the electronic components is reported below.

References Value Description Footprint Quantity
C12 47uF Electrolytic capacitor 47 uF 5 x 5.4 mm CP_Elec_5x5.4 1
C1 100uF Electrolytic capacitor 100 uF 6.3 x 5.4 mm CP_Elec_6.3×5.4 1
C7- C8- C9- C10- C11 0.1uF Capacitor 0.1 uF – SMD package 0805 C_0805_2012Metric 5
R3- R5 10K Resistor 10 Kohm – SMD package 0805 R_0805_2012Metric 2
R6- R7- R8- R10 330 Resistor 330 Ohm – SMD package 0805 R_0805_2012Metric 4
D3- D5 Y-LED LED – Yellow – SMD package 0805 LED_0805_2012Metric 2
D2 R-LED LED – Red – SMD package 0805 LED_0805_2012Metric 1
D4 G-LED LED – Green – SMD package 0805 LED_0805_2012Metric 1
U7 RFM69HW Radio Module - RFM69HW RFM69HW_SMD_Handsoldering 1
U4 ATmega328P-AU Microcontroller - ATmega328P-AU TQFP-32_7x7mm_P0.8mm 1
SW3 SW_Reed Reed Switch Reed-MKA-14103 1
SW2 Reset Tactile push button – SMD 3x6x2.5 mm SW_1437566-3 1
BT1 CR2032 CR2032 battery holder - SMD Keystone 1058 BatteryHolder_Keystone_1058_1x2032 1
Q1 FDN338P P-Mosfet – Code FDN338P – SMD package SSOT-3 SSOT-3 1
J5 ANT Helical antenna for the RFM69HW radio module PinHeader_1x01_P2.54mm_Vertical 1
JP1 Boost 1 x 03 Male Pin header - SMD - Veritcal pitch 2.54 mm PinHeader_1x03_P2.54mm_Vertical_SMD_Pin1Left 1
P1 MYSX_2.6 2 x 11 Male Pin header - SMD - Veritcal pitch 2.54 mm PinHeader_2x11_P2.54mm_Vertical_SMD 1

The following components are optional.

References Value Description Footprint
U2 ATSHA204A ATSHA204A IC chip SOT-23_Handsoldering
C4 0.1uF Capacitor 0.1 uF – SMD package 0805 C_0805_2012Metric
R2 10K Resistor 10 Kohm – SMD package 0805 R_0805_2012Metric

The ATSHA204A IC, the capacitor C4 and the resistor R2 are necessary only if you need the hardware signing functionality of the MySensors library. Please note that the security and signing features can be enabled also without dedicated hardware using software signing.

The 3d model files and the print instructions of the case are available in thingiverse.

If you don't have access to a 3d printer, you can consider an online 3d printing service.

To complete the build you need the following parts:

  • 1 x M2.5 self tapping screw
M2.5 self tapping screw

A cost estimation of the entire node (battery excluded) is around 5€

Well, this is the most time consuming part of the building, but once you have started the print job, you don't have too much to do except watching your 3d printer at work, so you can proceed with the other steps.

The model files are here.

Some components are THT, while some other are SMD, but generally with a 0805 package that is not so difficult to handle. The tools required for soldering the components of this board are the same of the d-diot board. See this to know what tools you need.

Use the interactive BOM tool to see where to place each component

The soldering process is divided in two parts for precaution; in fact if your programmer and FTDI adapter used for flashing the bootloader and the firmware does not have a voltage selector or if you don't select the 3.3V by mistake, you could damage the radio module that in most cases will not survive to a Vcc voltage above 3.3V.

The MCU works fine at 5V, so the flash of the bootloader and the firmware upload steps have been anticipated prior to the soldering of sensitive components.

Soldering - part 1

Solder the following components on the board:

  • ATmega328P MCU (U4)
  • MYSX Connector (P1)
  • Capacitors C7, C8, C9, C10 and C11
  • Resistor R5
  • Reset push button (SW2)

Burn the 1 Mhz MySensorsBootloader

With all the components of step above in place, you can proceed with the flashing of the “ATMega328p with MYSBootloader 1.3.0” which is necessary to the proper functionality of the node.

Connect the MISO, MOSI, SCK, RST, VCC, GND PIN of your programmer (USBasp) to the corresponding pin of the MYSX connector (PI) of the board and proceed according to this guide.

Upload the firmware

Connect the pin of your FTDI programmer to the MYSX connector (PI) of the board according to this scheme:

  • FTDI CTS → Unconnected or bridge with GND

Proceed according to this guide.

Soldering - part 2

Solder all the remaining components. The assembled board should look like this.

See the schematic if you want to know more about this jumpers.

  • JP1: bridge the Vcc and Vbatt pin to power the board. Board is off when the Vcc and Vbatt are not shortened
  • J3 (not soldered): open
  • JP2: open
  • JP3: open
  • JP4: open
  • JP5 (board v.2.0 only): open

Place the board inside the front part of the case and secure it with the M2.5 screw.

Insert the battery and close with the rear part of the case.

Insert the magnets in the bottom part of the holder and close with the top part.

The source code of the firmware is available here. Follow this guide to know how to upload the firmware to your node.

The configuration parameters are in the following files:

The comments above each parameter should be self-explanatory, but if you need more assistance visit the dedicated topic in the forum.

  • sensors_and_actuators/mysensors/door_window_sensor.txt
  • Last modified: 2020/07/17 20:45
  • by franzunix