iMSB Lua Library

Lua Logo


With the iMSB Lua libraries user scripts can be attached to dedicated sensor values. Lua is a powerful, efficient and embeddable multi-paradigm programming language designed as a scripting language. Detailed description and reference information is available at

iMSB supports sensor value based scripts. This means that a script can be associated to a specific sensor value that will be evaluated on a regular basis during data logging. Such a value behaves as any other value. It can thus be visualized, announced and logged by the standard iMSB functionalities.

Lua scripted values are available in a dedicated script sensor that contains eight values to which a Lua script template is attached to. You can of course instantiate several occurrences of this sensor.

In order to use Lua scripts the following steps must be performed:

  • The “Expert mode” must be enabled in the “Data logging” section of the application preferences
  • A “Script sensor” must be added to your model 

iMSB Lua library reference

At time being 4 libraries are available to the developers:

  • The SensorValue class: The SensorValue class mostly defines setter and getter methods that allow retrieving or setting specific value information. Within a value script you can read attributes of every sensor value that is available in your model, such as its value, statistics minimum or maximum data, alarm values and configuration, etc. Writing data to a value can be done to the value the current script is attached to.
  • The  TransmitterEvent class: The TransmitterEvent class allows instantiation of iMSB trigger and conditional transmitter events, such as GPIO switch events, sensor value transitions and timer triggers. When instantiating a trigger event you need to specify a callback function that will be called whenever the trigger conditions are met. All trigger-based events that are available in the application can be accessed through this library
  • The imsb library: The imsb library provides a set of functions that can be used within your script to control various aspects of the application that are not directly bound to a sensor or sensor value
  • The device library: The device library provides a set of functions related to positional and attitude information of your iOS device. Its grants access to the internal GPS and motion sensors

Download the full documentation

Sample scripts:

You can refer to these two sample scripts to help you get started with iMSB Lua.

 Thomas Styger, iMSB   © 2012