Skip to main content

Python driver for Arlyn UpScale Indicators.

Project description

arlyn-upscale

This repository was adapted from the alicat repository

TCP/Serial driver for Arlyn UpScale Touchscreen Indicator with the RS-232 serial port upgrade option.

Example Connections

Type Usage
The standard DB9 cable connected directly to a computer (unix: /dev/ttyS0, windows: COM1). Good with older computers that still have the connector.
The cable connected to a computer through a USB converter (unix: /dev/ttyUSB0, windows: COM1). Good for newer computers and maker boards such as Raspberry Pis.
The rj45 network port on the Arlyn UpScale Touchscreen Indicator (192.168.1.100:23) Using the scale over a network connection
Cables routed through a TCP device server (192.168.1.100:23). Using the scale over a network connection

Installation

git clone https://github.com/treychaffin/arlyn.git
cd alicat/
python setup.py install

Python Usage

Getting the weight string

This .print_weight method inputs the ~*P*~ serial command (shown in the Arlyn UpScale Touchscreen User Manual)

Example Usage

from arlynupscale import Scale

arlyn_address = 'ip-address:port'

async def get_weight_string(scale_address: str) -> str:
    '''Retrieve the weight string from the scale'''
    async with Scale(scale_address) as scale:
        return await scale.get_weight_string()

print(await get_weight_string(arlyn_address))

The method and the function shown will return a string showing the date, time, weight, unit, and whether or not the scale is in net mode.

'03/31/2024 17:28:08, 0.00 kg'

Toggle Unit

This .toggle_unit method inputs the ~*U*~ serial command (shown in the Arlyn UpScale Touchscreen User Manual)

The order in which the scale toggles: kg -> g -> oz -> lb ->

Example Usage

from arlynupscale import Scale

arlyn_address = 'COM6'

async def toggle_unit(scale_address: str) -> None:
    '''Toggles the unit change command'''
    async with Scale(scale_address) as scale:
        await scale.toggle_unit()

await toggle_unit(arlyn_address)

This method and function shown returns nothing

Zero Scale

This .zero_scale method inputs the ~*Z*~ serial command (shown in the Arlyn UpScale Touchscreen User Manual)

Example Usage

from arlynupscale import Scale

arlyn_address = '/dev/ttyS0'

async def zero_scale(scale_address: str) -> None:
    '''Sets the current weight on the scale to zero'''
    async with Scale(scale_address) as scale:
        await scale.zero_scale()

await zero_scale(arlyn_address)

This method and function shown returns nothing

JSON String

This .get_json method inputs the ~*W*~ serial command (shown in the Arlyn UpScale Touchscreen User Manual). The JSON string is converted into a dictionary.

Example Usage

from arlynupscale import Scale

arlyn_address = '/dev/ttyUSB0'

async def get_json(scale_address: str) -> dict:
    '''Retrieve a JSON string of the scales current status'''
    async with Scale(scale_address) as scale:
        return await scale.get_json()

print(await get_json(arlyn_address))

This method and function shown will return a dictionary

{'bSIndi': True, 'sNet': '', 'sUnit': 'kg', 'sWeight': '0.05', '_CMD_ACK': 'ACK', '_id': 1, '_name': '*W', '_rSNo': 42, '_sSNo': 24}

Weight Dictionary

The .get_weight_dict method obtains the the weight string from using the .get_weight_string method. Then, regex is used to extract and organize the information from the string into a dictionary.

Example Usage

from arlynupscale import Scale

arlyn_address = 'ip-address:port'

async def get_weight_dict(scale_address: str) -> dict:
    '''
    Retrieve the weight string from the scale, then extracts the information into 
    a dictionary. Converts weight value into a float
    '''
    async with Scale(scale_address) as scale:
        return await scale.get_weight_dict()

print(await get_weight_dict(arlyn_address))

This method and function shown will return a dictionary:

{'date': '04/05/2024', 'time': '11:39:30', 'weight': 50.0, 'unit': 'g', 'netMode': False}

Change Unit

The .change_unit method used the .toggle_unit method to change the unit value to the desired unit.

Example Usage

from arlynupscale import Scale

arlyn_address = 'COM6'

async def change_unit(scale_address: str, desired_unit: str) -> None:
    '''Toggles through units until scale is set to desired unit'''
    async with Scale(scale_address) as scale:
        return await scale.change_unit(desired_unit)

await change_unit(arlyn_address, 'kg')

This method and function shown does not return anything.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arlynupscale-0.0.6.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

arlynupscale-0.0.6-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file arlynupscale-0.0.6.tar.gz.

File metadata

  • Download URL: arlynupscale-0.0.6.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for arlynupscale-0.0.6.tar.gz
Algorithm Hash digest
SHA256 0cd7e92f47b6b67b17592cd589f175f6f8f071e24a90a690582971c473a04c6e
MD5 1305ecfd594c4ee7b1e7cd2d94b13f0e
BLAKE2b-256 e172003730f0c25c1c14b6e1051ae5cc7600e8b8f611ccdcda1095ed3fef919e

See more details on using hashes here.

File details

Details for the file arlynupscale-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: arlynupscale-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for arlynupscale-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 8712f5001762132d589c78fa0234a42ba99332e99c04e7d0e5f7be01cc1122f3
MD5 ff09c3ac127c9f77e78a09104483713c
BLAKE2b-256 0f9b995b35c0e86d2b8afca36c20af3298a89ce8945c938ae0f961e67d7af2c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page