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