The preferred method to add your own components to ESPHome is to use External Components.
If you want to make all components available use this config.
external_components:
- source:
type: git
url: https://github.com/mikelawrence/esphome-components
If you want to make specific components available use this config.
external_components:
- source:
type: git
url: https://github.com/mikelawrence/esphome-components
components: [ tfmini ]
These ToF (time of flight) range finder sensors are compact, self-contained range finders. They support both UART and I2C communication but this component only supports UART communication.
This component supports the following Benewake LiDAR Range Finder Sensors.
TFMini Plus | TFMini-S | TFLuna |
---|---|---|
# Sample configuration entry example
sensor:
- platform: tfmini
model: TFMINI_PLUS
sample_rate: 10
low_power: true
signal_strength:
id: tfmini_signal_strength
name: "Signal"
distance:
id: tfmini_distance
internal: true
name: "TFMini Distance"
accuracy_decimals: 1
signal_strength:
id: tfmini_signal_strength
name: "TFMini Signal Strength"
filters:
- throttle: 1s
- model (Required, string): The model of the Range Finder Sensor. Options are
TFMINI_PLUS
,TFMINI_S
orTF_LUNA
. - uart_id (Optional, string): Manually specify the ID of the UART Bus if you use multiple UART buses.
- sample_rate (Optional, integer): The frame rate at which the sensor will output sensor data in samples per sec. For the TFMINI_PLUS and TFMINI_S the range is 1-1000. For the TFLuna the range is 1-500. Note when low_power mode is set to true for the TFMINI_S and the TFLuna model the is significantly lower from 1-10. Default is 100.
- config_pin (Optional, Pin Schema): This pin when connected will be set high to enable UART mode. (TF_LUNA only)
- low_power (Optional, boolean): Turns on low power mode. This also requires sample_rate to be 10 or less. (TF_LUNA, TFMini-S only)
- distance (Optional): Distance in cm. For the TFMINI_PLUS and TFMINI_S the range is 10-1200cm. For the TFLuna the range is 20-800cm. A distance of 10000cm means the sensor is not receiving enough signal, most likely open air. A distance of 0cm means the sensor is saturated and there is no measurement possible. All Options from Sensor.
- signal_strength (Optional): Represents the signal strength with a range of 0-65535. The longer the measurement distance, the lower signal strength will be. The lower the reflectivity is, the lower the signal strength will be. When signal strength is less than 100 detection is unreliable and distance is set to 10000cm. When signal strength is 65535 detection is unreliable and distance is set to 0cm. All Options from Sensor.
- temperature (Optional): Internal temperature in °C. It's not clear how useful this sensor because it certainly does not measure room temperature. All Options from Sensor.
The STUSB4500 is a USB power delivery controller that supports sink up to 100 W (20V, 5A). It has Non-Volatile Memory that can be programmed with your PDO profile so when you connect to a USB-C Power Source it will immediately negotiate your power delivery contract.
STUSB4500 board from SparkFun Electronics
There are 3 PDOs that you can configure with PD1 fixed at 5V. You can vary PD1's current. If you have all three PDOs configured the STUSB4500 will try to negotiate a contract with the PDOs in the following order: PD3, PD2 and PD1. If you don't want PDO1 negotiated then set power_only_above_5v: true
.
The configuration below the STUSB4500 will try to negotiate 12V @ 3A then 9V @ 3A. If neither are available then it won't negotiate at all.
It also creates a PD State
and PD Status
Text Sensor.
# Sample configuration entry example
stusb4500:
alert_pin: GPIO8
snk_pdo_numb: 3
v_snk_pdo2: 9.00V
i_snk_pdo2: 3.00A
v_snk_pdo3: 12.00V
i_snk_pdo3: 3.00A
power_only_above_5v: true
usb_comms_capable: true
sensor:
- platform: stusb4500
pd_state:
name: "PD State"
text_sensor:
- platform: stusb4500
pd_status:
name: "PD Status"
- flash_nvm (Optional, boolean): When set to
true
the STUSB4500 NVM will be flashed with the current settings but only if different. To be on the safe side you should not leave this set totrue
. A power cycle is required to renegotiate. Default isfalse
. - default_nvm (Optional, boolean): When set to
true
the STUSB4500 NVM will be flashed with default settings but only if different. To be on the safe side you should not leave this set totrue
. A power cycle is required to renegotiate. Default isfalse
. - snk_pdo_numb (Optional, integer): Set the number of PDOs that should be negotiated. Range is 1 - 3. A value of 3 means PDO3, PDO2 and PDO1 can be negotiated. A value of 2 means PDO2 and PDO1 can be negotiated. A value of 1 means only PDO1 can be negotiated. Default is 3.
- v_snk_pdo2 (Optional, float): This is the desired PDO2 voltage. Range is 5.0 to 20.0. Default is 20.0.
- v_snk_pdo3 (Optional, float): This is the desired PDO3 voltage. Range is 5.0 to 20.0. Default is 15.0.
- i_snk_pdo1 (Optional, float): This is the desired PDO1 current. Range is 0.0 to 5.0. 5.0A is only available with 20V. For all other voltages the maximum current is 3.0A. Default is 1.5.
- i_snk_pdo2 (Optional, float): This is the desired PDO2 current. Range is 0.0 to 5.0. 5.0A is only available with 20V. For all other voltages the maximum current is 3.0A. Default is 1.5.
- i_snk_pdo3 (Optional, float): This is the desired PDO3 current. Range is 0.0 to 5.0. 5.0A is only available with 20V. For all other voltages the maximum current is 3.0A. Default is 1.0.
- shift_vbus_hl1 (Optional, percentage): This is the percentage above PDO1 voltage when the Over Voltage Lock Out occurs. Range is 1% to 15%. Default is 10%.
- shift_vbus_ll1 (Optional, percentage): This is the percentage below PDO1 voltage when the Under Voltage Lock Out occurs. Range is 1% to 15%. Default is 15%.
- shift_vbus_hl2 (Optional, percentage): This is the percentage above PDO2 voltage when the Over Voltage Lock Out occurs. Range is 1% to 15%. Default is 5%.
- shift_vbus_ll2 (Optional, percentage): This is the percentage below PDO2 voltage when the Under Voltage Lock Out occurs. Range is 1% to 15%. Default is 15%.
- shift_vbus_hl3 (Optional, percentage): This is the percentage above PDO3 voltage when the Over Voltage Lock Out occurs. Range is 1% to 15%. Default is 5%.
- shift_vbus_ll3 (Optional, percentage): This is the percentage below PDO3 voltage when the Under Voltage Lock Out occurs. Range is 1% to 15%. Default is 15%.
- vbus_disch_time_to_0v_ (Optional, time): Coefficient used to compute VBUS discharge time to 0V. Range is 84ms to 1260ms and must be a multiple of 84ms. Default is 756ms.
- vbus_disch_time_to_pdo_ (Optional, time): Coefficient used to compute VBUS discharge time when transitioning to lower PDO voltage. Range is 24ms to 360ms and must be a multiple of 24ms. Default is 288ms.
- vbus_disch_disable (Optional, boolean): When set to
true
the STUSB4500 NVM will stop discharging VBUS. Default isfalse
. - usb_comms_capable (Optional, boolean): When set to
true
the STUSB4500 will tell the connected device that USB communications are possible. Default isfalse
. - snk_uncons_power (Optional, boolean): When set to
true
the STUSB4500 will tell the connected device external power is available. Default isfalse
. - req_src_current (Optional, boolean): When set to
true
the STUSB4500 will report the source current from source instead of the sink. Default isfalse
. - power_ok_cfg (Optional, enumeration): Selects the POWER_OK pins configuration. Options are
CONFIGURATION_1
,CONFIGURATION_2
orCONFIGURATION_3
. Default isCONFIGURATION_2
. - gpio_cfg (Optional, enumeration): Selects the GPIO configuration. Options are
SW_CTRL_GPIO
,ERROR_RECOVERY
,DEBUG
orSINK_POWER
. Default isERROR_RECOVERY
. - power_only_above_5v (Optional, boolean): When set to
true
the STUSB4500 will enable VBUS only if PDO2 or PDO3 was negotiated. Whenfalse
VBUS is enabled at 5V when connected to a non-PD charger. The available current is unknown. Default isfalse
.
- pd_state (Optional): Current PD State as an integer. Range 0 to 3 where 0 is no PD negotiated. A value of 1, 2 or 3 indicates which PDO was negotiated. All Options from Sensor.
- pd_status (Optional): Easy to read PD State (e.g. "12V @ 3A" ). All Options from Sensor.
When the GPIO is configured for software control gpio_cfg: SW_CTRL_GPIO
these actions control the state of the output.
- stusb4500.turn_gpio_on Will pull the GPIO low.
- stusb4500.turn_gpio_off Will set the output to High-Z.
Example using automations...
on_value_range:
- below: 5.0
then:
- stusb4500.turn_gpio_on: pd_controller
Example in lambdas...
- lambda: |-
id(pd_controller).turn_gpio_on();
Caution
When configuring the STUSB4500 for the first time you should realize the default configuration will allow up to 20V on VBUS. Make sure your circuit can either support 20V or configure the NVM using a Power Source that will NOT produce 20V like USB 2.0 or a non-PD USB-C charger.
Using the STUSB4500 ESPHome component requires the following steps:
- Set the configuration variables to match your requirements. The sample configuration above sets PDO3 to 12V @ 3A, PDO2 to 9V @3A and PDO1 is disabled because
power_only_above_5v: true
. This means it will first try to negotiate 12V @ 3A. If unavailable then it will try 9V @ 3A. If is unavailable no PD will be negotiated. Either thepd_state
orpd_status
sensor will let you know if there is a problem. - Add
flash_nvm: true
to the configuration. You should see the following messages in your log.If you forgot to add[00:10:03][C][stusb4500:112]: STUSB4500: [00:10:03][E][stusb4500:119]: NVM has been flashed, power cycle the device to reload NVM
flash_nvm: true
to the configuration you will see an error in the log.[00:06:27][C][stusb4500:112]: STUSB4500: [00:06:27][E][stusb4500:114]: NVM does not match current settings, you must set flash_nvm: true [00:06:27][C][stusb4500:130]: PDO3 negotiated 9.00V @ 3.00A, 27.00W
- Power cycle your board. Make sure
NVM matches settings
is present in the log and that one of your PDOs was negotiated. Configuring the STUSB4500 can be a bit finicky, but keep at it.[00:00:19][C][stusb4500:112]: STUSB4500: [00:00:19][C][stusb4500:116]: NVM matches settings [00:00:19][C][stusb4500:130]: PDO3 negotiated 12.00V @ 3.00A, 36.00W
- The STUSB4500 comonent does check that the NVM is indeed different before flashing it but it is prudent to remove the
flash_nvm: true
after it is clear the STUSB4500 is working as configured.
The DFRobot C4001 (SEN0609 or SEN0610) is a millimeter-wave presence detector. The C4001 millimeter-wave presence sensor has the advantage of being able to detect both static and moving objects. It also has a relatively strong anti-interference ability, making it less susceptible to factors such as temperature changes, variations in ambient light, and environmental noise. Whether a person is sitting, sleeping, or in motion, the sensor can quickly detect their presence.
C4001 (SEN0609) 25m mmWave Presence Sensor
There are two variants:
- SEN0609 has a 100° horizontal and 40° vertical field of view, 16 meter presence detection range and 25 meter motion detection range.
- SEN0610 has a 100° horizontal and 80° vertical field of view, 8 meter presence detection range and 12 meter motion detection range.
Note
Some settings have different ranges depending on the variant used. This component treats both variants the same, so it is your responsibility to make sure your configuration sets these values appropriately.
The sensor can operate in one of two modes, Presence
and Speed and Distance
. In Presence
mode the sensor provides a singular occupancy output. The presence output once presence is detected will stay on for a period that can be configured. In Speed and Distance
mode the occupancy binary sensor indicates if a target is being tracked or not. Each time the sensor indicates presence it also outputs target distance, target speed and target energy. In Speed and Distance
mode all of these parameter update frequently. There are only two settings for this mode, micro_motion_enable switch and threshold_factor number.
The C4001 sensor maintains settings in flash. When powered on these settings are loaded from flash and made operational. To change the configuration of the sensor dial in the setting you need and hit the config_save button. This will tell the sensor to store the new settings in flash and make them operational. You only need to do this once.
More information on the C4001 (SEN0609) sensor is available here. Information on the C4001 (SEN0610) sensor is available here.
# Sample configuration entry example
dfrobot_c4001:
id: mmwave_sensor
uart_id: mmwave_uart
mode: PRESENCE
binary_sensor:
- platform: dfrobot_c4001
config_changed:
name: Config Changed
occupancy:
id: occupancy_uart
name: Occupancy via UART
button:
- platform: dfrobot_c4001
config_save:
name: Config Save
entity_category: CONFIG
number:
- platform: dfrobot_c4001
dfrobot_c4001_id: mmwave_sensor
max_range:
name: Range Max
min_range:
name: Range Min
trigger_range:
name: Range Trigger
hold_sensitivity:
name: Sensitivity Hold
trigger_sensitivity:
name: Sensitivity Trigger
on_latency:
name: Latency On
off_latency:
name: Latency Off
inhibit_time:
name: Inhibit Time
switch:
- platform: dfrobot_c4001
dfrobot_c4001_id: mmwave_sensor
led_enable:
name: Enable LED
- mode (Required, enumeration): This sets the operation mode of the sensor. Options are
PRESENCE
andSPEED_AND_DISTANCE
.
- config_save (Optional): When you click this button the current configuration will be saved. Keep in mind that these are writes to flash and there is a limited number of time you can do this before the flash wears out. All Options from Button Component.
- config_changed (Optional): When ```true`` the current sensor configuration has been changed but not saved to the sensor. All Options from Binary Sensor Component.
- occupancy (Optional): In
PRESENCE
mode this indicates presence. InSPEED_AND_DISTANCE
mode this indicates a target is being tracked. All Options from Binary Sensor Component.
- min_range (Optional): This is the minimum detection range. Default is 0.6 meters (m) with a range of 0.6 to 25.0 m. The manual recommends not changing this value. The
config_save
button must be clicked to save the sensor configuration to flash and make operational. Available only inPRESENCE
mode. All Options from Number Component. - max_range (Optional): This is the maximum detection range. Default is 6 meters (m) with a range of 0.6 to 25.0 m. The
config_save
button must be clicked to save the sensor configuration to flash and make operational. Available only inPRESENCE
mode. All Options from Number Component. - trigger_range (Optional): Sets the maximum range at which occupancy can switch to present. The range between max detection range and trigger detection range can NOT cause occupancy to switch to present. Default is 0.6 meters (m) with a range of 0.6 to 25.0 m. The
config_save
button must be clicked to save the sensor configuration to flash and make operational. Available only inPRESENCE
mode. All Options from Number Component. - hold_sensitivity (Optional): The number represents the ease in which the sensor switches to the present state when someone enters the sensing range of the sensor. Default is 7 (no units) with a range of 0 to 9, higher is more sensitive. The
config_save
button must be clicked to save the sensor configuration to flash and make operational. Available only inPRESENCE
mode. All Options from Number Component. - trigger_sensitivity (Optional): This number represents ease of continued presence detection after the sensor switched to the present state. Default is 5 (no units) with a range of 0 to 9, higher is more sensitive. The
config_save
button must be clicked to save the sensor configuration to flash and make operational. Available only inPRESENCE
mode. All Options from Number Component. - on_latency (Optional): This time value is how long presence is detected before switching to the present state. Default is 0.050 (seconds) with a range of 0.0 to 100.0. The
config_save
button must be clicked to save the sensor configuration to flash and make operational. Available only inPRESENCE
mode. All Options from Number Component. - off_latency (Optional): This time value is how long the after the sensor no longer detects presence before switching to the not present state. Default is 15 (seconds) with a range of 0 to 1500. The
config_save
button must be clicked to save the sensor configuration to flash and make operational. Available only inPRESENCE
mode. All Options from Number Component. - inhibit_time (Optional): The dead-time after switching to the not present state before presence can be detected again. Default is 1 (seconds) with a range of 0.1 to 255.0. The
config_save
button must be clicked to save the sensor configuration to flash and make operational. Available only inPRESENCE
mode. All Options from Number Component. - threshold_factor (Optional): The larger the number the larger the object and more motion is required to trigger the sensor to switch to target tracked state. Default is 5 with a range of 0 to 65535. The
config_save
button must be clicked to save the sensor configuration to flash and make operational. Available only inSPEED_AND_DISTANCE
mode. All Options from Number Component.
- target_distance (Optional): When occupancy binary sensor is
true
this sensor indicates distance to target in meters (m). When occupancy binary sensor isfalse
this sensor switches to 0.0 indicating invalid data. Available only inSPEED_AND_DISTANCE
mode. All Options from Sensor Component. - target_speed (Optional): When occupancy binary sensor is
true
this sensor indicates target speed in meters per second (m/s). When occupancy binary sensor isfalse
this sensor switches to 0.0 indicating invalid data. Available only inSPEED_AND_DISTANCE
mode. All Options from Sensor Component. - target_energy (Optional): When occupancy binary sensor is
true
this sensor indicates target energy in no units. When occupancy binary sensor isfalse
this sensor switches to 0.0 indicating invalid data. Available only inSPEED_AND_DISTANCE
mode. All Options from Sensor Component.
- led_enable (Optional): When turned on the green LED will flash when the sensor has been started. The blue LED cannot be disabled with this command. All Options from Switch Component.
- micro_motion_enable (Optional): Turns on micro motion mode. Available only in
SPEED_AND_DISTANCE
mode. All Options from Switch Component.
- dfrobot_c4001.factor_reset Will perform a factory reset of the module and all configuration values will go back to default. The module will restart with these defaults. Keep in mind that these are writes to flash and there is a limited number of time you can do this before the flash wears out. This is much easier to do with a lambda that accidentally performs a factory reset every second.
Example using automations...
button:
- platform: template
name: Factory Reset
on_press:
- dfrobot_c4001.factory_reset: mmwave_sensor
entity_category: CONFIG
Example in lambdas...
- lambda: |-
id(mmwave_sensor).factory_reset();