目錄
一? ?項(xiàng)目說明
①? ?設(shè)計(jì)框架
②? ?功能說明
③? ?硬件說明
④? ?軟件說明
二? ?項(xiàng)目代碼
<1> mainPro.c 主函數(shù)
<2> InputCommand.h 控制設(shè)備頭文件
<3> contrlDevices.h 外接設(shè)備頭文件
<4> bathroomLight.c 泳池?zé)?/p>
<5> livingroomLight.c 臥室燈
<6> restaurantLight.c 餐廳燈
<7> upstairLight.c 二樓燈
<8> fire.c 火焰?zhèn)鞲衅?/p>
<9> beep.c 蜂鳴器
<10> voiceContrl.c 語音模塊
<11>?socketContrl.c 服務(wù)器
三? ?項(xiàng)目演示
四? ?項(xiàng)目問題總結(jié)
問題一
問題二
問題三
問題四?
五? ?項(xiàng)目相關(guān)知識(shí)點(diǎn)整理
?
一? ?項(xiàng)目說明
①? ?設(shè)計(jì)框架
● 項(xiàng)目架構(gòu)采用簡(jiǎn)單工廠模式來設(shè)計(jì),將語音識(shí)別,TCP服務(wù)器設(shè)計(jì)成鏈表的每個(gè)節(jié)點(diǎn),形成控制工廠。
● 將餐廳燈,臥室燈,二樓燈,泳池?zé)?,蜂鳴器,火焰檢測(cè)模塊,也設(shè)計(jì)成鏈表的每個(gè)節(jié)點(diǎn),形成設(shè)備端工廠。
● 基于這種架構(gòu)保證項(xiàng)目的穩(wěn)定性和功能拓展性,在添加新功能的時(shí)候,只需要添加一個(gè)鏈表節(jié)點(diǎn)文件文件就可以。
● 不管是設(shè)備端還是控制端,在實(shí)際調(diào)試過程中又涉及到臨界資源的競(jìng)爭(zhēng),所以采用多線程來解決這個(gè)問題。
● 語音處理用的是SU-03T模塊的二次開發(fā),對(duì)串口數(shù)據(jù)進(jìn)行修改并整合到樹莓派的串口通信中去。
②? ?功能說明
● 語音模塊識(shí)別語音來控制各個(gè)燈的開關(guān),基于串口通信來配置語音命令的內(nèi)容。
● 搭建TCP服務(wù)器,用socket網(wǎng)絡(luò)通信的方式控制各個(gè)燈的開關(guān),手機(jī)客戶端發(fā)送指令到電腦服務(wù)器端來實(shí)現(xiàn)控制功能。
● 火災(zāi)報(bào)警,火焰檢測(cè)模塊結(jié)合蜂鳴器開發(fā)。接收火焰狀態(tài),檢測(cè)有火源靠近時(shí),蜂鳴器輸出低電平發(fā)出警報(bào)聲響,并在終端顯示火災(zāi)危險(xiǎn)提示,檢測(cè)沒有火源時(shí),蜂鳴器輸出高電平,停止報(bào)警聲。
● 實(shí)時(shí)監(jiān)控,將攝像頭模塊安裝于樹莓并配置樹莓派攝像頭的接口參數(shù),打開攝像頭,寫入樹莓ip地址及端口即可。
③? ?硬件說明
樹莓派開發(fā)板(3B),繼電器組,房屋模型,蜂鳴器,語音模塊,火焰檢測(cè)模塊,電池盒,攝像頭,杜邦線,燈具,USB-TTL模塊(串口調(diào)試)
④? ?軟件說明
SecureCRT8.0(樹莓派終端),sourceinsight(代碼編輯),filezilla(文件傳輸),AiThinker Serial Tool(串口調(diào)試),NetAssist(網(wǎng)絡(luò)調(diào)試)。文章來源:http://www.zghlxwxcb.cn/news/detail-431621.html
二? ?項(xiàng)目代碼
文章來源地址http://www.zghlxwxcb.cn/news/detail-431621.html
<1> mainPro.c 主函數(shù)
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "contrlDevices.h"http://外接設(shè)備
#include "InputCommand.h"http://控制
struct InputCommander *pCommandHead = NULL;
struct Devices *pdeviceHead = NULL;
struct InputCommander *socketHandler = NULL;
int c_fd;
//外設(shè)的設(shè)備查詢
struct Devices *findDeviceByName(char *name,struct Devices *phead)
{
struct Devices *tmp = phead;
if(phead == NULL){
return NULL;
}else{
while(tmp != NULL){
if(strcmp(tmp->deviceName,name) == 0){
return tmp;
}
tmp = tmp->next;
}
return NULL;
}
};
//控制設(shè)備查詢
struct InputCommander *findCommandByName(char *name,struct InputCommander *phead)
{
struct InputCommander *tmp = phead;
if(phead == NULL){
return NULL;
}else{
while(tmp != NULL){
if(strcmp(tmp->commandName,name) == 0){
return tmp;
}
tmp = tmp->next;
}
return NULL;
}
};
//控制燈函數(shù),用于語音線程
void Command(struct InputCommander *CmdHandler)
{
struct Devices *
到了這里,關(guān)于基于RAM樹莓派實(shí)現(xiàn)智能家居:語音識(shí)別控制,Socket網(wǎng)絡(luò)控制,火災(zāi)報(bào)警檢測(cè),實(shí)時(shí)監(jiān)控的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!