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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

Supported by

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