Skip to main content

WeightScale

caution

This service is rc and may change in the future.

A weight measuring sensor.

import { WeightScale } from "@devicescript/core"

const weightScale = new WeightScale()

Commands

calibrateZeroOffset

Call this command when there is nothing on the scale. If supported, the module should save the calibration data.

weightScale.calibrateZeroOffset(): Promise<void>

calibrateGain

Call this command with the weight of the thing on the scale.

weightScale.calibrateGain(weight: number): Promise<void>

Registers

reading

The reported weight.

  • type: Register<number> (packing format u16.16)

  • read only

import { WeightScale } from "@devicescript/core"

const weightScale = new WeightScale()
// ...
const value = await weightScale.reading.read()
  • track incoming values
import { WeightScale } from "@devicescript/core"

const weightScale = new WeightScale()
// ...
weightScale.reading.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

readingError

The estimate error on the reported reading.

  • type: Register<number> (packing format u16.16)

  • optional: this register may not be implemented

  • read only

import { WeightScale } from "@devicescript/core"

const weightScale = new WeightScale()
// ...
const value = await weightScale.readingError.read()
  • track incoming values
import { WeightScale } from "@devicescript/core"

const weightScale = new WeightScale()
// ...
weightScale.readingError.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

zeroOffset

Calibrated zero offset error on the scale, i.e. the measured weight when nothing is on the scale. You do not need to subtract that from the reading, it has already been done.

  • type: Register<number> (packing format u16.16)

  • optional: this register may not be implemented

  • read and write

import { WeightScale } from "@devicescript/core"

const weightScale = new WeightScale()
// ...
const value = await weightScale.zeroOffset.read()
await weightScale.zeroOffset.write(value)
  • track incoming values
import { WeightScale } from "@devicescript/core"

const weightScale = new WeightScale()
// ...
weightScale.zeroOffset.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

gain

Calibrated gain on the weight scale error.

  • type: Register<number> (packing format u16.16)

  • optional: this register may not be implemented

  • read and write

import { WeightScale } from "@devicescript/core"

const weightScale = new WeightScale()
// ...
const value = await weightScale.gain.read()
await weightScale.gain.write(value)
  • track incoming values
import { WeightScale } from "@devicescript/core"

const weightScale = new WeightScale()
// ...
weightScale.gain.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

maxReading

Maximum supported weight on the scale.

  • type: Register<number> (packing format u16.16)

  • optional: this register may not be implemented

  • constant: the register value will not change (until the next reset)

  • read only

import { WeightScale } from "@devicescript/core"

const weightScale = new WeightScale()
// ...
const value = await weightScale.maxReading.read()
note

write and read will block until a server is bound to the client.

minReading

Minimum recommend weight on the scale.

  • type: Register<number> (packing format u16.16)

  • optional: this register may not be implemented

  • constant: the register value will not change (until the next reset)

  • read only

import { WeightScale } from "@devicescript/core"

const weightScale = new WeightScale()
// ...
const value = await weightScale.minReading.read()
note

write and read will block until a server is bound to the client.

readingResolution

Smallest, yet distinguishable change in reading.

  • type: Register<number> (packing format u16.16)

  • optional: this register may not be implemented

  • constant: the register value will not change (until the next reset)

  • read only

import { WeightScale } from "@devicescript/core"

const weightScale = new WeightScale()
// ...
const value = await weightScale.readingResolution.read()
note

write and read will block until a server is bound to the client.

variant

The type of physical scale

  • type: Register<number> (packing format u8)

  • optional: this register may not be implemented

  • constant: the register value will not change (until the next reset)

  • read only

import { WeightScale } from "@devicescript/core"

const weightScale = new WeightScale()
// ...
const value = await weightScale.variant.read()
note

write and read will block until a server is bound to the client.