Skip to main content

Python port of the SparkFun Qwiic Scale NAU7802 Arduino Library

Project description

PyNAU7802

Python port of the SparkFun Qwiic Scale NAU7802 Arduino Library

Install

To install, simply use : pip install PyNAU7802 in a terminal window

How to use

The function name and arguments are the exact same as the original library, use it's documentation to get started.

Examples

Multiple examples are available in the examples/ directory.

This package use smbus2 as the I2C bus. Here is a small working example :

import PyNAU7802
import smbus2

# Create the bus
bus = smbus2.SMBus(1)

# Create the scale and initialize it
scale = PyNAU7802.NAU7802()
if scale.begin(bus):
    print("Connected!\n")
else:
    print("Can't find the scale, exiting ...\n")
    exit()

# Calculate the zero offset
print("Calculating the zero offset...")
scale.calculateZeroOffset()
print("The zero offset is : {0}\n".format(scale.getZeroOffset()))

print("Put a known mass on the scale.")
cal = float(input("Mass in kg? "))

# Calculate the calibration factor
print("Calculating the calibration factor...")
scale.calculateCalibrationFactor(cal)
print("The calibration factor is : {0:0.3f}\n".format(scale.getCalibrationFactor()))

input("Press [Enter] to measure a mass. ")
print("Mass is {0:0.3f} kg".format(scale.getWeight()))

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

pynau7802-0.2.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

pynau7802-0.2.2-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file pynau7802-0.2.2.tar.gz.

File metadata

  • Download URL: pynau7802-0.2.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Windows/10

File hashes

Hashes for pynau7802-0.2.2.tar.gz
Algorithm Hash digest
SHA256 0ba267046efd0c9fd5a798be20d72fba7a6883d08376ea0adc6ff18d3ed6d8cc
MD5 07c443485c1e509dbb09efde34cc90c5
BLAKE2b-256 2a6cbc6d974cb25d9f82b42789214f8dccb8710b1c98fddf99943cec1d88c56b

See more details on using hashes here.

File details

Details for the file pynau7802-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: pynau7802-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Windows/10

File hashes

Hashes for pynau7802-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e53075829178c21b154743791ab8d067c8d49935e7ca0a58cd9c2cfe259b3252
MD5 572cbd454dfae0bfc57ec0ccc0a28c93
BLAKE2b-256 472358079fff7274fb8c4dec2cea268b11f955bbaec10250ef87ee57eb2b99af

See more details on using hashes here.

Supported by

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