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

 找回密码
 立即注册
查看: 1545|回复: 5

[技术探讨] ESP32S3R8N16蓝牙转发

[复制链接]

15

主题

220

帖子

1761

积分

金牌会员

Rank: 6Rank: 6

积分
1761
金钱
1541
HASS币
0
发表于 2024-3-30 00:49:23 | 显示全部楼层 |阅读模式
本帖最后由 Awe7 于 2024-3-30 09:26 编辑

ESP32S3R8N16(不是合宙的开发板)实现 esphome 蓝牙转发到 Passive BLE Monitor
合宙的开发板建议参考 jjcs   https://bbs.hassbian.com/thread-19237-1-1.html

参考 https://bbs.hassbian.com/thread-19237-1-1.html
     https://github.com/custom-components/ble_monitor
     https://github.com/myhomeiot/esphome-components#ble-gateway
     https://custom-components.github.io/ble_monitor/parse_data

esphome


esphome:
  name: esp32s3
  platformio_options:
    board_build.flash_mode: dio
    board_upload.maximum_ram_size: 327680
    board_upload.maximum_size: 16777216
    board_build.partitions: "partitions.csv"
esp32:
  board: esp32-s3-devkitc-1
  flash_size: 16MB
  framework:
    type: esp-idf
# Enable logging
logger:
esp32_ble_tracker:
external_components:
  - source: github://myhomeiot/esphome-components
#  baud_rate: 0
# ESPHome
web_server:
  port: 80


ble_gateway:
  id: blegateway
  on_ble_advertise:
    then:
      homeassistant.event:
        event: esphome.on_ble_advertise
        data:
          packet: !lambda return packet;

binary_sensor:
  - platform: homeassistant
    id: ble_gateway_discovery
    entity_id: binary_sensor.ble_gateway
    attribute: discovery
    on_state:
      then:
        lambda: id(blegateway).set_discovery(x);

text_sensor:
  - platform: homeassistant
    id: ble_gateway_devices
    entity_id: binary_sensor.ble_gateway
    attribute: devices
    on_value:
      then:
        lambda: id(blegateway).set_devices(x);

switch:
  - platform: template
    id: switch_ble_gateway_discovery
    name: BLE Gateway Discovery
    icon: mdi:bluetooth-connect
    lambda: return id(blegateway).get_discovery();
    turn_on_action: [lambda: id(blegateway).set_discovery(true);]
    turn_off_action: [lambda: id(blegateway).set_discovery(false);]
    disabled_by_default: true
    entity_category: config
configuration.yaml设置在二楼

新建一个自动化,用yami编辑


alias: ESPHome BLE Advertise
description: ""
trigger:
  - platform: event
    event_type: esphome.on_ble_advertise
action:
  - service: ble_monitor.parse_data
    data:
      packet: "{{ trigger.event.data.packet }}"
mode: queued









已知问题:


编译时显示HARDWARE: ESP32S3 240MHz, 320KB RAM, 16MB Flash  


最后显示
RAM:   [==        ]  15.3% (used 50148 bytes from 327680 bytes)
Flash: [==        ]  15.6% (used 1270841 bytes from 8126464 bytes)


但还是能用。
esphome打开的 80 端口无法通过 visit进入, 需获取设备ip地址进入 web页面 手动打开 web上的 BLE Gateway Discovery开关可搜索蓝牙

  ESPHome固件 转到 自动化 转到 Passive BLE Monitor  


另 求怎么把 Passive BLE Monitor集成 暂未支持的设备接入
00:34:05[D][ble_gateway:063][D9:58:61:57:AF:29] Packet 043E250201000129AF576158D91903194002020104090302180F1804180318070948696C6D616EC9
00:34:05[D][ble_gateway:063][D9:58:61:57:AF:29] Packet 043E250201000129AF576158D91903194002020104090302180F1804180318070948696C6D616EC5


NRF52810  硬件带蜂鸣器,带按键,带双色指示灯  蓝牙5.0




回复

使用道具 举报

15

主题

220

帖子

1761

积分

金牌会员

Rank: 6Rank: 6

积分
1761
金钱
1541
HASS币
0
 楼主| 发表于 2024-3-30 00:54:17 | 显示全部楼层
本帖最后由 Awe7 于 2024-3-30 00:59 编辑

# Home Assistant
input_boolean:
  settings_ble_gateway:
    name: BLE Gateway
    icon: mdi:bluetooth
  settings_ble_gateway_discovery:
    name: BLE Gateway Discovery
    icon: mdi:bluetooth-connect

input_text:
  settings_ble_gateway_add_device:
    name: BLE Gateway Add Device
    icon: mdi:bluetooth-connect
    initial: ''

template:
  - binary_sensor:
      - name: BLE Gateway
        icon: mdi:bluetooth
        state: "{{ is_state('input_boolean.settings_ble_gateway', 'on') }}"
        attributes:
          discovery: "{{ is_state('input_boolean.settings_ble_gateway_discovery', 'on') }}"
          # devices: "{{ states | selectattr('entity_id', 'search', '^(device_tracker|sensor).ble_') | selectattr('attributes.mac address', 'defined') | map(attribute='attributes.mac address') | unique | sort | join('') | replace(':', '') ~ (states('input_text.settings_ble_gateway_add_device') | replace(':', '') | trim) if is_state('binary_sensor.ble_gateway', 'on') }}"
          # Important note: In Passive BLE Monitor version 7.8.2 and later 'attributes.mac address' was changed to 'attributes.mac_address', please update your config
          # devices: "{{ states | selectattr('entity_id', 'search', '^(device_tracker|sensor).ble_') | selectattr('attributes.mac_address', 'defined') | map(attribute='attributes.mac_address') | unique | sort | join('') | replace(':', '') ~ (states('input_text.settings_ble_gateway_add_device') | replace(':', '') | trim) if is_state('binary_sensor.ble_gateway', 'on') }}"
          # Note: In Home Assistant 2022.x, Passive BLE Monitor version 8.x and later you can use device attribute identifiers
          devices: >-
            {% set devices = namespace(items = []) %}
            {% for s in states | selectattr('entity_id', 'search', '^(device_tracker|sensor).ble_') | map(attribute='entity_id') %}
              {% set devices.items = devices.items + ([device_id(s)] if device_id(s) else []) %}
            {% endfor %}
            {% set ns = namespace(items = []) %}
            {% for s in devices.items | unique %}
              {% set ns.items = ns.items + [(device_attr(s, 'identifiers') | first)[1]] %}
            {% endfor %}
            {{ ns.items | unique | sort | join('') | replace(':', '') ~ (states('input_text.settings_ble_gateway_add_device') | replace(':', '') | trim) if is_state('binary_sensor.ble_gateway', 'on') }}

回复

使用道具 举报

15

主题

220

帖子

1761

积分

金牌会员

Rank: 6Rank: 6

积分
1761
金钱
1541
HASS币
0
 楼主| 发表于 2024-3-30 01:51:53 | 显示全部楼层

一顿瞎捣鼓能接入集成显示一个实体、ble tracker D9586157AF29 显示在家
回复

使用道具 举报

1

主题

17

帖子

98

积分

注册会员

Rank: 2

积分
98
金钱
81
HASS币
0
发表于 2024-7-7 19:40:01 | 显示全部楼层
8MB的yaml要改哪些地方呀
回复

使用道具 举报

15

主题

220

帖子

1761

积分

金牌会员

Rank: 6Rank: 6

积分
1761
金钱
1541
HASS币
0
 楼主| 发表于 2024-7-9 17:50:25 | 显示全部楼层
SOBER 发表于 2024-7-7 19:40
8MB的yaml要改哪些地方呀


  platformio_options:
    board_build.flash_mode: dio
    board_upload.maximum_ram_size: 327680
    board_upload.maximum_size: 16777216
    board_build.partitions: "partitions.csv"
esp32:
  board: esp32-s3-devkitc-1
  flash_size: 16MB
  framework:
    type: esp-idf

这些删除、用默认的ESP32S3就是8m  
回复

使用道具 举报

1

主题

17

帖子

98

积分

注册会员

Rank: 2

积分
98
金钱
81
HASS币
0
发表于 2024-7-12 16:58:39 | 显示全部楼层
Awe7 发表于 2024-7-9 17:50
platformio_options:
    board_build.flash_mode: dio
    board_upload.maximum_ram_size: 327680

我的型号是esp32-s3-wroom-1 n16r8的开发板,为什么用下面的yaml文件都不能正常启动进不去呢,跟着你的yaml写的,都没改,是有什么问题吗,我是直接usb连接到esphome网页上下载的,编译没问题,网络没问题,usb连接到esphome下载到最后会有警告,然后连不到esphome,不能完全下载成功,能连上它发出的热点,esphome显示offline。
esphome:
  name: esp32s3
  platformio_options:
    board_build.flash_mode: dio
    board_upload.maximum_ram_size: 327680
    board_upload.maximum_size: 16777216
    board_build.partitions: "partitions.csv"

esp32:
  board: esp32-s3-devkitc-1
  flash_size: 16MB
  framework:
    type: esp-idf

# Enable logging
logger:

external_components:
  - source: github://myhomeiot/esphome-components
  
#  baud_rate: 0
# ESPHome

web_server:
  port: 80

# Enable Home Assistant API
api:
  encryption:
    key: "zUtJAB+5NJvWgH0dF0EvBndW2DiRzzDbX6u4gwG4WI8="

ota:
  - platform: esphome
    password: "d4b14ca83a9d9497bb8d845ec84e251b"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32S3 Fallback Hotspot"

captive_portal:
   
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-24 13:37 , Processed in 0.053741 second(s), 28 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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