Git Product home page Git Product logo

circuitpython_nau7802's Introduction

Introduction

Discord Build Status Code Style: Black

A CircuitPython driver class for the NAU7802 24-bit ADC.

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle or individual libraries can be installed using circup.

Installing to a Connected CircuitPython Device with Circup

Make sure that you have circup installed in your Python environment. Install it with the following command if necessary:

pip3 install circup

With circup installed and your CircuitPython device connected use the following command to install:

circup install cedargrove_nau7802

Or the following command to update an existing version:

circup update

Installing for Blinka with Pip

pip3 install cedargrove-nau7802

Usage Example

import board
from cedargrove_nau7802 import NAU7802

# Instantiate NAU7802 ADC
nau7802 = NAU7802(board.I2C(), address=0x2A, active_channels=2)

nau7802_simpletest.py and other examples can be found in the examples folder.

Documentation

NAU7802 CircuitPython Driver API Class Description

Clue Coffee Scale (Adafruit Learning Guide)

CedarGrove NAU7802 FeatherWing OSH Park Project (16-SOIC version)

CedarGrove NAU7802 FeatherWing OSH Park Project (16-DIP version)

https://github.com/CedarGroveStudios/CircuitPython_NAU7802/blob/main/media/glamor_shot.jpeg

https://github.com/CedarGroveStudios/CircuitPython_NAU7802/blob/main/media/Clue_scale_trim.png

Needing a calibration weight? The U.S. Mint coin specifications might have some information that could help -- if you have some spare change.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project be welcoming to everyone.

circuitpython_nau7802's People

Contributors

cedargrovestudios avatar dhalbert avatar johnhind avatar kattni avatar semininja avatar tekktrik avatar the-compiler avatar veleek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

circuitpython_nau7802's Issues

I2C error using Python 3.11.2

I keep getting the following error using the NAU7802 with this library on RPi 5 and Python 3.11.2. This error occurs on killing the simple test in the examples directory. When I extend this code for my own application the same error occurs each time the __pu_cycle_ready bits are read during a call to nau7803.available.

Traceback (most recent call last):
  File "/home/pi/Documents/unfinished arch/nau_test.py", line 66, in <module>
    value = read_raw_value()
            ^^^^^^^^^^^^^^^^
  File "/home/pi/Documents/unfinished arch/nau_test.py", line 39, in read_raw_value
    while not nau7802.available():
              ^^^^^^^^^^^^^^^^^^^
  File "/home/pi/Documents/unfinished arch/lib/python3.11/site-packages/cedargrove_nau7802.py", line 297, in available
    return self._pu_cycle_ready
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/Documents/unfinished arch/lib/python3.11/site-packages/adafruit_register/i2c_bit.py", line 59, in __get__
    i2c.write_then_readinto(self.buffer, self.buffer, out_end=1, in_start=1)
  File "/home/pi/Documents/unfinished arch/lib/python3.11/site-packages/adafruit_bus_device/i2c_device.py", line 140, in write_then_readinto
    self.i2c.writeto_then_readfrom(
  File "/home/pi/Documents/unfinished arch/lib/python3.11/site-packages/busio.py", line 224, in writeto_then_readfrom
    return self._i2c.writeto_then_readfrom(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/Documents/unfinished arch/lib/python3.11/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 98, in writeto_then_readfrom
    readin = self._i2c_bus.read_i2c_block_data(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/Documents/unfinished arch/lib/python3.11/site-packages/Adafruit_PureIO/smbus.py", line 264, in read_i2c_block_data
    ioctl(self._device.fileno(), I2C_RDWR, request)
KeyboardInterrupt

Revamp API

Instead of passing integers, which are then looked up as constants with a particular name, it would be better to pass in the actual constants, and type-check them as necessary.

๐Ÿงน

@kattni will need CI/PyPI and all that good stuff - just a reminder so i can eject from my brain

Blocking delays during initialization

There are a number of places in this library that use time.sleep(...) during various initialization steps. Since these are blocking they prevent any additional work, so for example if you want to initialize 10 of these devices from a single controller, you will need to wait 7.5 seconds in total.

It would be relatively easy to implement an async version that depends on asyncio which would allow non-blocking sleep configuration. I don't know if there's a nice way to do this to avoid adding the async dependency for people not using it. Is it best to just create a separate library?

poll rate example

Would someone please write an example that changes the poll rate to a higher speed? I'm having trouble making it work. The only thing that has worked for me is to change the default in my local copy of cedargrove_nau7802.py.
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.