Code Overview

To interface with the DYMO scale's data protocol, we wrote a CircuitPython library called Adafruit CircuitPython DymoScale.

To take a reading from the scale (the library returns the weight in grams), we call

reading = dymo.weight

Then, print out the weight of the reading to the REPL as well as the weight_label on the PyPortal's display:

text = "%0.1f g"%reading.weight
weight_label.text = text
weight_label.color = 0xFFFFFF

Now that you have the data from the scale, it is time to send it to Adafruit IO. To do this, the code uses the send_data method from Adafruit IO CircuitPython.

For the weight on your dashboard to reflect what's displayed on the PyPortal the weight sent to IO is rounded to one decimal place.

print('Sending to Adafruit IO...')
text_label.color = 0xFFFFFF
text_label.text = 'Sending...'
# send data to Adafruit IO (rounded to one decimal place)
io.send_data(weight_feed['key'], round(reading.weight, 1))

That's it - sending data to Adafruit IO with CircuitPython is simple!

Removing the Auto Shut Off

The M-series DYMO scales have an automatic shut off "feature". The scale turns off after three minutes of inactivity. While this is a useful feature to preserve the scale's batteries - it causes the scale to turn off if we're measuring anything over a length of three minutes.

If you're measuring the volume of a mug of pour-over coffee or a bag of cat food - the scale will turn off. 

Dymo M-Series Manual (

In the Wiring page, you soldered a wire onto the Grams/Ounces button and connected it to your PyPortal. We've included a method in the adafruit_dymoscale library called toggle_unit_button to simulate pressing the button for you.

When the dymo object is initialized in the code, the units_pin is provided to it along with the scale's data pin.

units_pin = digitalio.DigitalInOut(board.D3)
dymo = adafruit_dymoscale.DYMOScale(board.D4, units_pin)

Then, the code takes a reference time reading with time.monotonic() 

# take a reading of the current time, used for toggling the units button
time_stamp = time.monotonic()

Each time the code runs through the while True loop, we'll check it against the current time. If it exceeds two minutes, the code toggles the unit button (dymo.toggle_unit_button()) and resets the timestamp by setting it to the current time.

# to avoid sleep mode, toggle the units pin every 2 mins.
if (time.monotonic() - time_stamp) > 120:
  print('toggling units button...')
  # reset the time stamp
  time_stamp = time.monotonic()

By performing this toggle, our scale never falls asleep! 

This guide was first published on Apr 02, 2019. It was last updated on Dec 10, 2023.

This page (Code Walkthrough) was last updated on Apr 02, 2019.

Text editor powered by tinymce.