找回密码
 立即注册

微信扫码登录

搜索
查看: 49|回复: 0

[技术探讨] 帮我看看我这个代码哪里出了问题用pwm信号控制12V的mos管

[复制链接]

61

主题

383

回帖

1941

积分

金牌会员

积分
1941
金钱
1497
HASS币
50
发表于 5 小时前 | 显示全部楼层 |阅读模式

esphome:
  name: water-control
  friendly_name: 非接触液位传感器实现自动供水系统
esp8266:
  board: nodemcuv2

logger:

# Enable Home Assistant API
api:
  encryption:
    key: "**********
ota:
  - platform: esphome
    password: "2**********
wifi:
  ssid: "*****" #你家wifi的ssid名
  password: "1**********611" #你家wifi密码
  
  ap:
    ssid: "Water-Control Fallback Hotspot"
    password: "88888888"

web_server:
  port: 80 # web端口


substitutions:
  config_version: 'v2022.01.23.001'
  #设备名称
  device_name: water control
  #如果SSID是隐藏的,设置为true


  # Enable fallback hotspot (captive portal) in case wifi connection fails
captive_portal:

########################################################################
uart:
  id: ld2410_uart
  tx_pin: GPIO1
  rx_pin: GPIO3
  baud_rate: 256000
  parity: NONE
  stop_bits: 1
ld2410:
  uart_id: ld2410_uart
  id: ld2410_comp

output:
  - platform: esp8266_pwm
    pin: GPIO2
    frequency: 2000Hz
    id: led_onboard
    inverted: True
  - platform: esp8266_pwm
    pin: D1
    frequency: 15000 Hz
    id: pwm_output
  - platform: esp8266_pwm
    pin: D2
    frequency: 15000 Hz
    id: pwm_output1
  - platform: esp8266_pwm
    pin: D3
    frequency: 15000 Hz
    id: pwm_output2
  - platform: esp8266_pwm
    pin: D8
    frequency: 15000 Hz
    id: pwm_output3
        

########################---------灯---------############################

light:
  - platform: monochromatic
    name: "LED On Board"
    output: led_onboard

########################-------传感器-------############################

binary_sensor:
  - platform: gpio      #水位传感器---低
    pin:
      number: D5
      mode: INPUT_PULLUP
      inverted: True
    id: water_low
    name: "${device_name} Low"

#----------------------------------------------------------------------#  
  - platform: gpio      #水位传感器-高
    pin:
      number: D6
      mode: INPUT_PULLUP
      inverted: true
    id: water_high
    name: "${device_name} High"
   
  - platform: ld2410
    has_target:
      name: Presence
    has_moving_target:
      name: Moving Target
    has_still_target:
      name: Still Target
    out_pin_presence_status:
      name: out pin presence status
  

number:
  - platform: ld2410
    timeout:
      name: timeout
    max_move_distance_gate:
      name: max move distance gate
    max_still_distance_gate:
      name: max still distance gate
    g0:
      move_threshold:
        name: g0 move threshold
      still_threshold:
        name: g0 still threshold
    g1:
      move_threshold:
        name: g1 move threshold
      still_threshold:
        name: g1 still threshold
    g2:
      move_threshold:
        name: g2 move threshold
      still_threshold:
        name: g2 still threshold
    g3:
      move_threshold:
        name: g3 move threshold
      still_threshold:
        name: g3 still threshold
    g4:
      move_threshold:
        name: g4 move threshold
      still_threshold:
        name: g4 still threshold
    g5:
      move_threshold:
        name: g5 move threshold
      still_threshold:
        name: g5 still threshold
    g6:
      move_threshold:
        name: g6 move threshold
      still_threshold:
        name: g6 still threshold
    g7:
      move_threshold:
        name: g7 move threshold
      still_threshold:
        name: g7 still threshold
    g8:
      move_threshold:
        name: g8 move threshold
      still_threshold:
        name: g8 still threshold  

text_sensor:
  - platform: wifi_info
    ssid:
      name: Connected SSID
      icon: "mdi:signal-variant"
    ip_address:
      name: IP Address
      icon: "mdi:ip-network"
    mac_address:
      name: Mac Address
      icon: "mdi:wifi-marker"



button:
  - platform: ld2410
    factory_reset:
      name: "factory reset"
    restart:
      name: "restart"
    query_params:
      name: query params

select:
  - platform: ld2410
    distance_resolution:
      name: "distance resolution"
    baud_rate:
      name: "baud rate"
    light_function:
      name: light function
    out_pin_level:
      name: out pin level  
   
sensor:
  - platform: dht
    pin: D7
    temperature:
      name: ${device_name} temperature
      filters:
        - filter_out: nan
        - heartbeat: 15s
        - sliding_window_moving_average:
            window_size: 2
            send_every: 2
            send_first_at: 1
        - lambda: return x * (9.0/5.0) + 32.0; # report temperature in Fahrenheit
      unit_of_measurement: "°F"
    humidity:
      name: ${device_name} humidity
      filters:
        - filter_out: nan
        - heartbeat: 15s
        - sliding_window_moving_average:
            window_size: 2
            send_every: 2
            send_first_at: 1
      accuracy_decimals: 1 # humidity gets 0 decimals by default
    model: DHT11
    update_interval: 15s
      
  - platform: ld2410
    moving_distance:
      name : Moving Distance
    still_distance:
      name: Still Distance
    moving_energy:
      name: Move Energy
    still_energy:
      name: Still Energy
    detection_distance:
      name: Detection Distance
    g0:
      move_energy:
        name: g0 move energy
      still_energy:
        name: g0 still energy
    g1:
      move_energy:
        name: g1 move energy
      still_energy:
        name: g1 still energy
    g2:
      move_energy:
        name: g2 move energy
      still_energy:
        name: g2 still energy
    g3:
      move_energy:
        name: g3 move energy
      still_energy:
        name: g3 still energy
    g4:
      move_energy:
        name: g4 move energy
      still_energy:
        name: g4 still energy
    g5:
      move_energy:
        name: g5 move energy
      still_energy:
        name: g5 still energy
    g6:
      move_energy:
        name: g6 move energy
      still_energy:
        name: g6 still energy
    g7:
      move_energy:
        name: g7 move energy
      still_energy:
        name: g7 still energy
    g8:
      move_energy:
        name: g8 move energy
      still_energy:
        name: g8 still energy

fan:
  - platform: speed
    output: pwm_output
    name: valve_switch
    icon: mdi:water-pump
  - platform: speed
    output: pwm_output1
    name: water_switch
    icon: mdi:water-pump
  - platform: speed
    output: pwm_output2
    name: Air_switch
    icon: mdi:water-pump
  - platform: speed
    output: pwm_output3
    name: Light_switch
    icon: mdi:water-pump
switch:
  - platform: ld2410
    engineering_mode:
      name: "engineering mode"


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian ( 晋ICP备17001384号-1 )

GMT+8, 2025-10-13 23:43 , Processed in 0.068565 second(s), 5 queries , MemCached On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表