<acronym id="s8ci2"><small id="s8ci2"></small></acronym>
<rt id="s8ci2"></rt><rt id="s8ci2"><optgroup id="s8ci2"></optgroup></rt>
<acronym id="s8ci2"></acronym>
<acronym id="s8ci2"><center id="s8ci2"></center></acronym>
0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

如何利用BME680實現智能家居控制中心的設計

科技觀察員 ? 來源:Wan Niu ? 作者:Wan Niu ? 2022-05-25 16:08 ? 次閱讀

該項目具有檢測室內環境數據和發送電子郵件、開燈按鈕、體感照明屏等功能。

經過不斷的踩坑學習,初代簡易智能家居中控系統已經完成,大部分功能已經完成,但是有些功能WIO終端沒有實現。一方面是因為代碼量太大,會給WIO終端帶來很大的“壓力”;另一方面,我的技術還不夠,還得繼續學習,尋找解決方案。

首先介紹一下我最初的想法:

WIO終端是一款高度集成的開發板。它配備了液晶顯示屏、三個按鈕、一個五向開關、麥克風、揚聲器、加速度傳感器、紅外發射器等,甚至可以與樹莓派和 Jetson nano 結合使用。作為家居的“大腦”,這些硬件非常實用。因此,在智能家居的中控系統中,我選擇WIO終端作為這個系統的核心。

未來,家里應該有一個智能管家。這個智能管家就是我現在做的簡單版。有了它,您就可以在家中獲取準確實時的溫度、濕度、光照強度等數據。不僅如此,它還像一個“萬能”遙控器,可以幫助你控制家中的電器。當然,它應該像智能音箱一樣,能夠理解我們給它的指令并響應我們!

提前準備
在這個項目的過程中,我第一次使用了開發板WIO終端:

不知為何,在WIO終端上使用grow-temperature 濕度壓力氣體傳感器時,接收不到數據,只好轉身實現:

使用Django搭建一個簡單的數據中心(基于Grove——溫度濕度壓力氣體傳感器)

重回正軌,實現數據展示的主要功能:

使用WIO終端通過HTTP請求獲取并顯示傳感器實時數據

下一步就是完善其他三個功能,我主要通過python實現

完善系統功能
前面我簡單提到了一些WIO終端上沒有實現的功能的原因,具體原因我沒有細說。畢竟剛開始做,所以打算先實現功能。至于實現方式,我想在二代系統中改進一下

通過 WIO 端子輸出狀態
我要表達的狀態是讀取可配置按鈕的狀態(是否按下按鈕)和麥克風的數據(數據也可以代表狀態)

對于WIO終端來說,簡單的輸出這些數據還是比較簡單的

補充 setup() 中的管腳定義:

pinMode(WIO_MIC, INPUT);
pinMode(WIO_KEY_A, INPUT_PULLUP);
pinMode(WIO_KEY_B, INPUT_PULLUP);
pinMode(WIO_KEY_C, INPUT_PULLUP);

補充loop()中的if條件語句:

int val_first = analogRead(WIO_MIC);
int val_next = analogRead(WIO_MIC);

if (abs(val_first - val_next) >= 100){
Serial.println("send message!");
}
if (digitalRead(WIO_KEY_A) == LOW) {
Serial.println("A Key pressed");
}
if (digitalRead(WIO_KEY_B) == LOW) {
Serial.println("B Key pressed");
}
if (digitalRead(WIO_KEY_C) == LOW) {
Serial.println("C Key pressed");
}
當WIO終端連接PC時,PC會讀取串口的數據,并在讀取相應的輸出時采取相應的動作

至此,我們已經完成了關于 Arduino 的所有代碼。整理一下代碼,分享給大家。

#include
#include
#include"LIS3DHTR.h"
#include"Free_Fonts.h"
#include"TFT_eSPI.h"


TFT_eSPI tft;
LIS3DHTR lis;
WiFiClient client;

const char* ssid = "Your WiFi account";
const char* password = "Your WiFi password";
const char* server = "192.168.1.102"; // Server URL
String data;
float accelerator_readings[3];


void setup() {

//Initialize serial and wait for port to open:
Serial.begin(115200);
delay(100);

pinMode(WIO_MIC, INPUT);
pinMode(WIO_KEY_A, INPUT_PULLUP);
pinMode(WIO_KEY_B, INPUT_PULLUP);
pinMode(WIO_KEY_C, INPUT_PULLUP);

lis.begin(Wire1);
lis.setOutputDataRate(LIS3DHTR_DATARATE_25HZ);
lis.setFullScaleRange(LIS3DHTR_RANGE_2G);

float x_raw = lis.getAccelerationX();
float y_raw = lis.getAccelerationY();
float z_raw = lis.getAccelerationZ();
accelerator_readings[0] = x_raw; //store x-axis readings
accelerator_readings[1] = y_raw; //store y-axis readings
accelerator_readings[2] = z_raw; //store z-axis readings

// Serial.print("Attempting to connect to SSID: ");
// Serial.println(ssid);
WiFi.begin(ssid, password);

tft.begin();
tft.setRotation(3);
tft.fillScreen(TFT_BLACK);
tft.setFreeFont(FMB12);
tft.setCursor((320 - tft.textWidth("Connecting to Wi-Fi.."))/2, 120);
tft.print("Connecting to Wi-Fi..");

// attempt to connect to Wifi network:
while (WiFi.status() != WL_CONNECTED) {
// Serial.print(".");
// wait 1 second for re-trying
delay(1000);
}

// Serial.print("Connected to ");
// Serial.println(ssid);

tft.fillScreen(TFT_BLACK);
tft.setCursor((320 - tft.textWidth("Connected!"))/2, 120);
tft.print("Connected!");

getFirstData();
}

void loop()
{
int val_first = analogRead(WIO_MIC);
float x_raw = lis.getAccelerationX();
float y_raw = lis.getAccelerationY();
float z_raw = lis.getAccelerationZ();
int val_next = analogRead(WIO_MIC);

if (abs(val_first - val_next) >= 100){
Serial.println("send message!");
}
if (digitalRead(WIO_KEY_A) == LOW) {
Serial.println("A Key pressed");
}
if (digitalRead(WIO_KEY_B) == LOW) {
Serial.println("B Key pressed");
}
if (digitalRead(WIO_KEY_C) == LOW) {
Serial.println("C Key pressed");
}

if (abs(accelerator_readings[0] - x_raw) >= 0.1 && abs(accelerator_readings[1] - y_raw) >= 0.1 && abs(accelerator_readings[2] - z_raw) >= 0.1){
// Turning on the LCD backlight
digitalWrite(LCD_BACKLIGHT, HIGH);
getFirstData();
delay(3000);
getLastData();
delay(3000);
}
else {
// Turning off the LCD backlight
digitalWrite(LCD_BACKLIGHT, LOW);
delay(500);
}

for (uint8_t i = 0; i<3; i++){
accelerator_readings[i] = 0.0; //this is used to remove the first read variable
}

accelerator_readings[0] = x_raw; //store x-axis readings
accelerator_readings[1] = y_raw; //store y-axis readings
accelerator_readings[2] = z_raw; //store z-axis readings
}

void getFirstData() {
// Serial.println("\nStarting connection to server...");
if (!client.connect(server, 9000)) {
// Serial.println("Connection failed!");
tft.fillScreen(TFT_BLACK);
tft.setCursor((320 - tft.textWidth("Connection failed!"))/2, 120);
tft.print("Connection failed!");
} else {
// Serial.println("Connected to server!");

// Make a HTTP request:
String postRequest =(String)("GET ") + "/ HTTP/1.1\r\n" + "Connection: close\r\n\r\n";
// Serial.println(postRequest);
client.print(postRequest);

while (client.connected()) {
String line = client.readStringUntil('\n');
if (line == "\r") {
// Serial.println("headers received");
break;
}
}

while(client.available())
{
String line = client.readStringUntil('\r');
data = line;
}
// Serial.println(data);
client.stop();
// Serial.println("closing connection");
}

//ArduinoJson to parse data, plesae check ArduinoJson for more info
const size_t capacity = JSON_OBJECT_SIZE(5) + 100;
DynamicJsonDocument doc(capacity);
deserializeJson(doc, data);

float temperature = doc["temperature"];
float pressure = doc["pressure"];
float humidity = doc["humidity"];

// -----------------LCD---------------------
tft.setFreeFont(FF17);
tft.setTextColor(tft.color565(224,225,232));
tft.drawString("Current Data At Home",20,10);

tft.fillRoundRect(10, 45, 300, 55, 5, tft.color565(40,40,86));
tft.fillRoundRect(10, 105, 300, 55, 5, tft.color565(40,40,86));
tft.fillRoundRect(10, 165, 300, 55, 5, tft.color565(40,40,86));

tft.setFreeFont(FM9);
tft.drawString("temperature:", 75, 50);
tft.drawString("pressure:",75, 110);
tft.drawString("humidity:",75, 170);

tft.setFreeFont(FMB12);
tft.setTextColor(TFT_RED);
tft.drawFloat(temperature,2 , 140, 75);
tft.setTextColor(tft.color565(224,225,232));
tft.drawFloat(pressure,2 , 140, 135);
tft.setTextColor(TFT_GREEN);
tft.drawFloat(humidity,2 , 140, 195);

tft.drawString("℃", 210, 75);
tft.drawString("KPa",210, 135);
tft.drawString("%",210, 195);
}

void getLastData() {
// Serial.println("\nStarting connection to server...");
if (!client.connect(server, 9000)) {
// Serial.println("Connection failed!");
tft.fillScreen(TFT_BLACK);
tft.setCursor((320 - tft.textWidth("Connection failed!"))/2, 120);
tft.print("Connection failed!");
} else {
// Serial.println("Connected to server!");

// Make a HTTP request:
String postRequest =(String)("GET ") + "/ HTTP/1.1\r\n" + "Connection: close\r\n\r\n";
// Serial.println(postRequest);
client.print(postRequest);

while (client.connected()) {
String line = client.readStringUntil('\n');
if (line == "\r") {
// Serial.println("headers received");
break;
}
}

while(client.available())
{
String line = client.readStringUntil('\r');
data = line;
}
// Serial.println(data);
client.stop();
// Serial.println("closing connection");
}

//ArduinoJson to parse data, plesae check ArduinoJson for more info
const size_t capacity = JSON_OBJECT_SIZE(5) + 100;
DynamicJsonDocument doc(capacity);
deserializeJson(doc, data);

float humidity = doc["humidity"];
float gas = doc["gas"];
String updataTime = doc["updataTime"];

// -----------------LCD---------------------
tft.setFreeFont(FF17);
tft.setTextColor(tft.color565(224,225,232));
tft.drawString("Current Data At Home",20,10);

tft.fillRoundRect(10, 45, 300, 55, 5, tft.color565(40,40,86));
tft.fillRoundRect(10, 105, 300, 55, 5, tft.color565(40,40,86));
tft.fillRoundRect(10, 165, 300, 55, 5, tft.color565(40,40,86));

tft.setFreeFont(FM9);
tft.drawString("humidity:", 75, 50);
tft.drawString("gas:",75, 110);
tft.drawString("updataTime:",75, 170);

tft.setFreeFont(FMB12);
tft.setTextColor(TFT_RED);
tft.drawFloat(humidity,2 , 140, 75);
tft.setTextColor(tft.color565(224,225,232));
tft.drawFloat(gas,2 , 140, 135);
tft.setTextColor(TFT_GREEN);
tft.drawString(updataTime , 30, 195);

tft.drawString("%", 210, 75);
tft.drawString("Kohms",210, 135);
}
上傳成功后,打開串口監視器:

poYBAGKN4qmALf4mAADgyYiXGjg451.png

接下來我們來看看Python的具體實現

使用Python讀取串口數據并做出相應決策

web端增加了保存數據的功能

因為我需要發送郵件,所以我先將傳感器接收到的數據存儲在一個TXT文本文件中。發送郵件時,我可以直接發送這個文本文件

在視圖中在 py 中:

def index(request):
datas = getDatas()
content = {
'temperature':datas[0],
'pressure':datas[1],
'humidity':datas[2],
'gas':datas[3],
'updataTime':datas[4],
}
jsonData = json.dumps(content)
with open("D:\TemperatureHumidityPressureGasData.txt", "w") as fp:
fp.write(jsonData)
return HttpResponse(jsonData)

主要變化是:

with open("D:\TemperatureHumidityPressureGasData.txt", "w") as fp:
fp.write(jsonData)

文件存放路徑可以修改為自己的路徑

打開文本文件,看能否保存成功:

pYYBAGKN4r6AOnsFAAEt5HIlL-k222.png

通過紅外模塊控制小夜燈

小夜燈可以遙控控制:

poYBAGKN4sqARfrEAAOws0frMfM193.png

因為WIO終端沒有紅外解碼功能,所以我又買了一個紅外模塊,編解碼合二為一。當然,我還需要一個usb-ttl串口轉換器

pYYBAGKN4tmAbygHAAbiumIPfwc284.png

其實這個想法很簡單。讀取遙控器對應按鍵發送的數據,然后用紅外模塊發送出去

可以使用串口調試助手進行解碼,更方便:

poYBAGKN4uSAJYNHAALDFzPZQF0259.png

串行端口發送它接收到的任何內容。收貨時最好找個比較暗的地方多試幾次

以下是我收集的每個密鑰應該發送的數據(十六進制):

開燈

send_data = 'FD FD 30 03 53 4B 00 34 17 01 3B 02 65 00 26 00 1E 00 27 00 D9 09 26 00 8A 00 40 02 C3 17 26 00 00 00 21 00 FF FF FF FF 01 22 22 22 22 11 11 11 11 12 11 22 22 21 22 11 13 45 46 F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 76 00 22 DF DF'

提亮

send_data = 'FD FD 30 03 52 47 00 34 16 01 3A 02 66 00 27 00 20 00 27 00 D9 09 25 00 8A 00 41 02 00 00 21 00 FF FF FF FF FF FF FF FF 01 22 22 22 22 11 11 11 12 21 11 22 21 12 22 11 13 45 F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 76 3F 6D DF DF '

調光

send_data = 'FD FD 30 03 53 4B 00 34 16 01 3C 02 63 00 27 00 1F 00 27 00 DA 09 25 00 8B 00 3D 02 C4 17 24 00 00 00 20 00 FF FF FF FF 01 22 22 22 22 11 11 11 12 11 11 22 21 22 22 11 13 45 46 F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 76 3F 2E DF DF '

要發送紅外線,只需再添加兩行:

send_data = bytes.fromhex(send_data) #先編碼,再發送
infrared_ser.write(send_data)

通過語音控制PC發送郵件

語音不是真正的語音識別。當WIO終端識別到環境音頻信號有波動時,會發送“send message!” 到串口,PC讀取后發送郵件

說話時,音頻信號會有明顯的波動:

pYYBAGKN4vKAMuuEAAFJhWmgS7Y444.png

發送電子郵件并不難。我把它封裝成一個方法,當時可以直接調用

import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.header import Header

def send():
# 第三方 SMTP 服務
mail_host="smtp.qq.com" #設置服務器
mail_user="" #用戶名
mail_pass="" #口令

sender = ''
receivers = [''] # 接收郵件,可設置為你的QQ郵箱或者其他郵箱

#創建一個帶附件的實例
message = MIMEMultipart()
message['From'] = Header("Wio Terimal", 'utf-8')
message['To'] = Header("溫濕度、大氣壓力、可燃氣體檢測數據", 'utf-8')
subject = '當前溫濕度、大氣壓力、可燃氣體檢測數據'
message['Subject'] = Header(subject, 'utf-8')

#郵件正文內容
message.attach(MIMEText('溫濕度、大氣壓力、可燃氣體檢測數據', 'plain', 'utf-8'))

# 構造附件,傳送當前目錄下的 test.txt 文件
att = MIMEText(open('D:\TemperatureHumidityPressureGasData.txt', 'rb').read(), 'base64', 'utf-8')
att["Content-Type"] = 'application/octet-stream'
# 這里的filename可以任意寫,寫什么名字,郵件中顯示什么名字
att["Content-Disposition"] = 'attachment; filename="TemperatureHumidityPressureGasData.txt"'
message.attach(att)
server = smtplib.SMTP_SSL(mail_host, 465) # SMTP協議默認端口是25
server.set_debuglevel(1)
server.login(mail_user, mail_pass)

try:
server.sendmail(sender, receivers, message.as_string())
print ("郵件發送成功")
except smtplib.SMTPException:
print ("Error: 無法發送郵件")

此處的發送者和接收者可以編寫自己的電子郵件。嘗試發送電子郵件進行測試:

poYBAGKN4wGAOn_eAAIfd-d6XbI887.png

預覽此 TXT 文件:

pYYBAGKN4w-ABPzXAAGDqeQjwBc677.png

通過語音合成回復用戶

Windows系統下,可以直接調用系統的語音包:

import win32com.client

speaker = win32com.client.Dispatch("SAPI.SpVoice")
text = "輸入要語音合成的內容"
speaker.Speak(text)

完整的程序

代碼中的串口需要改成自己的串口:

pYYBAGKN4xuAd5X-AAGpKmRzoXk318.png

Com14是WIO終端開發板

Com15是紅外模塊

Com19是seeeduino v4 2開發板

每次插上后,可能會因為電腦上的USB接口不夠,導致串口發生變化。我買了一個 USB 擴展塢

import serial
import re

import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.header import Header

import win32com.client

speaker = win32com.client.Dispatch("SAPI.SpVoice")

def send():
# 第三方 SMTP 服務
mail_host="smtp.qq.com" #設置服務器
mail_user="2733821739@qq.com" #用戶名
mail_pass="" #口令

sender = '2733821739@qq.com'
receivers = ['2733821739@qq.com'] # 接收郵件,可設置為你的QQ郵箱或者其他郵箱

#創建一個帶附件的實例
message = MIMEMultipart()
message['From'] = Header("Wio Terimal", 'utf-8')
message['To'] = Header("溫濕度、大氣壓力、可燃氣體檢測數據", 'utf-8')
subject = '當前溫濕度、大氣壓力、可燃氣體檢測數據'
message['Subject'] = Header(subject, 'utf-8')

#郵件正文內容
message.attach(MIMEText('溫濕度、大氣壓力、可燃氣體檢測數據', 'plain', 'utf-8'))

# 構造附件,傳送當前目錄下的 test.txt 文件
att = MIMEText(open('D:\TemperatureHumidityPressureGasData.txt', 'rb').read(), 'base64', 'utf-8')
att["Content-Type"] = 'application/octet-stream'
# 這里的filename可以任意寫,寫什么名字,郵件中顯示什么名字
att["Content-Disposition"] = 'attachment; filename="TemperatureHumidityPressureGasData.txt"'
message.attach(att)
server = smtplib.SMTP_SSL(mail_host, 465) # SMTP協議默認端口是25
server.set_debuglevel(1)
server.login(mail_user, mail_pass)

try:
server.sendmail(sender, receivers, message.as_string())
print ("郵件發送成功")
speaker = win32com.client.Dispatch("SAPI.SpVoice")
text = "Message sent successfully"
speaker.Speak(text)
except smtplib.SMTPException:
print ("Error: 無法發送郵件")


infrared_ser = serial.Serial('COM10', 9600, timeout=0.2)
Wio_terminal = serial.Serial('COM14', 115200, timeout=0.2)

# 接收返回的信息
while True:
strs = Wio_terminal.readline().decode('utf-8')
if strs.strip()!='':
print(strs)
if (re.match(r"C",strs)):
send_data = 'FD FD 30 03 53 4B 00 34 17 01 3B 02 65 00 26 00 1E 00 27 00 D9 09 26 00 8A 00 40 02 C3 17 26 00 00 00 21 00 FF FF FF FF 01 22 22 22 22 11 11 11 11 12 11 22 22 21 22 11 13 45 46 F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 76 00 22 DF DF'
send_data = bytes.fromhex(send_data)
infrared_ser.write(send_data)
text = "OK executed"
speaker.Speak(text)
elif (re.match(r"B",strs)):
send_data = 'FD FD 30 03 52 47 00 34 16 01 3A 02 66 00 27 00 20 00 27 00 D9 09 25 00 8A 00 41 02 00 00 21 00 FF FF FF FF FF FF FF FF 01 22 22 22 22 11 11 11 12 21 11 22 21 12 22 11 13 45 F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 76 3F 6D DF DF '
send_data = bytes.fromhex(send_data)
infrared_ser.write(send_data)
text = "Brightness up"
speaker.Speak(text)
elif (re.match(r"A",strs)):
send_data = 'FD FD 30 03 53 4B 00 34 16 01 3C 02 63 00 27 00 1F 00 27 00 DA 09 25 00 8B 00 3D 02 C4 17 24 00 00 00 20 00 FF FF FF FF 01 22 22 22 22 11 11 11 12 11 11 22 21 22 22 11 13 45 46 F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 76 3F 2E DF DF '
send_data = bytes.fromhex(send_data)
infrared_ser.write(send_data)
text = "Brightness down"
speaker.Speak(text)
elif (re.match(r"send",strs)):
try:
send()
except:
text = "Failed to send mail. Please try again later"
speaker.Speak(text)


infrared_ser.close()
Wio_terminal.close()

未來的想法

目前的系統只是一個非常簡單的第一代版本。往后我們可能會考慮使用云平臺存儲傳感器采集的溫度、濕度、光照強度、紫外線強度等數據,制作一個APP,讓用戶出門在外就可以知道家里的情況。

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • 智能家居
    +關注

    關注

    1914

    文章

    9166

    瀏覽量

    179652
  • python
    +關注

    關注

    52

    文章

    4686

    瀏覽量

    83515
收藏 人收藏

    評論

    相關推薦

    BME680環境傳感器的驅動設計與實現

    環境傳感器是一類我們很常用的傳感器。它可以方便我們獲取壓力、溫度、濕度以及空氣質量等數據。在這一篇中,我們將分析BME680環境傳感器的功能,并設計和實現BME680環境傳感器的驅動。
    發表于 12-08 15:41 ?1822次閱讀
    <b class='flag-5'>BME680</b>環境傳感器的驅動設計與<b class='flag-5'>實現</b>

    【開源】基于stm32的智能家居控制中心

    ` 本帖最后由 shaw.wang 于 2015-5-8 10:16 編輯 基于stm32和W5500的智能家居控制中心 HIKIT SC1是一款極具性價比的開發板,同時又是具備可擴展性
    發表于 05-07 16:22

    【EVB-335X-II申請】智能家居控制中心

    申請理由:本人從業于智能家居嵌入式開發,一直以來使用TI的產品開發BLE/ZIGBEE/WIFI等。之前智能控制中心方案是MSP430+ZIGBEE+BLUETOOTH+WIFI+LCD,但
    發表于 10-21 09:21

    BME680的參數資料

    產品技術參數資料Datasheet法例與合規 符合 符合聲明產品詳細信息BME680 是集成環境傳感器,專門開發用于尺寸和低功耗為關鍵要求的移動應用和可穿戴產品。BME680 擴大 Bosch
    發表于 04-23 11:20

    STM32移植BME680傳感器輸出IAQ相關資料分享

    STM32移植BME680傳感器輸出IAQ(室內空氣質量)1.準備材料軟件: stm32cubemx 、IAR for arm、jlink(或者stlink)驅動(已安裝請忽略)、任意的串口調試助手
    發表于 07-01 06:52

    如何利用stm32的HAL庫實現BME680傳感器輸出IAQ?

    如何利用stm32的HAL庫實現BME680傳感器輸出IAQ?為什么使用IAR而不使用stm32開發常用的keil呢?
    發表于 10-22 09:15

    NodeMCU的wifi模塊與BME680環境監測模塊搭配有何作用

    使用NodeMCU的ESP-12型號wifi模塊搭配BME680環境監測模塊測量溫度、濕度、氣壓,同時在web端實時顯示檢測到的數據。所需要的器件,及web端效果圖如下:1.所需要的元器件的接線圖
    發表于 02-10 06:35

    為LED的Do Electronics GT倡議而打造的BME680模塊

    描述這是為 LED 的 Do Electronics GT 倡議而打造的 BME680 模塊,讓危地馬拉的年輕人喚醒了開發低成本電子設備的興趣。代碼https://github.com/teslalab/BME680
    發表于 07-28 06:33

    什么才能算是智能家居真正的控制中心?

    德州儀器個人電子產品系統終端設備負責人隨著智能家居的普及,現在我們有越來越多的房間都安裝了配備有人工智能功能的智能音箱,它們的功能也基本上大同小異。但什么才能算是智能家居真正的
    發表于 11-09 07:14

    使用iic與bme680通信,Bme680數據讀取不到是為什么

    使用iic與bme680通信,芯片的CHIP—ID都已經能夠讀取到了,但是讀取不到溫濕度和壓力的數據?
    發表于 08-04 16:51

    基于BME680和Raspberry Pi Pico的氣象站

    電子發燒友網站提供《基于BME680和Raspberry Pi Pico的氣象站.zip》資料免費下載
    發表于 07-18 15:12 ?1次下載
    基于<b class='flag-5'>BME680</b>和Raspberry Pi Pico的氣象站

    BME680天氣監測裝置開源分享

    電子發燒友網站提供《BME680天氣監測裝置開源分享.zip》資料免費下載
    發表于 07-21 11:59 ?4次下載
    <b class='flag-5'>BME680</b>天氣監測裝置開源分享

    基于BME680的室內空氣質量計

    在本方案中,我們將介紹如何在房間內制作一個非常簡單的空氣質量計。為此,我們使用包含 Bosch Sensortec 的 BME680 芯片的 GY-MCU680V1 傳感器。BME680 是一種
    發表于 12-21 12:20 ?0次下載

    基于BME680的天氣監測裝置

    方案介紹天氣監測裝置BME680BME680 是第一款集成高線性度和高精度氣體、壓力、濕度和溫度傳感器的氣體傳感器。它專為移動應用和可穿戴設備而開發,其中尺寸和低功耗是關鍵要求。BME680 保證
    發表于 12-26 16:06 ?0次下載

    基于BME680的天氣監測裝置

    方案介紹BME680BME680 是第一款集成高線性度和高精度氣體、壓力、濕度和溫度傳感器的氣體傳感器。它專為移動應用和可穿戴設備而開發,其中尺寸和低功耗是關鍵要求。BME680 保證 - 根據特定
    發表于 12-27 16:41 ?0次下載
    亚洲欧美日韩精品久久_久久精品AⅤ无码中文_日本中文字幕有码在线播放_亚洲视频高清不卡在线观看
    <acronym id="s8ci2"><small id="s8ci2"></small></acronym>
    <rt id="s8ci2"></rt><rt id="s8ci2"><optgroup id="s8ci2"></optgroup></rt>
    <acronym id="s8ci2"></acronym>
    <acronym id="s8ci2"><center id="s8ci2"></center></acronym>