Home Elements Boards Recipes

Digital Signal Element

The DigitalSignalElement is used to handle digital input with short time level changes that might be missed when using the [DigitalInput Element](/elements/digitalin.md). On a changing input a pulse value is created with a defined duration.

When a digital input signals like spikes are created on a GPIO input they may not last long enough to be detected by reading the actual level in the loop function.

To avoid missing these input signals interrupts are used that are triggered by the GPIO hardware when the signal level changes. Inside the interrupt routine itself no action can be created so every detected digital signal change will incrementing an internal counter that is then analyzed in the loop function.

The output signal is generated with a given minimal duration and stays high as long as the input changes.

Element Configuration

The following properties are available for configuration of the element:

pin* - the GPIO pin used for input.

pullup - When defining with true the internal pullup resistor for the input pin will be activated.

duration - the duration of the generated output pulse with a value of 1

onHigh - These actions are emitted when the logical level is switched to 1.

onLow - These actions are emitted when the logical level is switched to 0.

onValue - These actions are emitted when the logical level is switched.

From the base element implementation the following properties are available for configuration:

title – Caption text for the element. Used by the element specific cards on the dash boards.

description – A line of text that gives a short description of the device used in the web UI.

room – The location of the device.

loglevel – This property holds the element specific log level. The default value is LOGGER_LEVEL_ERR == 1.

startup – This property can be used to start the element using a different initialization phase. Possible values are “sys”, “net”, “time”. See The Startup sequence.

* This parameter must be specified.

Configuration Example

This example shows how to configure this element:

{
  "digitalsignal": {
    "d5": {
      "description": "Listen for level changes on pin D5",
      "pin": "D5",
      "pullup": "true",
      "onvalue": "console/log?value=D5:$v"
  }
}

State

The state of the DigitalSignal element available at runtime includes the current values:

active - Is set to true when the Element is active.

value - The current output value from the generated pulse.

Example State

{
  "digitalsignal/d5": {
    "active":"true",
    "value":"0"
  },
}

See also

Tags

Element Input