Skip to main content

Alarm Rules (alarm)

Alarms generate an immediate uplink when a condition is met. The rules are managed with the alarm command over the developer shell (see Firmware Setup for opening the console). Two related config parameters control how often alarm uplinks are sent:

CommandArgumentDescription
config alarm-limit0-3600 (seconds)Minimum interval between alarm uplinks. The first alarm is sent immediately; further alarms within the window are suppressed. 0 = disabled. Default 0.
config alarm-notif-time1-60 (seconds)Red-LED hold time for pulse and momentary (PIR, accelerometer) alarms. Default 10.

Dynamic alarm rules

Per-sensor thresholds are dynamic rules held in 16 fixed slots (0-15). The slot index is the rule's stable identity, and several slots may target the same sensor (for example a warning band and a separate critical band).

CommandDescription
alarm list [<index>]List all rules, or one slot.
alarm set <index> <source> <quantity> <args>Write a rule into a specific slot.
alarm new <source> <quantity> <args>Write a rule into the first free slot.
alarm clear <index> / alarm clear allDelete one slot, or all of them.
alarm pollSample and evaluate the rules now (bench test).

Source - which sensor the rule watches:

SourceSensor
onboardOn-board temperature / humidity / pressure
s1 - s41-Wire sensor slots 1 to 4
hall-left, hall-rightHall switches
input-a, input-bExternal inputs
pirPIR motion detector
accelAccelerometer

Quantity - what is measured, which also fixes the argument kind:

QuantityKindArgumentsValid sources
temperature, humidity, pressurethreshold<lo> <hi> [hst]onboard; temperature/humidity also on s1-s4
illuminance, magnetic-fieldthreshold<lo> <hi> [hst]s1-s4
tiltstate<from> <to>s1-s4
statestate<from> <to>hall-*, input-*, pir, accel
countrate<N>hall-*, input-*, pir, accel
  • threshold: the alarm fires when the value leaves the [lo, hi] band; hst is an optional hysteresis dead band (default 0).
  • state: <from> <to> are digital levels (0/1). from != to is an edge (fires once on that transition); from == to is a level (active while the line equals to). PIR and accelerometer are momentary sources, so only edge rules are accepted there.
  • rate: <N> is the maximum number of counter events allowed per report interval.

Examples:

alarm set 0 onboard temperature 5 30 1 # alarm below 5 C or above 30 C, 1 C hysteresis
alarm set 1 input-a state 0 1 # fire when input A goes from 0 to 1 (rising edge)
alarm new hall-left count 10 # alarm at 10 or more pulses per report interval
alarm list # review all rules
alarm clear 1 # delete slot 1
Over the air

The same rules can be set over NFC or LoRaWAN with the set_param command, where each slot is a packed binary value rather than these shell arguments. The Downlink Commands Generator builds those rules from a form. The shell alarm command is the local equivalent.