{"id":13802508,"url":"https://github.com/robert-hh/hx710","last_synced_at":"2025-05-13T13:31:36.310Z","repository":{"id":226059692,"uuid":"767624878","full_name":"robert-hh/hx710","owner":"robert-hh","description":"MicroPython driver for the HX710 load cell interface interface.","archived":false,"fork":false,"pushed_at":"2024-11-26T08:18:28.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-26T09:25:18.052Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-05T16:22:22.000Z","updated_at":"2024-11-26T08:18:32.000Z","dependencies_parsed_at":"2024-10-22T18:57:28.983Z","dependency_job_id":null,"html_url":"https://github.com/robert-hh/hx710","commit_stats":null,"previous_names":["robert-hh/hx710"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robert-hh%2Fhx710","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robert-hh%2Fhx710/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robert-hh%2Fhx710/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robert-hh%2Fhx710/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robert-hh","download_url":"https://codeload.github.com/robert-hh/hx710/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253950091,"owners_count":21989300,"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.104Z","updated_at":"2025-05-13T13:31:36.300Z","avatar_url":"https://github.com/robert-hh.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["Sensors"],"readme":"# HX710: Python class for the HX710 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 methods are GPIO and PIO, because they deal properly with the conversion\nready signal resulting in a more precise result.\n\n## Constructor\n\n### hx710 = HX710(clock_pin, data_pin, mode=1)\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.\nmode is the setting of the load cell amplifier.\nThe default value of 1 also selects the external sensor.\n\n### hx710 = HX710(clock_pin, data_pin, mode=1, 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.\nmode is the setting of the load cell amplifier.\nThe default value of 1 also selects the external sensor.\nThe argument state_machine has to be set to different values if more than one\nHX711 device is used by an application.\n\n### hx710 = HX710(clock_pin, data_pin, spi, mode=1)\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.\nmode is the of of the load cell amplifier.\nThe default value of 1 also selects the external sensor.\n\n## Methods\n\n### hx710.set_mode(mode)\n\nSets the mode which is used for the next call of hx710.read()\n\n|Mode|Value|\n|:-:|:-:|\n|1|External Sensor at 10 Hz|\n|2|Internal Temperature (HX710A)|\n|2|DVDD - AVDD (HB710B)|\n|3|External Sensor at 40 Hz|\n\n### result = hx710.read()\n\nReturns the actual raw value of the load cell. Raw means: not scaled, no offset\ncompensation.\n\n### result = hx710.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 = hx710.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 = hx710.set_time_constant(value=None)\n\nSet the time constant used by hx710.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 = hx710.get_value()\n\nReturns the difference of the filtered load cell value and the offset, as set by hx710.set_offset() or hx710.tare()\n\n### units = hx710.get_units()\n\nReturns the value delivered by hx710.get_value() divided by the scale set by\nhx710.set_scale().\n\n### hx710.tare(times=15)\n\nDetermine the tare value of the load cell by averaging times raw readings.\n\n### hx710.power_down()\n\nSet the load cell to sleep mode.\n\n### hx710.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 # | HX710\n# ------|-----------\n# P9    | data_pin\n# P10   | clock_pin\n#\n\nfrom hx710_gpio import HX710\nfrom machine import Pin\n\npin_OUT = Pin(\"P9\", Pin.IN, pull=Pin.PULL_DOWN)\npin_SCK = Pin(\"P10\", Pin.OUT)\n\nhx710 = HX710(pin_SCK, pin_OUT)\n\nhx710.tare()\nvalue = hx710.read()\nvalue = hx710.get_value()\n```\n\n```\n# Example for micropython.org device, gpio mode\n# Connections:\n# Pin # | HX710\n# ------|-----------\n# 12    | data_pin\n# 13    | clock_pin\n#\n\nfrom hx710_gpio import HX710\nfrom machine import Pin\n\npin_OUT = Pin(12, Pin.IN, pull=Pin.PULL_DOWN)\npin_SCK = Pin(13, Pin.OUT)\n\nhx710 = HX710(pin_SCK, pin_OUT)\n\nhx710.tare()\nvalue = hx710.read()\nvalue = hx710.get_value()\n```\n\n```\n# Example for micropython.org device, RP2040 PIO mode\n# Connections:\n# Pin # | HX710\n# ------|-----------\n# 12    | data_pin\n# 13    | clock_pin\n#\n\nfrom hx710_pio import HX710\nfrom machine import Pin\n\npin_OUT = Pin(12, Pin.IN, pull=Pin.PULL_DOWN)\npin_SCK = Pin(13, Pin.OUT)\n\nhx710 = HX710(pin_SCK, pin_OUT)\n\nhx710.tare()\nvalue = hx710.read()\nvalue = hx710.get_value()\n```\n\n```\n# Example for Pycom device, spi mode\n# Connections:\n# Pin # | HX710\n# ------|-----------\n# P9    | data_pin\n# P10   | clock_pin\n# None  | spi clock\n#\n\nfrom hx710_spi import HX710\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 = HX710(pin_SCK, pin_OUT, spi)\n\nhx710.tare()\nvalue = hx710.read()\nvalue = hx710.get_value()\n```\n\n```\n# Example for micropython.org device, spi mode\n# Connections:\n# Pin # | HX710\n# ------|-----------\n# 12    | data_pin\n# 13    | clock_pin\n# 14    | spi clock\n\nfrom hx710_spi import HX710\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 = HX710(pin_SCK, pin_OUT, spi)\n\nhx710.tare()\nvalue = hx710.read()\nvalue = hx710.get_value()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobert-hh%2Fhx710","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobert-hh%2Fhx710","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobert-hh%2Fhx710/lists"}