NAHS-LatchBrick v1.0

This is a generic digital input sensor, featuring two inputs. Amongst others it can be used as a door-/window-sensor or (light) switch. The latch states can be tracked in InfluxDB and emit MQTT messages on change and periodically (by default only the periodically are enabled). This gives you the full flexibility to trigger whatever action you like with a LatchBrick.


The inputs detect a high or low state and can be configured to trigger on edge detection (transition from high to low or low to high) or (as I call them) bumps. Bumps are the following sequences of states: high-low-high or low-high-low where the middle state is held under one second. By default both edges and bumps are disabled, so only the finite states (high or low) are recorded periodically.

All six states are published via MQTT (if MQTT is enabled for the latch and the corresponding state is configured to trigger). The MQTT topic builds up as /brick/<brick_id>/latch/<latch_index> and the payload contains the triggering state as an integer as noted in the following table:

state (payload)description
0Low-Level (Low)
1High-Level (High)
2Falling-Edge (High-Low)
3Rising-Edge (Low-High)
4Rising-Bump (Low-High-Low)
5Falling-Bump (High-Low-High)

By reading the table you might think states (payload) 4 and 5 are flipped, but it’s on purpose they have this order. With the states as they are, it is possible to do a modulus two operation and get the resulting state of a latch. This can be quiet useful on graphing or processing. For Example:

  • a Rising-Edge results in 3 % 2 = 1 (High-Level)
  • a Rising-Bump results in 4 % 2 = 0 (Low-Level)

Hardware Overview

  1. NAHS-Brick-Interface_v3 programming interface connector
  2. reset button
    (soft reset (wake) ESP, needed to push for entering programming or setup mode)
  3. USART header
    (for programming ESP8266 and running setup)
  4. UPDI header
    (for programming ATtiny212, CoIC for handling Latch IO)
  5. mode selector header
    (connect middle and lower pin to enter ESP programming or connect middle and upper pin to enter setup mode)
  6. power input
    (for charging or wall-power)
  7. power input selector
    (select the input-power connected to ESP, either BAT or USB)
  8. voltage regulation
    (steps down the selected input-power to 3.3Volts)
  9. battery holder
    (for unproteced 18650 LiIon cells)
  10. battery protection circuit
  11. battery charging circuit
    (configured to charge battery from power input with up to 700mA)
  12. battery charging indicator
    (lights up red if battery is currently charged)
  13. testpoints for battery calibration
    (needed during setup, to calibrate the voltage reading of input-power)
  14. latch input header
    (lower pins are connected to ground, upper pins are inputs with pull-up resistors)