1.前言
基于Seeed xiao ESP32S3 Sense的自动化HA鱼缸
在当今物联网与智能家居科技日益发达的时代,将先进技术和传统养鱼艺术融合,创造出智能、自动化且极具观赏价值的鱼缸已成为一种创新趋势。SeeedStudio推出的Xiao ESP32-S3 Sense开发板以其卓越的性能和丰富的拓展性为这一设想提供了有力的技术支撑。这款开发板搭载了高性能的ESP32-S3芯片,集成了强大的处理能力、Wi-Fi和蓝牙双模无线通讯模块,并内嵌有OV2640摄像头,使其成为构建智能鱼缸的理想核心元件。
本文旨在探讨如何运用Seeed Xiao ESP32-S3 Cam开发板设计一款自动化、可接入Home Assistant(简称HA)的智能鱼缸系统。系统将集成多项功能,如自动投喂、环境监测(包括温度、湿度)、实时视频监控以及远程管理等,使鱼缸养护工作更加科学便捷,同时也增强了观赏体验和互动性。
1.1 立项目标
- 基于ESP32S3 Sense接入ESPHome实体化研究(涉及Camera/DHT/LED/Servo)
- 基于NodeRED+小爱自动化服务鱼缸管理研究(涉及自动语音播报温湿度、定时开灯、定时投饵)
通过精心设计和细致调试,我们将借助开源软硬件的优势,搭建起一套涵盖硬件组装、软件编程、云服务对接等多层面技术环节的智能鱼缸解决方案。在这个过程中,不仅体现了技术创新带来的生活乐趣,也展示了物联网技术在改善生活品质、提升宠物养护体验等方面的广泛应用前景。随着篇章的深入,读者将逐步了解如何利用Xiao ESP32-S3 Cam及其周边组件,结合Home Assistant的强大自动化能力,共同构建一个既实用又充满科技魅力的智能鱼缸系统。
1.2 系统设计流程图
系统设计流程图是一个用于描述HA自动化系统设计过程的流程图。在这个流程中,首先进行的是项目立项,然后进入系统设计阶段,包括结构设计和硬件模块设计。在硬件模块设计中,又包括硬件模块设计和软件模块设计。然后进行联合调试,如果调试成功,就进行系统设计修改,如果调试失败,就回到硬件模块设计进行更改,直到调试成功。最后,进行是总结并记录归档。
2. 关键技术
2.1 HA环境搭建
时隔一年,我又重新开始玩Homeassistant,发现其中奥妙无穷,惊喜不断。在我浅薄的认知中要学好嵌入式,必须玩过Homeassistant,并且玩出自己的名堂!因为这是最贴切实际的生活应用没有之一,每月更新使得唯有活水来;拥抱大千使得永葆青春的活力;鬼斧神工的操作精彩纷呈,可以堪称软件与硬件的完美落地!在2024年我会出一期完整的树莓派与Homeassistant不解之缘的开发教程,只需要简单的代码拼接和模块的堆叠,会在这里看到接地气(GPIO、PWM、UART等)的硬件和妙笔生花(自动化、语音识别、语音合成、chatgpt大语言模型等)的软件之间无机衔接,最终设计一个属于自己的智能家居系统Homeassistant。
参考教程:【树莓派安装Homeassistant及基本配置】
2.2 ESPHome设备接入
本 教程将逐步介绍如何将 Seeed Studio XIAO ESP32S3 与 Home Assistant 上运行的。
ESPHome 连接,并在将 Grove 模块连接到 XIAO ESP32S3 后发送传感器数据/控制设备。那么,让我们开始吧!
参考教程:【XIAO ESP32S3 sense 通过 ESPHome 与 Home Assistant 连接】
2.3 NodeRED自动化设计
上面实现HA环境配置和xiao ESP32S3 开发板实体信息接入ESPHome,接下来就需要设计相对应的自动化控制,其中关键在于NodeRED自动化设计。实现是Homeassistant 的Node-red插件之小爱同学语音功能开通,采用NodeRED节点流设计自动化控制流,实现播报任意带变量的文本🥳🥳🥳
参考教程:【Homeassistant 的Node-red插件之小爱同学语音功能开通】
3. 系统硬件
系统硬件由xiao esp32s3与树莓派400组成,树莓派400是主控服务器,xiao esp32s3是客户端,xiao esp32s3连接Camera/DHT/LED/Servo
名称 | 信号端口 | 功能 |
---|---|---|
DHT | GPIO8 | 检测鱼缸外部温湿度 |
LED | GPIO21 | 鱼缸照明 |
Servo | GPI7 | 鱼缸喂食器 |
3.1 Camera
围绕OV2640相机(XIAO ESP32S3 Sense)与鱼缸相结合的应用场景,我们可以设计一个智能鱼缸监控系统。并通过ESP32S3的Wi-Fi功能将视频流发送到云端服务器或本地HA设备,便于远程观察鱼儿的生活状态和鱼缸环境。
畅想:
- 自动化喂食:通过对鱼缸内情况进行分析,配合定时功能,可以实现自动化的定时定量喂食。
- 健康监测:长期记录并分析鱼类的行为特征,识别异常行为,提前发现潜在的健康问题。
- 水质预警:通过图像识别水质的变化,及时提醒用户更换滤材或采取其他水质维护措施。
总结来说,XIAO ESP32S3 Sense与OV2640相机的结合,可以打造一个功能丰富的智能鱼缸监控系统,不仅能提供实时监控功能,还能通过数据分析提升养鱼体验,实现智慧渔业管理。
3.2 DHT
由于鱼缸环境对于水温和湿度稳定性的要求较高,尤其是在饲养热带观赏鱼或者需要保持特定温湿度范围的情况下,DHT传感器成为必不可少的组件。DHT系列传感器包括但不限于DHT11(本文采用型号)和DHT22(也称为AM2302)等型号,它们均能够提供数字信号输出的温湿度测量结果,具有良好的性价比和稳定性。
畅想
- 温度监测与控制:DHT传感器可以实时监测鱼缸水体温度,以及周围空气的温度,这些数据对于维持鱼只生存所需的适宜温度至关重要。当温度超过或低于预设的舒适区间时,连接到传感器的控制系统会收到信号,进而启动加热器或冷却设备,自动调整鱼缸水温。
- 数据记录与报警:DHT传感器的数据可以被记录下来,形成历史曲线,帮助养鱼者了解鱼缸环境变化趋势。当温度或湿度出现异常波动时,可通过配套的电路和软件系统触发警报,及时通知养鱼者采取相应措施。
因此,将DHT传感器集成到智能鱼缸设计中,不仅有利于保证鱼缸内生物的健康,也有助于提高整个鱼缸系统的自动化程度和管理水平。例如,可以通过ESP32或其他微处理器平台轻松读取DHT传感器的数据,并实现上述功能。
3.3 LED
LED(Light Emitting Diode)与鱼缸的结合,主要体现在鱼缸照明和水生生物生长环境模拟方面。LED灯具有能耗低、寿命长、色彩丰富、亮度可调等特点,非常适合用于鱼缸照明及水草养殖。
畅想
- 照明效果:LED鱼缸灯可以根据不同种类的观赏鱼和水草的需求提供特定光谱的光线,比如热带鱼和水草需要蓝光和红光来模拟自然界的日照,促进生理活动和增强观赏效果。
- 节能和智能化:LED灯具的能效高,长期使用成本较低,而且很多现代的LED鱼缸灯支持定时开关和亮度调节,可以根据生物作息习惯模拟昼夜交替,甚至可以通过智能家居系统远程控制。
综上所述,LED技术在鱼缸领域扮演着重要的角色,不仅可以满足美学需求,更重要的是能满足鱼类和水生植物在光环境方面的生物学需求,是现代智能鱼缸生态系统不可或缺的一部分。
3.4 Servo
伺服电机(Servo Motor)在鱼缸自动喂食器中的应用是用于精确控制食物投放动作的装置。伺服电机能在特定角度范围内精准定位,这对于确保鱼饲料每次投放的适量非常关键。
在鱼缸自动喂食器中,伺服电机的工作原理如下:
- 投放机构:伺服电机通过传动机构(如齿轮、连杆等)连接到食物投放部件,如螺旋推进器或者滑槽等,当伺服电机接收到指令后,旋转到预设的角度,推动饲料颗粒进入鱼缸。
- 定时定量喂食:通过编程设定,自动喂食器能够在指定的时间点驱动伺服电机工作,使得投放机构释放预先设定好的饲料量。
总之,伺服电机喂食器与鱼缸相适应,实现了鱼缸自动喂食的精准化、智能化和远程可控化,大大提高了养鱼爱好者的便利性和观赏鱼的饲养质量。
4. 遇到的问题
- 小爱同学如何接入HA,每天定时执行任务。解决办法:【Homeassistant 的Node-red插件之小爱同学语音功能开通】
- xiao esp32s3如何接入ESPHome。解决办法:【XIAO ESP32S3 sense 通过 ESPHome 与 Home Assistant 连接】
5. 程序设计
程序设计主要是
- ESP32S3 Sense 接入ESPHome设备实体yaml代码设计
- NodeRED自动化控制流模块配置
5.1 ESPHome设备接入
ESP32S3 Sense 接入ESPHome设备的完整代码如下
esphome:name: xiao-cam# friendly_name: xiao-camesp32:board: esp32-s3-devkitc-1framework:type: arduino# Enable logging
logger:# Enable Home Assistant API
api:encryption:key: "Fabc3YZ2bYG7x8WhupncrCMPqZuPMwxyeCPsgrbQIAI="ota:password: "412c844a7b10765fcd89954e7587e5af"wifi:ssid: "J09 502"password: "qwertyuiop111"# use_address: elkontrol1# use_address: elkontrol1.local# Enable fallback hotspot (captive portal) in case wifi connection failsap:ssid: "Xiao Fallback Hotspot1"password: "YpeK5OYS4Xej"captive_portal:
# Example configuration entry
external_components:- source:type: giturl: https://github.com/MichaKersloot/esphome_custom_componentscomponents: [ esp32_camera ]esp32_camera:external_clock:pin: GPIO10frequency: 20MHzi2c_pins:sda: GPIO40scl: GPIO39data_pins: [GPIO15, GPIO17, GPIO18, GPIO16, GPIO14, GPIO12, GPIO11, GPIO48]vsync_pin: GPIO38href_pin: GPIO47pixel_clock_pin: GPIO13# Image settingsname: My Camera# ...# Configuration for the status LED light
light:- platform: status_ledid: light0name: "Voice Assistant State"pin:number: GPIO21inverted: true# Configuration for I2S audio
i2s_audio:i2s_lrclk_pin: GPIO46 # Note: labeled as "useless"i2s_bclk_pin: GPIO42# Configuration for the microphone using I2S audio
microphone:- platform: i2s_audioid: echo_microphonei2s_din_pin: GPIO41adc_type: externalpdm: true# Configuration for the Voice Assistant
voice_assistant:microphone: echo_microphone# Configuration for the binary sensor (Boot Switch)
binary_sensor: - platform: gpiopin: number: GPIO2mode:input: truepullup: truename: Boot Switchinternal: trueon_press:- voice_assistant.start:- light.turn_off: light0on_release:- voice_assistant.stop:- light.turn_on: light0# Example configuration entry (D2)
sensor:- platform: dhtpin: GPIO7temperature:name: "Temperature"humidity:name: "Humidity"update_interval: 5snumber:- platform: templatename: Servo Controlmin_value: -100max_value: 100step: 1set_action:then:- servo.write:id: my_servolevel: !lambda 'return x / 100.0;'# Example configuration entry
servo:- id: my_servooutput: pwm_output# Example output platform
# On ESP32, use ledc output
output:- platform: ledcid: pwm_outputpin: GPIO8frequency: 50 Hz
这段ESPhome配置文件描述了一台基于ESP32-S3芯片的设备(命名为"xiao-cam")的各种配置项,主要用于控制和监控鱼缸环境,并且整合了摄像、音频输入输出、LED指示灯、温湿度传感器以及伺服电机等功能。
- 基础配置:设备名为xiao-cam,ESP32框架选用arduino,主板类型为esp32-s3-devkitc-1。开启日志记录功能,并配置Home Assistant API以供远程访问,其中包含API加密密钥。Wi-Fi连接信息,包括SSID、密码,以及在Wi-Fi连接失败时启用的备用热点(captive portal)。
- 外部组件:从MichaKersloot的GitHub仓库拉取自定义组件,其中包括esp32_camera组件。
- 摄像头配置:配置ESP32-CAM模块的引脚分配和外接晶振频率,用于驱动OV2640摄像头。
- LED指示灯:创建一个状态LED灯,当语音助手激活或关闭时,改变LED状态。
- 麦克风与语音助手:使用I2S音频接口设置麦克风,用于拾音,并将麦克风绑定到语音助手服务。
- 二进制传感器(开机按钮):配置一个GPIO引脚作为开机按钮,按下时启动语音助手服务并关闭LED指示灯,松开时停止语音助手服务并打开LED指示灯。
- 温湿度传感器:使用DHT传感器采集鱼缸环境的温度和湿度,每5秒更新一次数据。
- 模板数值控制:创建一个虚拟数显控制器,用于调整伺服电机的角度,当数值改变时,将数值映射到伺服电机的控制水平。
- 伺服电机:配置一个伺服电机,通过PWM输出控制,这里的输出平台是ledc,也就是LED PWM控制器。
- 输出平台配置:设置一个LED PWM输出通道,用于驱动伺服电机,配置了输出频率为50Hz。
综上所述,这段配置文件旨在实现一个具备拍照、录音、语音唤醒、环境温湿度监测以及伺服电机控制等多种功能的智能鱼缸配件。通过ESP32-S3开发板,该设备能够接入家庭自动化系统,实现高度定制化的自动化控制。
5.2 NodeRED控制流
- 小爱同学语言播报,测试是否故障
Json代码
[{"id": "31531595a3887301","type": "tab","label": "小爱同学配置","disabled": false,"info": "","env": []},{"id": "01c4904dbc06f88c","type": "inject","z": "31531595a3887301","name": "","props": [{"p": "payload"},{"p": "topic","vt": "str"}],"repeat": "","crontab": "","once": false,"onceDelay": 0.1,"topic": "","payload": "","payloadType": "date","x": 260,"y": 120,"wires": [["5d641ec6b07a673c"]]},{"id": "95179cc4df24244c","type": "debug","z": "31531595a3887301","name": "debug 1","active": true,"tosidebar": true,"console": false,"tostatus": false,"complete": "false","statusVal": "","statusType": "auto","x": 820,"y": 120,"wires": []},{"id": "d03f58e01f4a16b3","type": "inject","z": "31531595a3887301","name": "","props": [{"p": "payload"},{"p": "topic","vt": "str"}],"repeat": "","crontab": "","once": false,"onceDelay": 0.1,"topic": "","payload": "","payloadType": "date","x": 220,"y": 220,"wires": [["a89d1daebe024134"]]},{"id": "8d8e1bd016c64e63","type": "debug","z": "31531595a3887301","name": "debug 2","active": true,"tosidebar": true,"console": false,"tostatus": false,"complete": "false","statusVal": "","statusType": "auto","x": 740,"y": 220,"wires": []},{"id": "5d641ec6b07a673c","type": "xiaoai-volume","z": "31531595a3887301","name": "","xiaoai": "c8dc251df8e97718","volume": "11","device": "","x": 460,"y": 120,"wires": [["95179cc4df24244c"],[]]},{"id": "a89d1daebe024134","type": "api-call-service","z": "31531595a3887301","name": "测试小爱同学","server": "9e5db24f.d50e5","version": 5,"debugenabled": false,"domain": "xiaomi_miot","service": "intelligent_speaker","areaId": [],"deviceId": [],"entityId": ["sensor.xiaomi_lx04_5e02_conversation"],"data": "{\"text\":\"你好鸭!欢迎来到智慧实验室,我是鹏鹏的小助手\"}","dataType": "jsonata","mergeContext": "","mustacheAltTags": false,"outputProperties": [{"property": "payload","propertyType": "msg","value": "测试小爱同学成功","valueType": "str"}],"queue": "none","x": 480,"y": 220,"wires": [["8d8e1bd016c64e63"]]},{"id": "6f985e77ba2239d8","type": "inject","z": "31531595a3887301","name": "触发器","props": [{"p": "payload"},{"p": "topic","vt": "str"}],"repeat": "","crontab": "","once": false,"onceDelay": 0.1,"topic": "","payload": "","payloadType": "date","x": 150,"y": 380,"wires": [["c87ec627c3d65acc"]]},{"id": "cdf9b42ee3b909ee","type": "debug","z": "31531595a3887301","name": "打印调试","active": true,"tosidebar": true,"console": false,"tostatus": false,"complete": "payload","targetType": "msg","statusVal": "","statusType": "auto","x": 1040,"y": 380,"wires": []},{"id": "c87ec627c3d65acc","type": "xiaoai-volume","z": "31531595a3887301","name": "","xiaoai": "c8dc251df8e97718","volume": "43","device": "","x": 320,"y": 380,"wires": [["06efbebf06c2e680"],["710be66d9ae5fa19"]]},{"id": "710be66d9ae5fa19","type": "api-call-service","z": "31531595a3887301","name": "小助手故障提醒","server": "41ef4b78.2e2ab4","version": 5,"debugenabled": false,"domain": "smtp","service": "notify","areaId": [],"deviceId": [],"entityId": [],"data": "{\t \"message\":\"<b>当前智慧实验室小助手失效,请重新检测设备</b>\",\t \"title\":\"消息来自HomeAssistant\",\t \"email\":\"3126171871@qq.com\"\t}","dataType": "jsonata","mergeContext": "","mustacheAltTags": false,"outputProperties": [{"property": "payload","propertyType": "msg","value": "小助手故障提醒","valueType": "str"}],"queue": "none","x": 700,"y": 420,"wires": [["cdf9b42ee3b909ee"]]},{"id": "06efbebf06c2e680","type": "api-call-service","z": "31531595a3887301","name": "测试小爱同学","server": "9e5db24f.d50e5","version": 5,"debugenabled": false,"domain": "xiaomi_miot","service": "intelligent_speaker","areaId": [],"deviceId": [],"entityId": ["sensor.xiaomi_lx04_5e02_conversation"],"data": "{\"text\":\"你好鸭!欢迎来到智慧实验室,我是鹏鹏的小助手\"}","dataType": "jsonata","mergeContext": "","mustacheAltTags": false,"outputProperties": [{"property": "payload","propertyType": "msg","value": "测试小爱同学成功","valueType": "str"}],"queue": "none","x": 700,"y": 320,"wires": [["cdf9b42ee3b909ee"]]},{"id": "c8dc251df8e97718","type": "xiaoai-tts-configurator","name": "小爱"},{"id": "9e5db24f.d50e5","type": "server","name": "Home Assistant","addon": true},{"id": "41ef4b78.2e2ab4","type": "server","name": "Home Assistant","version": 5,"addon": true,"rejectUnauthorizedCerts": true,"ha_boolean": "y|yes|true|on|home|open","connectionDelay": true,"cacheJson": true,"heartbeat": false,"heartbeatInterval": "30","areaSelector": "friendlyName","deviceSelector": "friendlyName","entitySelector": "friendlyName","statusSeparator": "at: ","statusYear": "hidden","statusMonth": "short","statusDay": "numeric","statusHourCycle": "h23","statusTimeFormat": "h:m","enableGlobalContextStore": true}
]
- 喂鱼自动化,每天12点自动喂鱼
Json代码
[{"id": "13c9e0ee685611ac","type": "tab","label": "喂鱼自动化","disabled": false,"info": "","env": []},{"id": "2ee71350eab9a05b","type": "inject","z": "13c9e0ee685611ac","name": "","props": [{"p": "payload"},{"p": "topic","vt": "str"}],"repeat": "","crontab": "00 12 * * *","once": true,"onceDelay": 0.1,"topic": "","payload": "","payloadType": "date","x": 260,"y": 100,"wires": [["fd353374c78d82f8"]]},{"id": "87a1d11f9c89367d","type": "debug","z": "13c9e0ee685611ac","name": "debug 3","active": false,"tosidebar": true,"console": false,"tostatus": false,"complete": "false","statusVal": "","statusType": "auto","x": 1060,"y": 380,"wires": []},{"id": "2e6d7d5839debb53","type": "api-call-service","z": "13c9e0ee685611ac","name": "舵机90度","server": "41ef4b78.2e2ab4","version": 5,"debugenabled": false,"domain": "number","service": "set_value","areaId": ["ke_ting"],"deviceId": ["dc2bd470f44cfb196986ae81f0c54a1b"],"entityId": ["number.servo_control"],"data": "{\"value\":100}","dataType": "jsonata","mergeContext": "","mustacheAltTags": false,"outputProperties": [{"property": "payload","propertyType": "msg","value": "舵机90度","valueType": "str"}],"queue": "none","x": 800,"y": 100,"wires": [["508e5a9410e2423c"]]},{"id": "a81f43e407aa0c35","type": "api-call-service","z": "13c9e0ee685611ac","name": "舵机0度","server": "41ef4b78.2e2ab4","version": 5,"debugenabled": false,"domain": "number","service": "set_value","areaId": ["ke_ting"],"deviceId": ["dc2bd470f44cfb196986ae81f0c54a1b"],"entityId": ["number.servo_control"],"data": "{\"value\":-100}","dataType": "jsonata","mergeContext": "","mustacheAltTags": false,"outputProperties": [{"property": "payload","propertyType": "msg","value": "舵机0度","valueType": "str"}],"queue": "none","x": 400,"y": 220,"wires": [["7a2b85ccb60380df"]]},{"id": "45dbf177629c65d5","type": "api-call-service","z": "13c9e0ee685611ac","name": "舵机90度","server": "41ef4b78.2e2ab4","version": 5,"debugenabled": false,"domain": "number","service": "set_value","areaId": ["ke_ting"],"deviceId": ["dc2bd470f44cfb196986ae81f0c54a1b"],"entityId": ["number.servo_control"],"data": "{\"value\":100}","dataType": "jsonata","mergeContext": "","mustacheAltTags": false,"outputProperties": [{"property": "payload","propertyType": "msg","value": "舵机90度","valueType": "str"}],"queue": "none","x": 860,"y": 220,"wires": [["c595f13eb99d5d01"]]},{"id": "d4dce4fd5a1de16d","type": "api-call-service","z": "13c9e0ee685611ac","name": "舵机0度","server": "41ef4b78.2e2ab4","version": 5,"debugenabled": false,"domain": "number","service": "set_value","areaId": ["ke_ting"],"deviceId": ["dc2bd470f44cfb196986ae81f0c54a1b"],"entityId": ["number.servo_control"],"data": "{\"value\":-100}","dataType": "jsonata","mergeContext": "","mustacheAltTags": false,"outputProperties": [{"property": "payload","propertyType": "msg","value": "舵机0度","valueType": "str"}],"queue": "none","x": 480,"y": 380,"wires": [["07266ceecfd9a08f"]]},{"id": "508e5a9410e2423c","type": "delay","z": "13c9e0ee685611ac","name": "","pauseType": "delay","timeout": "5","timeoutUnits": "seconds","rate": "1","nbRateUnits": "1","rateUnits": "second","randomFirst": "1","randomLast": "5","randomUnits": "seconds","drop": false,"allowrate": false,"outputs": 1,"x": 1060,"y": 100,"wires": [["a81f43e407aa0c35"]]},{"id": "c595f13eb99d5d01","type": "delay","z": "13c9e0ee685611ac","name": "","pauseType": "delay","timeout": "5","timeoutUnits": "seconds","rate": "1","nbRateUnits": "1","rateUnits": "second","randomFirst": "1","randomLast": "5","randomUnits": "seconds","drop": false,"allowrate": false,"outputs": 1,"x": 1180,"y": 220,"wires": [["d4dce4fd5a1de16d"]]},{"id": "7a2b85ccb60380df","type": "delay","z": "13c9e0ee685611ac","name": "","pauseType": "delay","timeout": "5","timeoutUnits": "seconds","rate": "1","nbRateUnits": "1","rateUnits": "second","randomFirst": "1","randomLast": "5","randomUnits": "seconds","drop": false,"allowrate": false,"outputs": 1,"x": 640,"y": 220,"wires": [["45dbf177629c65d5"]]},{"id": "07266ceecfd9a08f","type": "api-call-service","z": "13c9e0ee685611ac","name": "结束喂鱼","server": "41ef4b78.2e2ab4","version": 5,"debugenabled": false,"domain": "xiaomi_miot","service": "intelligent_speaker","areaId": [],"deviceId": [],"entityId": ["sensor.xiaomi_lx04_5e02_conversation"],"data": "{\"text\":\"小爱同学已经喂鱼成功啦\"}","dataType": "jsonata","mergeContext": "","mustacheAltTags": false,"outputProperties": [{"property": "payload","propertyType": "msg","value": "结束喂鱼","valueType": "str"}],"queue": "none","x": 800,"y": 380,"wires": [["87a1d11f9c89367d"]]},{"id": "fd353374c78d82f8","type": "api-call-service","z": "13c9e0ee685611ac","name": "开始喂鱼","server": "41ef4b78.2e2ab4","version": 5,"debugenabled": false,"domain": "xiaomi_miot","service": "intelligent_speaker","areaId": [],"deviceId": [],"entityId": ["sensor.xiaomi_lx04_5e02_conversation"],"data": "{\"text\":\"小爱同学开始喂鱼啦\"}","dataType": "jsonata","mergeContext": "","mustacheAltTags": false,"outputProperties": [{"property": "payload","propertyType": "msg","value": "测试小爱同学成功","valueType": "str"}],"queue": "none","x": 460,"y": 100,"wires": [["2e6d7d5839debb53"]]},{"id": "41ef4b78.2e2ab4","type": "server","name": "Home Assistant","version": 5,"addon": true,"rejectUnauthorizedCerts": true,"ha_boolean": "y|yes|true|on|home|open","connectionDelay": true,"cacheJson": true,"heartbeat": false,"heartbeatInterval": "30","areaSelector": "friendlyName","deviceSelector": "friendlyName","entitySelector": "friendlyName","statusSeparator": "at: ","statusYear": "hidden","statusMonth": "short","statusDay": "numeric","statusHourCycle": "h23","statusTimeFormat": "h:m","enableGlobalContextStore": true}
]
- 开灯自动化
Json代码
[{"id": "10765693b6bcfeaf","type": "tab","label": "开灯自动化","disabled": false,"info": "","env": []},{"id": "3eca89300da6a067","type": "api-call-service","z": "10765693b6bcfeaf","name": "开灯","server": "9e5db24f.d50e5","version": 5,"debugenabled": false,"domain": "light","service": "turn_on","areaId": ["ke_ting"],"deviceId": ["dc2bd470f44cfb196986ae81f0c54a1b"],"entityId": ["light.voice_assistant_state"],"data": "","dataType": "jsonata","mergeContext": "","mustacheAltTags": false,"outputProperties": [{"property": "payload","propertyType": "msg","value": "开灯","valueType": "str"}],"queue": "none","x": 810,"y": 300,"wires": [["d4b489b84d3a1a11"]]},{"id": "d16b213857492fcb","type": "time-range-switch","z": "10765693b6bcfeaf","name": "","lat": "","lon": "","startTime": "07:28","endTime": "12:28","startOffset": 0,"endOffset": 0,"x": 550,"y": 320,"wires": [["784f9bc1adca590d"],["3eca89300da6a067"]]},{"id": "784f9bc1adca590d","type": "api-call-service","z": "10765693b6bcfeaf","name": "关灯","server": "9e5db24f.d50e5","version": 5,"debugenabled": false,"domain": "light","service": "turn_off","areaId": ["ke_ting"],"deviceId": ["dc2bd470f44cfb196986ae81f0c54a1b"],"entityId": ["light.voice_assistant_state"],"data": "","dataType": "jsonata","mergeContext": "","mustacheAltTags": false,"outputProperties": [{"property": "payload","propertyType": "msg","value": "关灯","valueType": "str"}],"queue": "none","x": 790,"y": 400,"wires": [["d4b489b84d3a1a11"]]},{"id": "d4b489b84d3a1a11","type": "debug","z": "10765693b6bcfeaf","name": "debug 5","active": true,"tosidebar": true,"console": false,"tostatus": false,"complete": "false","statusVal": "","statusType": "auto","x": 1000,"y": 360,"wires": []},{"id": "56a173656eee3993","type": "inject","z": "10765693b6bcfeaf","name": "","props": [{"p": "payload"},{"p": "topic","vt": "str"}],"repeat": "","crontab": "0 7-13 * * *","once": false,"onceDelay": 0.1,"topic": "","payload": "","payloadType": "date","x": 370,"y": 320,"wires": [["d16b213857492fcb"]]},{"id": "1ff3db3ea7622884","type": "inject","z": "10765693b6bcfeaf","name": "","props": [{"p": "payload"},{"p": "topic","vt": "str"}],"repeat": "","crontab": "","once": false,"onceDelay": 0.1,"topic": "","payload": "","payloadType": "date","x": 650,"y": 220,"wires": [["3eca89300da6a067"]]},{"id": "6c19a3bec41654a6","type": "inject","z": "10765693b6bcfeaf","name": "","props": [{"p": "payload"},{"p": "topic","vt": "str"}],"repeat": "","crontab": "","once": false,"onceDelay": 0.1,"topic": "","payload": "","payloadType": "date","x": 650,"y": 460,"wires": [["784f9bc1adca590d"]]},{"id": "9e5db24f.d50e5","type": "server","name": "Home Assistant","addon": true}
]
6. 效果展示
实物图制作
主视图
侧视图
6.1 HA界面
这个概览界面显示小爱同学和ESP32S3 Sense设备接入情况
- 滑动
Servo control
控制喂食 - 点击
Voice Assistant State
鱼缸补光 - 查看当前鱼缸外围温湿度
- 通过
My Camera
实时摸鱼
6.2 NodeRED自动化
设计每天12定时喂鱼,喂鱼效果如下,下面是滑动Servo control
从-100~100
测试小爱同学,点击触发就可让小爱同学发声
7. 总结
这是我第五次参加嵌入式相关的网上比赛活动
● 第一次是RT-Thread的【基于RT-Thread+RA6M4的智能鱼缸系统设计之鱼我所欲也】活动,作品是2022年暑假做的获得第六名,还是比较开心!
● 第二次2023年寒假做的是【基于MAX7800羽毛板语音控制ESP8266小车】,成绩还不错第七名,让对小车车的可玩性又近了一步!
● 第三次2023年春做的【基于腾讯云的CH32V307开发板远程机械臂小车】,由于图床引用CSDN导致最后评审没有显示出来,最后获得安慰奖!
● 第四次2023年冬做的【FastBond2阶段2——基于ESP32C3开发的简易IO调试设备 - 电子森林 (eetree.cn) 】 ,最终获得三等奖,再接再厉哦!
● 第五次实现了【基于LicheePi-4A的 人脸识别系统软件设计】,人脸识别系统软件设计和调试全流程,加深了对tkinter GUI设计思路,对LicheePi-4A 国产单板计算机更有信心,最终获得参与奖!
这一次我又回到最开始,用HA重新做了一遍,发现代码量减少许多,对智能家居有更深刻认识啦!😘😘😘
建议:
- 希望硬禾与Seeed多多合作定期举办博客活动,让更加优质的国产嵌入式生态做大做强;
- 期待硬禾平台推出更多有质量有意义持续性的创客活动!
非常硬禾举行寒假在家一起练活动,大家都为这个国内嵌入式生态出一份力,只要努力认真做了都会有所收获,期盼这些作品在将来某一天为构建美好未来贡献一份微博之力!
我后期会持续更新我测评的一系列国内开发板测评,并且会积极参加有质量的玄铁杯活动🛹🛹🛹每天都一点点结合实际需求联动丰富生活,从而实现对外部世界进行充分的感知,尽最大努力认识这个有机与无机的环境,科学地合理地进行创作和发挥效益,然后为人类社会发展贡献一点微薄之力。🤣🤣🤣
🥳🥳🥳再次非常感谢硬禾的相关组织者支持等等🥳🥳🥳期待这一次的成绩哟!
参考文献:
- 【树莓派安装Homeassistant及基本配置】
- 【XIAO ESP32S3 sense 通过 ESPHome 与 Home Assistant连接】
- 【Homeassistant的Node-red插件之小爱同学语音功能开通】