Our software 232key was originally designed to make it as easy as possible to capture the weight sent by a scale or balance (and then transmit it to another application as simulated keystrokes). As most weighing instruments also include the unit and possibly other characters, 232key assumes that the first (decimal) number it encounters is the weight. If you also want to capture the date and time sent from a scale, this can lead to unwanted results.
Capturing the net weight
Let’s look at a simple example first. Below you’ll see the data received from an Ohaus Scout STX scale configured to transmit only the net weight (as it appears in the event log in 232key):
Net: 302.4 g ? N<13><10>
The blue characters were captured by 232key using the “Ohaus” device profile. In this example, 232key managed to successfully capture the weight.
Capturing the net and tare weight
If we set the scale to send both the net and tare weight, the event log shows that 232key still captures both values:
Net: 302.4 g ? N<13><10> Tare: 7.9 g T<13><10>
To have them appear in separate columns in spreadsheet applications like Excel, OpenOffice Calc or Google Sheets, we can go the output tab and modify the end with settings as shown below:
Alternating the “TAB” with the “Enter” key every 2 value will produce the desired result (shown in Google Sheets):
Capturing date and time
Things get significantly more complicated if we configure the scale to also send the date and time. The event log now looks as follows:
11/17/2017 15:04:21<13><10> Net: 302.4 g N<13><10> Tare: 7.9 g T<13><10>
Using its default strategy of capturing the first number in each line, 232key only captures “11” and ignores the rest of the combined date/time line (as the backslash cannot be a part of a decimal number).
We can try to fix this by going to the device tab and setting the device to “Barcode alphanumeric extended” (available in the Plus version). This device appears in italics, which means that it is a “text” device instead of a “numeric” device. Note: Do not click the set defaults button after making this change.
As the scale is now sending three lines of data, we should also enter the number “3” in the end with settings in the output tab:
If we press the print button on the scale again, the event log will show that all data has been captured by 232key:
11/17/2017 15:09:51<13><10> Net: 302.2 g N<13><10> Tare: 7.9 g T<13><10>
The output in Google Sheets looks as follows:
If we simply wanted to record all data sent from the scale, this would be fine. However, it is not ideal for further processing for two reasons:
- Date and time appear together in one column.
- The measurement values are not recognized as numbers because the cells contain additional text.
232key does currently not support extracting multiple values from one line of data, so there’s nothing we can do about the first issue. Unfortunately, our Ohaus Scout STX scale cannot send the date and time in separate lines.
The second issue can be fixed using custom regular expressions. To do this, go to the device tab, click on the customize button and replace the existing regular expression with the following one:
Note: This regular expressions assumes the scale is using the 24 hour time format.
The event log and the output in the spreadsheet now look as follows:
15:38:40 11/17/2017 15:39:01<13><10> 15:38:40 Net: 302.2 g N<13><10> 15:38:40 Tare: 7.9 g T<13><10>
The cells containing the net and tare weights are recognized as numbers and can be used for further calculations.
If we just wanted to capture the time (and maybe add a “date” column manually), we could use the following regular expression:
- The regular expressions above have been customized to work with the Ohaus Scout STX scale (configured to send the date, time and weight). They might not work with other scales and balances.
- As we’re now using a “text” device, the computation and rounding settings in the process tab have been disabled (you can’t round non-numeric characters).
- The option to change the decimal separator from a dot to a comma is also no longer available (and our custom regular expression does not capture decimal numbers using a comma as the separator).
- For data logging purposes, consider using our new Simple Data Logger software instead of 232key. It has the ability to add the date and time to each weight. The CSV files it produces can be easily opened in Excel and other spreadsheet apps.
- 232key version 2018.1.4 released – includes flow control support and new profiles for Mettler Toledo and Sartorius balances
- 232key version 2018.1.3.0 released
- Does 232key work with Moxa NPort serial device servers?
- How to write the date, time and weight from your scale to Excel
- 232key version 2018.1.2.0 released