Giter VIP home page Giter VIP logo

hx711's People

Contributors

deepsourcebot avatar firebelow avatar iuliux avatar mpibpc-mroose avatar pierreretief avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hx711's Issues

Sparkfun hx711 compatibility

Description

I tried to use your library but am seemingly unable to connect to the hardware for some reason. When trying to run the example I get the following (repeatingly):

WARNING:root:setting gain and channel took more than 60µs. Time elapsed: 0.00006646

What I Did

Ran this code:

#!/usr/bin/python3
from hx711 import HX711
from RPi import GPIO
try:
    hx711 = HX711(
        dout_pin=5,
        pd_sck_pin=6,
        channel='A',
        gain=64
    )

    hx711.reset()   # Before we start, reset the HX711 (not obligate)
    measures = hx711.get_raw_data(num_measures=3)
finally:
    GPIO.cleanup()  # always do a GPIO cleanup in your scripts!

print("\n".join(measures))**

I have a sparkfun edition of the hx711. I connected the DAT pin to GPIO 5 and the CLK pin to GPIO 6. I have a raspberry pi model 3 b+. The VCC is connected to 5v pin.

Anything obvious I'm doing wrong?

Getting Dual Channels To Work

Description

Hi there. I am trying to us your library to take measurements from two load cells. I can either try to use two of the HX711 boards or just use one with Channel A & B. I am trying to do the later and only use one board with two channels. Can you let me know what I am doing wrong below. I am running the below code in it own thread outputting global measurements to the other threads. I keep getting this error:
WARNING:root:current channel != "A" so no need to set a gain current channel is 'B'
RIGHT RAW MEAN DATA: -45.19999999999982
LEFT RAW MEAN DATA: 357.59999999999854

What I Did

Here is my code:

'#!/usr/bin/python3
from future import print_function
import time
import threading
from hx711 import HX711
import RPi.GPIO as GPIO
import statistics

GPIO.setmode(GPIO.BCM)
left_calibration = 23380 # To try to calibrate each side to a TARE zero
right_calibration = 3390 # To try to calibrate each side to a TARE zero

def loadSensorBoth():
global left_pressure
global right_pressure
while True:
try:
DataPin = 5
ClockPin = 6
NumReadings = 10
print('READING HX711 LEFT')
hxleft = HX711(dout_pin=5, pd_sck_pin=6, channel="A")
print('LEFT RESET')
resultleft = hxleft.reset()
if resultleft:
print('LEFT READY TO USE')
else:
print("LEFT NOT READY")
left_pressure = ((statistics.mean(hxleft.get_raw_data(NumReadings))) - left_calibration)
if left_pressure != False:
print('LEFT RAW MEAN DATA: ' + str(left_pressure))
else:
print('LEFT INVALID DATA')
GPIO.cleanup()
print('READING HX711 RIGHT')
hxright = HX711(dout_pin=5, pd_sck_pin=6, channel="B")
print('RESET RIGHT')
resultright = hxright.reset()
if resultright:
print('RIGHT READY TO USE')
else:
print("RIGHT NOT READY")
right_pressure = ((statistics.mean(hxright.get_raw_data(NumReadings))) - right_calibration)
if right_pressure != False:
print('RIGHT RAW MEAN DATA: ' + str(right_pressure))
else:
print('RIGHT INVALID DATA')
GPIO.cleanup()
except (KeyboardInterrupt, SystemExit):
print('BYE')
finally:
GPIO.cleanup()`

Library blocks if there is no HX711 present

  • HX711 version: 1.1.2.2
  • Python version: 3.5.3
  • Operating System: Raspbian Stretch Lite June 2018

Description

The library blocks if there is no HX711 present. This seems to boil down to a couple of problems:

  1. Creating the initial HX711 object will return a valid object even if there is no HX711 connected to the pins.
  2. The reset() method blocks and does not throw an error if the _set_channel_gain() fails. It will log the warning "WARNING:root:setting gain and channel took more than 60µs" until Python itself throws a "RecursionError: maximum recursion depth exceeded in comparison"

It would be useful for the library to throw errors so that a failed HX711 (for whatever reason) can be detected and handled in some way, rather than simply crashing the application.

What I Did

I used the simple example code, but without an HX711 attached. This was to simulate a device with a connected HX711 based scale, where the scale is not plugged in to the main device.

...
WARNING:root:setting gain and channel took more than 60µs. Time elapsed: 0.0001909989950945601
WARNING:root:setting gain and channel took more than 60µs. Time elapsed: 0.00026499800151214004
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.5/logging/__init__.py", line 981, in emit
    msg = self.format(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 831, in format
    return fmt.format(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 569, in format
    if self.usesTime():
  File "/usr/lib/python3.5/logging/__init__.py", line 537, in usesTime
    return self._style.usesTime()
  File "/usr/lib/python3.5/logging/__init__.py", line 381, in usesTime
    return self._fmt.find(self.asctime_search) >= 0
RecursionError: maximum recursion depth exceeded in comparison

Library crashes Raspberry Pi

  • HX711 version:
  • Python version:
  • Operating System:
    Buster - Raspberry pi 4

Description

I am using the example. As soon as the print message "Reset HX711" is printed, the Raspberry Pi shutdown. This happens if I don't have any device connected or not.

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

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.