{"id":15197108,"url":"https://github.com/phurin-git/python-hx711","last_synced_at":"2026-03-06T12:02:07.871Z","repository":{"id":249534242,"uuid":"831768214","full_name":"phurin-git/python-hx711","owner":"phurin-git","description":"A Python library for interfacing with the HX711 load cell amplifier. Traditionally, HX711 sensors have official libraries available only in C++ for Arduino. This library aims to fill that gap by offering a Python implementation, making it compatible with platforms such as the Jetson Nano that use Python GPIO for sensor integration.","archived":false,"fork":false,"pushed_at":"2024-07-21T16:23:02.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-09T21:47:07.560Z","etag":null,"topics":["hx711","jetson-nano","raspberrypi"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phurin-git.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-21T15:17:52.000Z","updated_at":"2024-08-22T05:53:12.000Z","dependencies_parsed_at":"2024-07-21T17:16:22.433Z","dependency_job_id":"ba5f5501-029d-4947-bda1-7df288f5d038","html_url":"https://github.com/phurin-git/python-hx711","commit_stats":null,"previous_names":["phurin-git/python-hx711"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phurin-git/python-hx711","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phurin-git%2Fpython-hx711","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phurin-git%2Fpython-hx711/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phurin-git%2Fpython-hx711/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phurin-git%2Fpython-hx711/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phurin-git","download_url":"https://codeload.github.com/phurin-git/python-hx711/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phurin-git%2Fpython-hx711/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30175874,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T11:48:51.886Z","status":"ssl_error","status_checked_at":"2026-03-06T11:48:51.460Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hx711","jetson-nano","raspberrypi"],"created_at":"2024-09-28T00:42:34.596Z","updated_at":"2026-03-06T12:02:07.792Z","avatar_url":"https://github.com/phurin-git.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python HX711 Library\n\nThis repository provides a Python library for interfacing with the HX711 load cell amplifier. Traditionally, HX711 sensors have official libraries available only in C++ for Arduino. This library aims to fill that gap by offering a Python implementation, making it compatible with platforms such as the Jetson Nano that use Python GPIO for sensor integration.\n## Example\n\n```python\n# Load Cell Calibration\nfrom HX711 import HX711\nimport RPi.GPIO as GPIO\nGPIO.setmode(GPIO.BOARD)\nscale = HX711()\ncalibration_factor = 1\nrealweight = 0\ndef setup(obj):\n    global realweight\n    obj.begin(21,23) \n    obj.set_scale()\n    obj.tare()   #Reset the scale to 0  \n    zero_factor = obj.read_average() #Get a baseline reading\n    print(\"Zero factor: \" + str(zero_factor)) #This can be used to remove the need to tare the scale. Useful in permanent scale projects.\n    input(\"Did you put your object on weight scale yet?\")\n    realweight = float(input(\"Please input real weight(g).\\n\"))\n    \nsetup(scale)\nwhile(True):\n    scale.set_scale(calibration_factor) #Adjust to this calibration factor\n    weight = scale.get_units()\n    print(\"Reading: \" + str(weight) + \" g Calibrate Factor : \" + str(calibration_factor))\n    if(weight \u003c= 0):\n        weight = 0\n    if(weight \u003c (realweight - 1)):\n        calibration_factor -= 1\n    elif(weight \u003e (realweight + 1)):\n        calibration_factor  += 1\n    else:\n        break\n    if(calibration_factor \u003c= 0):\n        calibration_factor = 1\n```\n\n## Features\n1. It provides a `tare()` function, which \"resets\" the scale to 0. Many other\n   implementations calculate the tare weight when the ADC is initialized only.\n   I needed a way to be able to set the tare weight at any time.\n   **Use case**: Place an empty container on the scale, call `tare()` to reset\n   the readings to 0, fill the container and get the weight of the content.\n\n2. It provides a `power_down()` function, to put the ADC into a low power mode.\n   According to the datasheet,\n   \u003e When PD_SCK pin changes from low to high and stays at high\n   \u003e for longer than 60μs, HX711 enters power down mode.\n\n   **Use case**: Battery-powered scales. Accordingly, there is a `power_up()`\n   function to get the chip out of the low power mode.\n\n3. It has a `set_gain(byte gain)` function that allows you to set the gain factor\n   and select the channel. According to the datasheet,\n   \u003e Channel A can be programmed with a gain of 128 or 64, corresponding to\n   a full-scale differential input voltage of ±20mV or ±40mV respectively, when\n   a 5V supply is connected to AVDD analog power supply pin. Channel B has\n   a fixed gain of 32.\n\n   The same function is used to select the channel A or channel B, by passing\n   128 or 64 for channel A, or 32 for channel B as the parameter. The default\n   value is 128, which means \"channel A with a gain factor of 128\", so one can\n   simply call `set_gain()`.\n\n   This function is also called from the initializer method `begin()`.\n\n4. The `get_value()` and `get_units()` functions can receive an extra parameter \"times\",\n   and they will return the average of multiple readings instead of a single reading.\n\n\n## How to calibrate your load cell\n1. Call `set_scale()` with no parameter.\n2. Call `tare()` with no parameter.\n3. Place a known weight on the scale and call `get_units(10)`.\n4. Divide the result in step 3 to your known weight. You should\n   get about the parameter you need to pass to `set_scale()`.\n5. Adjust the parameter in step 4 until you get an accurate reading.\n\n## Credits\n\nThanks to [Weihong Guan](https://github.com/aguegu) who started the first version of this library in 2012 (see [ardulibs](https://github.com/aguegu/ardulibs/tree/master/hx711)) and [Bogdan Necula](https://github.com/bogde) (see [bodge](https://github.com/bogde/HX711)) who took over in 2014 and others who contributed to this library. Thanks for your hard work! (This python version developed by me in 2021)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphurin-git%2Fpython-hx711","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphurin-git%2Fpython-hx711","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphurin-git%2Fpython-hx711/lists"}