esphome-docs/components/sensor/hx711.rst

84 lines
2.7 KiB
ReStructuredText
Raw Normal View History

HX711 Load Cell Amplifier
=========================
2018-11-14 22:12:27 +01:00
.. seo::
2019-02-16 23:25:23 +01:00
:description: Instructions for setting up HX711 load cell amplifiers with ESPHome
:image: hx711.jpg
2018-11-14 22:12:27 +01:00
:keywords: HX711
The ``hx711`` sensor platform allows you to use your HX711
load cell amplifier
2020-05-10 21:27:59 +02:00
(`datasheet <https://www.mouser.com/ds/2/813/hx711_english-1022875.pdf>`__, `SparkFun`_) with ESPHome
.. figure:: images/hx711-full.jpg
:align: center
2020-05-10 21:27:59 +02:00
:target: `SparkFun`_
:width: 60.0%
2020-05-10 21:27:59 +02:00
HX711 Load Cell Amplifier. Image by `SparkFun`_ licensed and re-distributed under `CC BY 2.0 <https://creativecommons.org/licenses/by/2.0/>`__.
2020-05-10 21:27:59 +02:00
.. _SparkFun: https://www.sparkfun.com/products/13879
Connect ``GND`` to ``GND``, ``VCC`` to ``3.3V`` and the other three ``MISO`` (or ``SO`` for short),
``CS`` and ``CLOCK`` (or ``SCK``) to free GPIO pins.
.. code-block:: yaml
# Example configuration entry
sensor:
- platform: hx711
name: "HX711 Value"
dout_pin: D0
clk_pin: D1
gain: 128
2019-01-06 18:56:14 +01:00
update_interval: 60s
Configuration variables:
2018-10-12 16:33:22 +02:00
------------------------
- **name** (**Required**, string): The name for the load cell sensor.
- **dout_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The DOUT (or DAT) pin.
- **clk_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The CLK pin.
2019-01-06 18:56:14 +01:00
- **update_interval** (*Optional*, :ref:`config-time`): The interval to check the sensor. Defaults to ``60s``.
2018-10-20 15:10:26 +02:00
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
2019-02-17 12:28:17 +01:00
- All other options from :ref:`Sensor <config-sensor>`.
2018-11-10 14:31:27 +01:00
Converting Units
----------------
As the HX711 does not have any calibration data, you have to convert the measurement to units yourself.
To calibrate the sensor:
2019-05-12 22:44:59 +02:00
1. Place a zero load or a known mass on the sensor, for example ``0kg``
2018-11-10 14:31:27 +01:00
2. Wait for the data to arrive in the logs and write down the value. For example ``120``.
3. Place another (different) known mass on the sensor, for example ``1kg``
4. Again wait for the data to arrive and note the value, for example ``810``.
2019-05-12 22:44:59 +02:00
Once you've done those steps, you can use the ``calibrate_linear`` filter to map the incoming value
to the calibrated one:
2018-11-10 14:31:27 +01:00
.. code-block:: yaml
2018-11-10 14:31:27 +01:00
# Example configuration entry
sensor:
- platform: hx711
# ... Other HX711 options
filters:
2019-05-12 22:44:59 +02:00
- calibrate_linear:
- 120 -> 0
- 810 -> 1
2018-11-10 14:31:27 +01:00
unit_of_measurement: kg
Replace the masses and values ``120.0``, ``810.0``, etc with your values.
See Also
2018-10-12 16:33:22 +02:00
--------
- :ref:`sensor-filters`
- :doc:`adc`
2019-05-12 22:44:59 +02:00
- :apiref:`hx711/hx711.h`
2018-08-24 22:44:01 +02:00
- `HX711 Library <https://github.com/bogde/HX711>`__ by `@bogde <https://github.com/bogde>`__
- :ghedit:`Edit`