meter Module

Status Last Update API Version
Active 2019-11-14 V1.00.00

Description

Access the on-board voltage & current meter.

meter.setDataSource()

Description

Set the data source of the readings.

Parameters

Name Type Range Usage
<dataSource> number meter.INSTANT meter.FILTERSTAGE1 meter.FILTERSTAGE2 Specify the data-source
  • meter.INSTANT: Set the reading to INSTANT, which updates every 1ms without any filtering.

  • meter.FILTERSTAGE1 : Set the reading to FILTERSTAGE1, this stage is the average of the meter.INSTANT readings, but the average time is defined by user, it is recommended for display purposes.

  • meter.FILTERSTAGE2 : Set the reading to FILTERSTAGE2, this stage is filtered again based on meter.FILTERSTAGE1 readings, it is recommended for display purposes which require stable readings.

If it is not for display purposes, it’s recommended to use meter.INSTANT as the data-source, as it provides fast and precise enough readings for most cases. Update rate of meter.FILTERSTAGE1 and meter.FILTERSTAGE2 are dependent on user settings.

Return value

nil

Example call

meter.setDataSource(meter.INSTANT)

meter.readVoltage()

Description

Get voltage reading of the meter in volts.

Parameters

nil

Return value

Name Type Range Usage
voltage number 0~36 Voltage reading

Example call

voltage = meter.readVoltage()

meter.readCurrent()

Description

Get current reading of the meter in amps. Notice that for display convenience, it returns the absolute value. If you want to get the current direction, call meter.readCurrentDirection().

Parameters

nil

Return value

Name Type Range Usage
current number 0~6 Current reading

Example call

current = meter.readCurrent()

meter.readPower()

Description

Get current reading of the meter in watts. Notice that for display convenience, it returns the absolute value.

Parameters

nil

Return value

Name Type Range Usage
power number 0~216 Power reading

Example call

power = meter.readPower()

meter.readDP()

Description

Get voltage reading of the USB DP in volts.

Parameters

nil

Return value

Name Type Range Usage
v_dp number 0~3.3 DP Voltage reading

Example call

dp = meter.readDP()

meter.readDM()

Description

Get voltage reading of the USB DM in volts.

Parameters

nil

Return value

Name Type Range Usage
v_dm number 0~3.3 DM Voltage reading

Example call

dp = meter.readDM()

meter.readCurrentDirection()

Description

Get direction of the current. Returns true if the direction is reversed, which is, the current goes from the output port back into the input port and vice versa.

Parameters

nil

Return value

Name Type Range Usage
dir boolean Direction

Example call

dir = meter.readCurrentDirection()