{"id":13802507,"url":"https://github.com/robert-hh/hx711","last_synced_at":"2025-05-13T13:31:33.312Z","repository":{"id":40609666,"uuid":"135819677","full_name":"robert-hh/hx711","owner":"robert-hh","description":"MicroPython driver for the HX711 load cell interface.","archived":false,"fork":true,"pushed_at":"2024-09-08T08:36:34.000Z","size":41,"stargazers_count":47,"open_issues_count":1,"forks_count":8,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-09-08T09:47:05.765Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"geda/hx711-lopy","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robert-hh.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}},"created_at":"2018-06-02T13:24:26.000Z","updated_at":"2024-09-08T08:36:37.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/robert-hh/hx711","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robert-hh%2Fhx711","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robert-hh%2Fhx711/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robert-hh%2Fhx711/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robert-hh%2Fhx711/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robert-hh","download_url":"https://codeload.github.com/robert-hh/hx711/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225218079,"owners_count":17439713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-04T00:01:46.070Z","updated_at":"2025-05-13T13:31:33.304Z","avatar_url":"https://github.com/robert-hh.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["Sensors"],"readme":"# HX711: Python class for the HX711 load cell\n\nThis is a very short and simple class. This lib includes three variants of the\nmodule. One is using direct GPIO pin handling, the other uses the PIO\nmodule of the RPI Pico. The third variant uses SPI.\nBesides the class instantiation, all variants offer the same methods.\nThe preferred variants are GPIO and PIO, because they deal properly with the conversion\nready signal resulting in a more precise result.\n\n## Constructor\n\n### hx711 = HX711(clock_pin, data_pin, gain=128)\n\nThis is the GPIO constructor. data_pin and clock_pin are the pin objects\nof the GPIO pins used for the communication. clock_pin must not be an input-only pin.\ngain is the setting of gain and channel of the load cell amplifier.\nThe default value of 128 also selects channel A.\n\n### hx711 = HX711(clock_pin, data_pin, gain=128, state_machine=0)\n\nThis is the Raspberry Pi PIO constructor. data_pin and clock_pin are the pin objects\nof the GPIO pins used for the communication. \ngain is the setting of gain and channel of the load cell amplifier.\nThe default value of 128 also selects channel A.\nThe argument state_machine has to be set to different values if more than one\nHX711 device is used by an application.\n\n### hx711 = HX711(clock_pin, data_pin, spi, gain=128)\n\nThis is the SPI constructor. data_pin is the SPI MISO, clock_pin the SPI MOSI. These must be\nPin objects, with data_pin defined for input, clock_pin defined as output. They must be supplied\nin addition to the spi object, even if spi uses the same  pins for miso and mosi.\nspi is the SPI object. The spi clock signal will not be be used.\ngain is the setting of gain and channel of the load cell amplifier.\nThe default value of 128 also selects channel A.\n\n## Methods\n\n### hx711.set_gain(gain)\n\nSets the gain and channel configuration which is used for the next call of hx711.read()\n\n|Gain|Channel|\n|:-:|:-:|\n|128|A|\n|64|A|\n|32|B|\n\n### result = hx711.read()\n\nReturns the actual raw value of the load cell. Raw means: not scaled, no offset\ncompensation.\n\n### result = hx711.read_average(times=3)\n\nReturns the raw value of the load cell as the average of times readings of The\nraw value.\n\n### result = hx711.read_lowpass()\n\nReturns the actual value of the load cell fed through an one stage IIR lowpass\nfilter. The properties of the filter can be set with set_time_constant().\n\n### rh = hx711.set_time_constant(value=None)\n\nSet the time constant used by hx711.read_lowpass(). The range is 0-1.0. Smaller\nvalues means longer times to settle and better smoothing.\nIf value is None, the actual value of the time constant is returned.\n\n### value = hx711.get_value()\n\nReturns the difference of the filtered load cell value and the offset, as set by hx711.set_offset() or hx711.tare()\n\n### units = hx711.get_units()\n\nReturns the value delivered by hx711.get_value() divided by the scale set by\nhx711.set_scale().\n\n### hx711.tare(times=15)\n\nDetermine the tare value of the load cell by averaging times raw readings.\n\n### hx711.power_down()\n\nSet the load cell to sleep mode.\n\n### hx711.power_up()\n\nSwitch the load cell on again.\n\n## Examples\n\n```\n# Example for Pycom device, gpio mode\n# Connections:\n# Pin # | HX711\n# ------|-----------\n# P9    | data_pin\n# P10   | clock_pin\n#\n\nfrom hx711_gpio import HX711\nfrom machine import Pin\n\npin_OUT = Pin(\"P9\", Pin.IN, pull=Pin.PULL_DOWN)\npin_SCK = Pin(\"P10\", Pin.OUT)\n\nhx711 = HX711(pin_SCK, pin_OUT)\n\nhx711.tare()\nvalue = hx711.read()\nvalue = hx711.get_value()\n```\n\n```\n# Example for micropython.org device, gpio mode\n# Connections:\n# Pin # | HX711\n# ------|-----------\n# 12    | data_pin\n# 13    | clock_pin\n#\n\nfrom hx711_gpio import HX711\nfrom machine import Pin\n\npin_OUT = Pin(12, Pin.IN, pull=Pin.PULL_DOWN)\npin_SCK = Pin(13, Pin.OUT)\n\nhx711 = HX711(pin_SCK, pin_OUT)\n\nhx711.tare()\nvalue = hx711.read()\nvalue = hx711.get_value()\n```\n\n```\n# Example for micropython.org device, RP2040 PIO mode\n# Connections:\n# Pin # | HX711\n# ------|-----------\n# 12    | data_pin\n# 13    | clock_pin\n#\n\nfrom hx711_pio import HX711\nfrom machine import Pin\n\npin_OUT = Pin(12, Pin.IN, pull=Pin.PULL_DOWN)\npin_SCK = Pin(13, Pin.OUT)\n\nhx711 = HX711(pin_SCK, pin_OUT, state_machine=0)\n\nhx711.tare()\nvalue = hx711.read()\nvalue = hx711.get_value()\n```\n\n```\n# Example for Pycom device, spi mode\n# Connections:\n# Pin # | HX711\n# ------|-----------\n# P9    | data_pin\n# P10   | clock_pin\n# None  | spi clock\n#\n\nfrom hx711_spi import HX711\nfrom machine import Pin, SPI\n\npin_OUT = Pin(\"P9\", Pin.IN, pull=Pin.PULL_DOWN)\npin_SCK = Pin(\"P10\", Pin.OUT)\n\nspi = SPI(0, mode=SPI.MASTER, baudrate=1000000, polarity=0,\n             phase=0, pins=(None, pin_SCK, pin_OUT))\n\nhx = HX711(pin_SCK, pin_OUT, spi)\n\nhx711.tare()\nvalue = hx711.read()\nvalue = hx711.get_value()\n```\n\n```\n# Example for micropython.org device, spi mode\n# Connections:\n# Pin # | HX711\n# ------|-----------\n# 12    | data_pin\n# 13    | clock_pin\n# 14    | spi clock\n\nfrom hx711_spi import HX711\nfrom machine import Pin\n\npin_OUT = Pin(12, Pin.IN, pull=Pin.PULL_DOWN)\npin_SCK = Pin(13, Pin.OUT)\nspi_SCK = Pin(14)\n\nspi = SPI(1, baudrate=1000000, polarity=0,\n          phase=0, sck=spi_SCK, mosi=pin_SCK, miso=pin_OUT)\n\nhx = HX711(pin_SCK, pin_OUT, spi)\n\nhx711.tare()\nvalue = hx711.read()\nvalue = hx711.get_value()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobert-hh%2Fhx711","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobert-hh%2Fhx711","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobert-hh%2Fhx711/lists"}