『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
123
返回列表 发新帖
楼主: polisher

[硬件DIY] 智能喂鱼器植入HA

[复制链接]

0

主题

14

帖子

402

积分

中级会员

Rank: 3Rank: 3

积分
402
金钱
388
HASS币
0
发表于 2024-5-24 13:29:20 | 显示全部楼层
刷写后 配网连接喂鱼器 Ap提示“接入点暂时满载”如何解决?或哪位有备份原机固件。我这直接刷到0x0 忘备份了。 使用工具为乐鑫的官网工具 flash_download_tool_3.9.6 与esptool-win64>esptool.exe,esphome的 web.esphome.io都尝试过刷写,都是卡在配网这一块。
ESPHome-Flasher-1.4.0-Windows-x64  这个只能查看日志跑码 但无法刷写,提示权限拒绝。
回复

使用道具 举报

0

主题

14

帖子

402

积分

中级会员

Rank: 3Rank: 3

积分
402
金钱
388
HASS币
0
发表于 2024-6-5 22:15:36 | 显示全部楼层
ewintec 发表于 2024-5-24 13:29
刷写后 配网连接喂鱼器 Ap提示“接入点暂时满载”如何解决?或哪位有备份原机固件。我这直接刷到0x0 忘备份 ...

找到原机固件 刷回原版了。
回复

使用道具 举报

0

主题

8

帖子

108

积分

注册会员

Rank: 2

积分
108
金钱
100
HASS币
0
发表于 2024-9-28 12:27:27 | 显示全部楼层
大神你好,可以代刷吗
回复

使用道具 举报

8

主题

166

帖子

2182

积分

金牌会员

Rank: 6Rank: 6

积分
2182
金钱
2016
HASS币
0
发表于 2024-11-30 00:27:11 | 显示全部楼层
z00000000 发表于 2024-5-14 11:36
如图,不知道是啥芯片。

BL2028N的模块,希望esphome后续能加入这个模块的支持,像bk7231系列都已经支持了。
回复

使用道具 举报

4

主题

162

帖子

1870

积分

论坛DIY达人

积分
1870
金钱
1703
HASS币
20
发表于 2024-12-2 21:47:34 | 显示全部楼层
同款喂鱼器,应该是最早那个版本,不知道官方那边出了什么问题,现在已经不能连接上了。
回复

使用道具 举报

8

主题

166

帖子

2182

积分

金牌会员

Rank: 6Rank: 6

积分
2182
金钱
2016
HASS币
0
发表于 2024-12-11 16:52:10 | 显示全部楼层
z00000000 发表于 2024-5-14 11:36
如图,不知道是啥芯片。

这个bl2028n我查了资料,其实就是bk7231n系列芯片,严格来讲是bk7231m,隶属bk7231n,esphome也是支持的,只是刷机方法不同。
回复

使用道具 举报

1

主题

28

帖子

166

积分

注册会员

Rank: 2

积分
166
金钱
138
HASS币
0
发表于 2024-12-13 15:52:15 | 显示全部楼层
我也买了一个,望眼欲穿,不知道怎么接入
回复

使用道具 举报

0

主题

3

帖子

26

积分

新手上路

Rank: 1

积分
26
金钱
23
HASS币
0
发表于 2025-1-3 15:46:10 | 显示全部楼层
感谢,买回来就想这样弄了,苦于没技术,昨天折腾一天搞掂,顺便改了下代码,加入蓝牙网关功能,缺料改为喂食完检查。
esphome:
  name: fish-feeder
  friendly_name: 智能喂鱼器
  comment: 包含蓝牙网关功能的智能喂鱼器

# 定义ESP32的基本硬件信息
esp32:
  board: esp32-c3-devkitm-1  # 使用ESP32-C3开发板
  framework:
    type: arduino  # 使用Arduino框架

# 启用日志功能,用于调试和记录信息
logger:

# 启用蓝牙扫描功能
esp32_ble_tracker:

# 启用蓝牙网关功能,将蓝牙数据中继到Home Assistant
bluetooth_proxy:

# 启用Home Assistant API,用于与Home Assistant通信
api:
  encryption:
    key: "85WJ9FhrcX1PhoSMW/ARpg7oWLBjJ6ecZSOTKHf8M7k="

# 启用OTA功能,支持远程固件更新
ota:
  platform: esphome
  password: "c7482694d7b07b649f1754af82cc73c9"

# Wi-Fi配置
wifi:
  ssid: !secret wifi_ssid # Wi-Fi网络名称
  password: !secret wifi_password # Wi-Fi密码

  # 当Wi-Fi连接失败时启用备用热点模式
  ap:
    ssid: "Fish-Feeder"
    password: "1234567890"

# 启用ESPHome的捕获门户功能,便于设备配置
captive_portal:

# 定义全局变量
globals:
   - id: auto_feeding  # 自动喂食开关
     type: bool
     restore_value: yes  # 设备重启后恢复上次状态
     initial_value: "false"
   - id: feeding_interval  # 自动喂食间隔时间(小时)
     type: int
     restore_value: yes
     initial_value: "8"
   - id: last_feeding  # 距离上次喂食的时间(分钟)
     type: int
     restore_value: no
     initial_value: "0"

# 定义硬件引脚的别名,便于代码管理
substitutions:
  device_name: Fish Feeder
  Stroke_Switch: GPIO8  # 行程开关
  Manual_button: GPIO9  # 手动按钮
  Red_led: GPIO19  # 红色指示灯
  Blue_led: GPIO18  # 蓝色指示灯
  Infrared_LED: GPIO2  # 红外发射管
  Phototransistor: GPIO3  # 红外接收管
  Forward: GPIO6  # 出料盘前进
  Reversed: GPIO7  # 出料盘后退

# 定义故障指示灯
status_led:
  pin: $Red_led

# 定义二进制传感器
binary_sensor:
  # 系统运行状态指示
  - platform: status
    id: binary_status
    internal: false 
    on_press:
      - switch.turn_on: blue_led  # 系统运行时开启蓝灯
    on_release: 
      - switch.turn_off: blue_led  # 系统停止时关闭蓝灯
  # 行程开关检测
  - platform: gpio
    pin: 
      number: GPIO8
    internal: false
    id: stroke_switch  
    on_press:
      then:
        - delay: 800ms  # 延迟800毫秒避免抖动
        - switch.turn_off: ina_switch  # 关闭马达
        - lambda: id(last_feeding) = 0;  # 重置喂食计时
        - if:
            condition: 
              lambda: 'return id(auto_feeding);'  # 检测自动喂食是否开启
            then:
              - lambda:
                  id(text_feeding_time).publish_state(
                    "下次还剩" + to_string((id(feeding_interval) * 60 - id(last_feeding)) / 60) + "时" + 
                    to_string((id(feeding_interval) * 60 - id(last_feeding)) % 60) + "分"
                  );     
            else:
              - lambda:                   
                  id(text_feeding_time).publish_state(
                    "上次已过" + to_string(id(last_feeding) / 60) + "时" + 
                    to_string(id(last_feeding) % 60) + "分"
                  );
  # 手动喂食按钮
  - platform: gpio
    pin: GPIO9
    id: sw_buttion
    internal: false
    filters:
      - delayed_on: 10ms  # 按钮去抖动
    on_press:
      then:
        - switch.toggle: ina_switch  # 切换马达状态
  # 红外接收器检测
  - platform: gpio
    pin: $Phototransistor
    id: phototransistor     
    internal: false

# 定义文本传感器
text_sensor:
  # 缺料状态
  - platform: template
    name: "Missing Feed"
    update_interval: never
    id: missing_feed
    entity_category: DIAGNOSTIC
  # 喂食时间信息
  - platform: template
    name: "Feeding time"
    icon: mdi:message
    update_interval: never
    id: text_feeding_time
    entity_category: DIAGNOSTIC

# 定义开关
switch:
  # 蓝色指示灯
  - platform: gpio
    pin: GPIO18    
    id: blue_led
    internal: false
  # 马达驱动器
  - platform: gpio
    pin: GPIO7
    id: ina_switch        
    internal: false 
  # 红外发射管
  - platform: gpio
    pin: $Infrared_LED    
    id: infrared_led
    internal: false      
  # 自动喂食开关
  - platform: template
    name: "Auto Feeding"
    icon: mdi:format-list-checks
    entity_category: config
    lambda: |-
        return id(auto_feeding);
    turn_on_action:
      - lambda: id(auto_feeding) = true;
    turn_off_action:
      - lambda: id(auto_feeding) = false;

# 定义按钮
button:
  - platform: template
    name: "Feeding"
    id: btn_feeding
    on_press:
      - switch.turn_on: ina_switch  # 开始喂食
      - delay: 20s  # 喂食持续20秒
      - switch.turn_off: ina_switch  # 喂食结束,停止喂食
      - switch.turn_on: infrared_led  # 开始检查是否缺料
      - delay: 100ms  # 延迟100毫秒
      - if:
          condition: 
            lambda: 'return id(phototransistor).state;'  # 检测是否缺料
          then:
            - text_sensor.template.publish:
                id: missing_feed
                state: "缺料"
          else:
            - text_sensor.template.publish:
                id: missing_feed
                state: "不缺料"
      - switch.turn_off: infrared_led  # 关闭红外检查

# 定义选择器
select:
  - platform: template
    name: "Feeding Interval select"
    id: select_Feeding_Interval
    optimistic: true
    restore_value: True
    entity_category: config      
    options:
      - 1 小时
      - 2 小时
      - 4 小时
      - 6 小时
      - 8 小时
      - 12 小时
      - 24 小时
      - 48 小时      
    initial_option: 8 小时
    on_value:
      then:
        - lambda: |-
            switch(i)
            {
              case 0: id(feeding_interval) = 1; break;
              case 1: id(feeding_interval) = 2; break;
              case 2: id(feeding_interval) = 4; break;
              case 3: id(feeding_interval) = 6; break;
              case 4: id(feeding_interval) = 8; break;
              case 5: id(feeding_interval) = 12; break;
              case 6: id(feeding_interval) = 24; break;
              case 7: id(feeding_interval) = 48; break;
            }

# 定义定时器
interval:
  # 每1分钟更新喂食状态
  - interval: 1min
    then:
      - if:
          condition: 
            lambda: 'return id(auto_feeding);'
          then:
            - if:
                condition:
                  lambda: 'return id(last_feeding) >= (id(feeding_interval) * 60);'
                then:
                  - switch.turn_on: ina_switch
            - lambda:
                id(text_feeding_time).publish_state(
                  "下次还剩" + to_string((id(feeding_interval) * 60 - id(last_feeding)) / 60) + "时" + 
                  to_string((id(feeding_interval) * 60 - id(last_feeding)) % 60) + "分"
                );
          else:
            - lambda:                  
                id(text_feeding_time).publish_state(
                  "上次已过" + to_string(id(last_feeding) / 60) + "时" + 
                  to_string(id(last_feeding) % 60) + "分"
                );
      - lambda: id(last_feeding) = id(last_feeding) + 1;
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2025-2-3 03:49 , Processed in 0.056503 second(s), 28 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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