Skip to main content

Variables

Variables can be one of two things:

  • A link to a hardware or sensor value
  • A container of a value

Variables can be used in the Variable Set/Math and On Variable Changed blocks:

variable blocks

Hardware and Sensor Values

When hardware is added to the project, variables are automatically generated for each sensor or GPIO line.

In the case of sensors, the variable is linked to the sensor's value. This means that the variable's value is updated at a regular interval, and is the same as the sensor's value.

In the case of GPIO lines, the variable is linked to the GPIO line's state. Setting the variable's value to 1 will set the GPIO line to HIGH, and setting the variable's value to 0 will set the GPIO line to LOW.

Updating Variables

Updating the values of variables connected to hardware manipulates the hardware directly.

variablesvariables

Poll Interval

Variables that are automatically created from hardware are updated at a regular interval (Default 1 second). This interval can be set in the Settings menu.

Variables as Containers of Value

Variables can be used to store a value. This value can be a number, a string, a datetime, or a time.

Variable Values can be used directly in block parameters like this:

variable blocks

Variable Types

Variables can be of the following types:

  • Number (Integer or Decimal)
  • String (Text)
  • DateTime (Date and Time)
  • Time (Time of day)

Number

A number can be an integer or a decimal. A number is stored in IEEE754 format.

String

A string is a sequence of characters. Strings are stored in UTF-8 format.

DateTime

A datetime is a date and time. A datetime is stored in the Unix Timestamp format. This is the number of seconds since 1970-01-01 00:00:00 UTC.

Time

A time is a time of day. A time is stored in the format of number of seconds since midnight.