系統(tǒng)介紹
樹莓派5B:系統(tǒng)核心,負(fù)責(zé)設(shè)備的通信管理、狀態(tài)監(jiān)測(cè)和數(shù)據(jù)處理。
Zigbee通信:通過 Zigbee 協(xié)調(diào)器模塊進(jìn)行硬件中繼。系統(tǒng)采用 Zigbee2MQTT 框架,使 Zigbee 設(shè)備能夠通過 MQTT 協(xié)議接入樹莓派,實(shí)現(xiàn)數(shù)據(jù)的高效傳輸和控制。
BLE通信:由樹莓派5B自身支持,直接用于與 BLE 設(shè)備的連接和數(shù)據(jù)交互,方便 BLE 終端設(shè)備的接入和管理。
WiFi通信:系統(tǒng)通過 WiFi 接入家庭或辦公網(wǎng)絡(luò),終端設(shè)備連接至路由器后,樹莓派5B能通過網(wǎng)絡(luò)自動(dòng)發(fā)現(xiàn)設(shè)備,實(shí)現(xiàn)無縫的設(shè)備接入與狀態(tài)管理。
系統(tǒng)框圖
樹莓派開機(jī)系統(tǒng)配置
修改root密碼
sudo -i
passwd root password
修改SSH配置,允許密碼登錄和root登錄
sudo nano /etc/ssh/sshd_config
添加如下配置并保存
PermitRootLogin yes
PermitEmptyPasswords yes
重啟ssh服務(wù)
sudo systemctl restart ssh
修改apt源
# 編輯這個(gè)文件
sudo nano /etc/apt/sources.list.d/raspi.list
# 注釋掉原有的源,添加這個(gè)源
deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bookworm main
# 編輯這個(gè)文件
sudo nano /etc/apt/sources.list
# 注釋掉原有的內(nèi)容,添加下方內(nèi)容
# 默認(rèn)注釋了源碼鏡像以提高 apt update 速度,如有需要可自行取消注釋
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# 以下安全更新軟件源包含了官方源與鏡像站配置,如有需要可自行修改注釋切換
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
安裝casaos導(dǎo)航頁
方便安裝和管理docker容器
curl -fsSL https://get.casaos.io | sudo bash
安裝Zigbee2MQTT
casaos中使用如下配置文件新建一個(gè)應(yīng)用
name: stirring_chiahui
services:
main_app:
cpu_shares: 10
command: []
container_name: Zigbee2MQTT
deploy:
resources:
limits:
memory: 256M
devices:
- /dev/ttyUSB0:/dev/ttyACM0
environment:
- TZ=Asia/Shanghai
image: koenkk/zigbee2mqtt:latest
labels:
icon: https://icon.casaos.io/main/all/zigbee2mqtt.png?x-oss-process=image/watermark,g_center,image_YXJ0aWNsZS9wdWJsaWMvd2F0ZXJtYXJrLnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3Jlc2l6ZSxQXzQwCg,t_20
ports:
- target: 8080
published: "23080"
protocol: tcp
restart: unless-stopped
volumes:
- type: bind
source: /DATA/AppData/z2m/data
target: /app/data
- type: bind
source: /run/udev
target: /run/udev:ro
cap_add: []
network_mode: bridge
privileged: false
hostname: Zigbee2MQTT
x-casaos:
author: self
category: self
hostname: ""
icon: https://icon.casaos.io/main/all/zigbee2mqtt.png?x-oss-process=image/watermark,g_center,image_YXJ0aWNsZS9wdWJsaWMvd2F0ZXJtYXJrLnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3Jlc2l6ZSxQXzQwCg,t_20
index: /
is_uncontrolled: false
port_map: "23080"
scheme: http
store_app_id: stirring_chiahui
title:
custom: Zigbee2MQTT
創(chuàng)建完成后停止運(yùn)行,然后修改配置文件,按照如下修改,其他的不動(dòng)
homeassistant: true
frontend: true
mqtt:
base_topic: zigbee2mqtt
server: mqtt://IP
user: user
password: passowrd
serial:
port: /dev/ttyACM0
其他配套軟件
EMQX: MQTT Broker
Homeassistant: 控制中心
Node-Red: 可選,擴(kuò)展應(yīng)用
以下為視頻演示: