Skip to main content

Lua Scripting with PRM3

Back to Main Power Relay Module (PRM3) Product Page.

The eGauge meter provides a Lua scripting environment for interaction and control of the eGauge PRM3 Power Relay Module when connected to the eGauge via USB.

Navigating to the Lua Scripting interface

Control script

See the main Lua Scripting Overview Control Scripts section for additional Lua Control environment information.

There is risk of damaging external equipment using control scripts. Only skilled Lua developers familiar with the eGauge meter and software should attempt to use Lua control scripts.

Control scripts can be used to confrol supported equipment such as the eGauge Power Relay Module (PRM3).

For example, the following script reads the instantaneous value of a register called "Temperature" and controls a PRM3 relay contact. If the temperature is lower than 21 C, relay number 0 of the PRM3 is closed (activated), otherwise opens (turns off) relay number 0. It then sleeps for 15 minutes before checking again.

In the real world, the control script should be more advanced

dev = ctrl:dev({interface='relay'})
  relay = dev:interface('relay')

  while true do
    print("Temperature is currently: " .. __r("Temperature"))
    if __r("Temperature") < 21 then
        relay:close(0)
    else
        relay:open(0)
    end
    sleep(60*15)
  end