robert-hh / hx711

MicroPython driver for the HX711 load cell interface.
MIT License
48 stars 8 forks source link

I cant manually install library to Thonny ide (micropython for raspberry pi pico) #4

Open ChrisAkr1v opened 3 months ago

ChrisAkr1v commented 3 months ago

Downoad as zip folder the files and try install to thonny (tools->manage packages->install from local file) but i cant. Whats my wrong?

install install C:/Users/Chris_EL/Desktop/hx711-master.zip Preparing working environment ... Collecting pip==22.2.2 Downloading pip-22.2.2-py3-none-any.whl (2.0 MB) ---------------------------------------- 2.0/2.0 MB 1.5 MB/s eta 0:00:00 Collecting setuptools==65.4.1 Downloading setuptools-65.4.1-py3-none-any.whl (1.2 MB) ---------------------------------------- 1.2/1.2 MB 2.0 MB/s eta 0:00:00 Collecting wheel==0.38.4 Downloading wheel-0.38.4-py3-none-any.whl (36 kB) Installing collected packages: wheel, setuptools, pip Attempting uninstall: setuptools Found existing installation: setuptools 65.5.0 Uninstalling setuptools-65.5.0: Successfully uninstalled setuptools-65.5.0 Attempting uninstall: pip Found existing installation: pip 23.0.1 Uninstalling pip-23.0.1: Successfully uninstalled pip-23.0.1 Successfully installed pip-22.2.2 setuptools-65.4.1 wheel-0.38.4 Looking in indexes: http://127.0.0.1:36628 Processing c:\users\chris_el\desktop\hx711-master.zip ERROR: file:///C:/Users/Chris_EL/Desktop/hx711-master.zip does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found. Error Command '['C:\Users\Chris_EL\AppData\Local\pipkin\cache\workspaces\1c7bfecf12769f9897e393af77815ec0\Scripts\python.exe', '-I', '-m', 'pip', '--no-color', '--disable-pip-version-check', '--trusted-host', '127.0.0.1', 'install', '--no-compile', '--use-pep517', '--upgrade-strategy', 'only-if-needed', 'install', 'C:/Users/Chris_EL/Desktop/hx711-master.zip', '--index-url', 'http://127.0.0.1:36628']' returned non-zero exit status 1.

jetsup commented 3 months ago

Hey @ChrisAkr1v, there is no compilation or installation required to be done for this library. Just copy the file you want from your extracted zip into the board and call it from your script.

from machine import SoftSPI, Pin, SoftI2C
from hx711_spi import HX711
from hx711 import M_HX711

From the above snippet, I am using the it in SPI mode. Copied here

ChrisAkr1v commented 3 months ago

Hey @jetsup, thanks for your respone. Try your code from link, connect hx711 with load cell and raspberry but the print (print("Weight: " + str(reading)) is 0.0. Looks like no input signal (i use 4 res 1k (3 1k and 1 pot 1k) like load cell and set the dif voltage 0.7V). Also to the conf.py set the pins in and out. ||HX711_SCK_PIN = Pin(12, Pin.OUT) HX711_OUT_PIN = Pin(13, Pin.IN, Pin.PULL_DOWN)||. Maybe can you help me again?

robert-hh commented 3 months ago

Better use the GPIO or PIO variant of the HX711 driver, as they have recent updates to avoid spurious wrong readings.

Also, a dif voltage of 0.7 V is way too high. The gain of the HX711 is 32 (B-Channel), 64 or 128 (A-Channel), the maximum internal output of the hx711 is ++/- 1.5V. So the maximum in put voltages are ~45mV at the B-Channel and 23mV resp 12 mV at the A channel. If you have to deal with diff voltages in the range of 0.7V, look at the CS1237 amplifier/ADC, which can run at a gin of 1 and 2. Or use a generic ADC like the ADS1115.

ChrisAkr1v commented 3 months ago

@robert-hh set the dif voltage 35mv and use channel B. Also download again the files of HX711 driver and try to run the example with gpio. I have problem too. Screenshot_1

Maybe exist documentation for this driver in order to take a deep look because i am new dev in micropython and raspberry.

robert-hh commented 3 months ago

Did you care that Pin(12) and Pin(13) are GPIO12 and GPIO13, not the board pins 12 and 13? The documentation exists at the Github site https://github.com/robert-hh/hx711

robert-hh commented 3 months ago

The error message is raised if the driver does not detect a "conversion done" pulse in a time window of 500ms.

robert-hh commented 3 months ago

Edit: I just noticed that your code does not use channel B. You have to set the gain to 32 to use channel B. That can be done in the constructor. Still there should be conversion pulses.