Open utdrmac opened 1 year ago
Oof, looks like I added type hints without double-checking and re-testing the PIO lib back in the day. 🤦
I should be able to get this changed, tested, and committed to the repo within the next 24 hours or so.
Although the constructor's type hints are incorrect (whoops), I did just run a test that worked fine as long as the board's Pin
objects themselves are just passed through without using DigitalInOut
at all, as in the PIO-mode example:
Give that a shot and let me know how it goes. I tested on a PicoW running the latest stable CircuitPython release (8.0.5) using board.GP18
and board.GP19
. Give that a shot and let me know if it works out.
Those type hints definitely need fixing though, so I'll be getting that addressed ASAP.
Hey @fivesixzero I finally got a chance to test this and switching my code as follows results in all 0 for data:
**
** GPIO
from hx711.hx711_gpio import HX711_GPIO
# HX711 Setup
gpio_data = digitalio.DigitalInOut(board.GP19)
gpio_clk = digitalio.DigitalInOut(board.GP18)
# Initialize the HX711 ADC
# Don't tare on startup as the offset and scalar values are already calibrated
hx = HX711_GPIO(gpio_data, gpio_clk, tare=False, offset=-155118, scalar=8949.0)
**
** PIO
from hx711.hx711_pio import HX711_PIO
# HX711 Setup
gpio_data = board.GP19
gpio_clk = board.GP18
# Initialize the HX711 ADC
# Don't tare on startup as the offset and scalar values are already calibrated
hx = HX711_PIO(gpio_data, gpio_clk, tare=False, offset=-155118, scalar=8949.0)
Both are used as such:
# Take 20 ADC readings, which are averaged
reading = hx.read(20)
reading_raw = hx.read_raw()
Both variables are then pushed to mqtt into influxdb. The GPIO version gives values whereas the PIO version gives 0s for both.
Per suggestions in #4, I'm trying to use the PIO version with my PicoW:
Error when running:
The constructor for HX711_PIO wants a DigitalInOut but rp2pio.StateMachine wants a
Pin
(https://docs.circuitpython.org/en/latest/shared-bindings/rp2pio/index.html)