Raspberry Pi: Connecting a scale can be very easy…

…as long as you choose the right scale! The photo below shows an A&D EK-2000i compact balance connected to a Raspberry Pi 3 Model B using a compatible serial cable and an FTDI RS-232 to USB converter:
Scale connected to Raspberry Pi

Python and pySerial make it easy to read weight data from a scale

On the Pi, I used Python with pySerial to read the weight from the scale. The script I put together is trivially simple. You can download it here or just type it on the Pi:
Script to read weight sent from A&D scale

By pressing the PRINT-Button on the scale, I then sent a few weight values to the Pi and the script wrote them to the terminal (b’ is added by Python):
Weight printed to terminal

In a more useful application, you would want to parse the data sent from the scale to get the weight as a number and then do something with it (maybe write it to a database). You could also do interesting things with the GPIO on the Pi like sounding an alarm when a certain weight is exceeded (though a microcontroller might be better suited for this).

I then switched the scale to “stream mode” (continuous transmission) where it sent 10 values per second (stable or not). The output you see below is the result of placing a single object on the scale and waiting for it to stabilize:
Weight data in continuous mode

I hope this example shows that it can be really easy to transfer the weight from a scale to a Raspberry Pi.

Notes on scales and the Raspberry Pi

One advantage of A&D scales is that (almost) all of them use the same data format and interface parameters and that you’ll find a good description in the manual:
A&D EK-i balance data format

However, you could use also use scales made by other manufacturers as long as they come with an RS-232 interface and the ability to send the weight in ASCII format. Available data output modes vary, so please read the product description carefully before buying.

A converter like the one I used is already built into some scales, which means that you can directly connect them to the Raspberry Pi via USB (you won’t need a serial cable). You’ll find many Ohaus scales with this interface option and the ones I’ve tested worked fine. However, cheaper scales with a USB interface can often not be used with pySerial as they do not emulate a serial port. They can also present other challenges (e.g. data that is not transmitted in human-readable ASCII format).

You do of course not have to use Python, just make sure that your preferred programming language can communicate over a serial port on the Pi. The book Raspberry Pi with Java: Programming the Internet of Things (IoT) contains projects using Ohaus scales and, well, Java.

Finally, please don’t try to use the serial interface already provided by the Pi on the GPIO pins without a logic level converter (RS-232 voltage could reach up to 15V). Excellent further information on serial ports on the Raspberry Pi can be found here.

200 years of legal metrology in Luxembourg

Did you know that Luxembourg’s law of August 21st 1816 made the metric system obligatory for all commercial transactions? I didn’t, until I was invited to the 200 year celebration “Bicentenaire de la Métrologie Légale”, which took place in Belval yesterday. The most prominent speaker, Luxembourg’s Deputy Prime Minister and Minister of the Economy Étienne Schneider, took this opportunity to announce that Luxembourg has decided to acquire an atomic clock.

Deputy Prime Minister and Minister of the Economy Étienne Schneider

Deputy Prime Minister and Minister of the Economy Étienne Schneider

Other speakers included ILNAS director Jean-Marie Reiff, BLM director Philippe Kadok, Professor Olivier Francis from the University of Luxembourg and Dr. Martin Milton, director of the BIPM. Mr. Kadok’s presentation contained a slide a few interesting facts about the Service de Métrologie Légale: In 2015, this relatively small sub-organization of the BLM verified 2861 petrol pumps and more than 1450 weighing instruments of all types throughout the country.

BLM director Philippe Kadok

BLM director Philippe Kadok

Several organizations with ties to the field of metrology had set up stands in the conference hall. The Service de Métrologie Légale’s stand showcased balances, weights and other measurement instruments. Sadly, recently retired director John Kirchen was nowhere to be seen.

Service de Métrologie Légale

Service de Métrologie Légale

A&D EK-610i balance used for density determination

A&D EK-610i balance used for density determination

Visitors were also invited to take a tour of ILNAS’ recently inaugurated EMC lab (used only for market surveillance purposes, not for product certification).



Free software for scales and balances with RS-232 and USB

Are you still manually entering weight readings from your scale or balance on your PC? Is your scale equipped with a RS-232 or USB (virtual COM port) interface? If yes, you can eliminate manual data entry by connecting your scale to your computer and using our free software 232key.

232key automatically types the weight into any application

Our software runs in the background, listens to the COM port (serial port) your scale is connected to and waits for measurement values sent by the scale. Those values are then filtered, formatted and typed into the application running in the foreground at the current cursor position as simulated keystrokes. This means that 232key can be used to transfer the weight (or other measurement values) into any application that accepts keyboard inputs, e.g. Microsoft Excel, OpenOffice / LibreOffice Calc, Google Docs, a form on a website, etc.

In the following example, I used A&D’s FG-60KBM scale with an optional RS-232 interface (FG-OP-23). I connected it to my laptop with A&D’s serial cable (AX-PC09-SCA) and an inexpensive converter to USB (as my laptop doesn’t have a serial port). Upon pressing the “PRINT” key on the scale, the weight was typed directly into an input field on a website:
Transferring the weight from a scale to a website

Compatibility with scales and balances

To use 232key, you’ll need a scale with a RS-232 interface (aka. serial port, COM port, EIA-232) or an interface which appears as a (virtual) COM port when the scale is connected to your PC. This is the case for many (but not all) scales with a USB interface and for scales which support the Bluetooth Serial Port Profile.

Your scale or balance also has to send the weight in ASCII format. The weight has to be the first numeric value sent* and it should only be sent once (after you’ve pressed a key on the scale), not continuously.

The vast majority of scales and balances available on the market today fulfills these requirements. Just to give you a few examples, you should be able to use 232key with most or all scales and balances made by A&D (RS-232 only), Adam Equipment (RS-232 and USB), Ohaus** (RS-232 and USB), Kern**, MyWeigh (RS-232 only) and other well-known brands. New device profiles are constantly added!

Finally, an easy way to transfer data from your scale to your PC

We designed 232key to make your life easier. No complicated configuration is required. If your scale manufacturer or model is included in the list of predefined devices, you don’t even have to manually enter the interface parameters: Simply select your scale and click on “Default” to load the settings.
Interface settings

Not sure which COM port you scale is connected to? Press the “Auto” button and 232key will try to detect the port automatically (works with all devices which have some sort of hardware handshaking functionality, e.g. scales and balances made by A&D and MyWeigh’s popular HD series).

Do you know which decimal separator (point or comma) your scale is using? Why should you! 232key understands both input formats and lets you choose which output format you want.
Decimal separator

Would you like 232key to press an additional key after typing the weight, e.g. the “Enter” key to jump to the next row in a spreadsheet? No problem, simply specify the desired key in the “Format” tab.
Additional key

All of these useful and user-friendly features are available for free! Additional functionality is available in the paid “Plus” version of 232key.

Download and documentation

Please visit our product website 232key for further information and to download our free software. Should you have any questions or suggestions, please don’t hesitate to post them in our support section or as a comment below.

* We’ve added an exception to this rule for scales and balances made by Adam Equipment.
** Affiliate links.

Update May 2018: Write the weight to a file

232key is a great solution for sending the weight from your scale to an application running on your PC (as simulated keystrokes). In some cases, however, it makes more sense to record the weight to a file which is later opened in Excel (or other applications).

This is particularly true for unattended data logging applications running over long periods of time. Another example are applications with high data rates (several weight values per second) which would overwhelm a virtual keyboard wedge like 232key.

For these use cases, we’ve recently released Simple Data Logger, an easy to use solution for recording the weight sent from your scale to a CSV file. You can read more about it on this blog or on www.smartlux.com/sdl.