From 1a7851a0f780ac1aea768039df4349ed99e038f1 Mon Sep 17 00:00:00 2001 From: John Dillenburg Date: Sat, 1 Mar 2025 15:18:43 -0600 Subject: [PATCH] For some reason, you must reference the master branch even though this is stored in main --- components/tfmini/README.md | 109 ++++++++++++++++++++++++++++++------ garage-door-controller.yaml | 2 +- 2 files changed, 94 insertions(+), 17 deletions(-) diff --git a/components/tfmini/README.md b/components/tfmini/README.md index 378e171..3ee52f1 100644 --- a/components/tfmini/README.md +++ b/components/tfmini/README.md @@ -1,6 +1,14 @@ # TFMini-S Time of Flight Distance Sensor for ESPHome -This is an external component for ESPHome that supports the TFMini-S time of flight distance sensor. +This is an external component for ESPHome that supports the TFMini-S time of flight distance sensor. It provides distance measurements along with signal strength and temperature readings from the sensor. + +## Features + +- Distance measurement in centimeters or meters (configurable) +- Signal strength monitoring for reliability assessment +- Internal temperature monitoring +- Automatic configuration of the TFMini-S sensor +- Configurable at 100Hz refresh rate ## Installation @@ -10,49 +18,118 @@ You can install this component in two ways: ```yaml external_components: - - source: github://your-username/esphome-tfmini@main + - source: github://jdillenburg/esphome@master components: [ tfmini ] ``` ### 2. Manual installation -Clone this repository into your ESPHome `custom_components` directory: +Clone this repository into your ESPHome external components directory: ```bash -cd /custom_components -git clone https://github.com/your-username/esphome-tfmini.git +cd /esphome/external_components +git clone https://github.com/jdillenburg/esphome.git +``` + +Or copy the component files directly: + +```bash +mkdir -p /esphome/components/tfmini +cd /esphome/components/tfmini +wget https://raw.githubusercontent.com/jdillenburg/esphome/main/components/tfmini/__init__.py +wget https://raw.githubusercontent.com/jdillenburg/esphome/main/components/tfmini/sensor.py +wget https://raw.githubusercontent.com/jdillenburg/esphome/main/components/tfmini/tfmini.cpp +wget https://raw.githubusercontent.com/jdillenburg/esphome/main/components/tfmini/tfmini.h +``` + +Then reference it in your configuration: + +```yaml +external_components: + - source: /esphome/components + components: [ tfmini ] ``` ## Configuration Add the following to your ESPHome configuration file: +### Basic Configuration + ```yaml -# Example configuration +# UART configuration for the TFMini-S uart: tx_pin: GPIO17 rx_pin: GPIO16 baud_rate: 115200 +# TFMini-S sensor configuration sensor: - platform: tfmini - name: "Distance Sensor" - update_interval: 1s + name: "Distance" + id: tfmini_distance ``` -## Features +### Full Configuration with All Options -- Measures distance in meters -- Automatic configuration of the TFMini-S sensor -- Signal strength validation -- Temperature monitoring (internal, not exposed yet) +```yaml +# UART configuration for the TFMini-S +uart: + tx_pin: GPIO17 + rx_pin: GPIO16 + baud_rate: 115200 -## Notes +# TFMini-S sensor configuration with all sensors +sensor: + - platform: tfmini + name: "Distance" + id: tfmini_distance + distance_unit: cm # Options: cm (default) or m + strength: + name: "TFMini Signal Strength" + id: tfmini_strength + temperature: + name: "TFMini Temperature" + id: tfmini_temperature +``` + +## Configuration Options + +| Option | Default | Description | +|--------|---------|-------------| +| `name` | Required | Name of the distance sensor | +| `distance_unit` | `cm` | Unit for distance measurement. Options: `cm` or `m` | +| `strength` | Optional | Configuration for signal strength sensor | +| `temperature` | Optional | Configuration for temperature sensor | + +## Technical Notes - The sensor is configured to use the standard 9-byte output format - Refresh rate is set to 100Hz -- Data is provided in meters with 2 decimal precision +- The component validates signal strength to ensure reliable readings (minimum 100) +- Default unit is centimeters as that's the native output of the TFMini-S + +## Wiring + +Connect your TFMini-S to your ESP device as follows: + +| TFMini-S | ESP | +|----------|-----| +| 5V | 5V | +| GND | GND | +| TX | RX (GPIO16 in example) | +| RX | TX (GPIO17 in example) | + +## Troubleshooting + +If you're having issues: + +1. Check the wiring connections +2. Ensure the UART pins are correctly defined +3. Set the logger to DEBUG level to see detailed messages +4. Verify the sensor has a clear line of sight to the target +5. Check signal strength values to ensure reliable readings ## License -This component is licensed under the MIT License. \ No newline at end of file +This component is licensed under the MIT License. diff --git a/garage-door-controller.yaml b/garage-door-controller.yaml index e3a38f1..bb47843 100644 --- a/garage-door-controller.yaml +++ b/garage-door-controller.yaml @@ -7,7 +7,7 @@ packages: wifi: !include { file: packages/wifi.yaml, vars: { ssid: "garage-door-controller" }} external_components: - - source: github://jdillenburg/esphome@main + - source: github://jdillenburg/esphome@master components: [ tfmini ] substitutions: