Simple test

Ensure your device works with this simple test.

examples/dymoscale_simpletest.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import time
import board
import digitalio
import adafruit_dymoscale

# initialize the dymo scale
units_pin = digitalio.DigitalInOut(board.D3)
units_pin.switch_to_output()
dymo = adafruit_dymoscale.DYMOScale(board.D4, units_pin)

# take a reading of the current time
time_stamp = time.monotonic()

while True:
    reading = dymo.weight
    text = "{} g".format(reading.weight)
    print(text)
    # to avoid sleep mode, toggle the units pin every 2 mins.
    if (time.monotonic() - time_stamp) > 120:
        print('toggling units button...')
        dymo.toggle_unit_button()
        # reset the time
        time_stamp = time.monotonic()