描述
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt">1、项目功能介绍</h3>
<p></p><hr class="horizontal-splitline normal-bold-2"><p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt"> 本项目采用启英泰伦离线语音模组和ESP8266模组制作,能够作为桌面语音小助手,实时控制RGB灯、台灯、风扇,并且能够显示温湿度。</p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt">2、项目属性</h3>
<p></p><hr class="horizontal-splitline normal-bold-2"><p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt"> 本项目包括电源电路,显示电路,复位电路,传感器电路等。其中RGB灯由启英泰伦离线语音模组直接控制,其他传感器及其小设备由ESP8266控制,ESP8266与语音模组通过串口连接,ESP8266被语音模组控制。</p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt">3、开源协议</h3>
<p></p><hr class="horizontal-splitline normal-bold-2"><p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt">GPL3.0</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt">4、硬件部分</h3>
<p></p><hr class="horizontal-splitline normal-bold-2"><p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt">原理图</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt"><img src="//image.lceda.cn/pullimage/H5sljLvyLmmnYyvrLWGWhImqbxYjvknluhYWAeRQ.png" alt="" width="1110" height="685"></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt">PCB</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt"><img src="//image.lceda.cn/pullimage/qcRW4fQ3szL9114HkZDaozsRspchsJdOOn0wgCIL.png" alt="" width="710" height="412"></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt">5、软件部分</h3>
<p></p><hr class="horizontal-splitline normal-bold-2"><p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt">启英泰伦语音模组采用eclipse开发,部分代码如图所示:</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em"><img src="//image.lceda.cn/pullimage/0IoHAAvIzcq0aujZmbOJiucCxlQBO7dUfM0uiZBG.png" alt="" width="981" height="322"></p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt"><img src="//image.lceda.cn/pullimage/46vnWsJ5O13rNVjlJ8g4cQxd527QKsfNUGQL0xEQ.png" alt="" width="875" height="720"></h3>
<p>ESP8266由arduino开发源码如下:</p>
<p><span style="background-color:#f8cac6;">#include <Arduino.h></span><br><span style="background-color:#f8cac6;">#include <U8g2lib.h></span><br><span style="background-color:#f8cac6;">#include <Wire.h></span><br><span style="background-color:#f8cac6;">#include<SimpleDHT.h></span><br><span style="background-color:#f8cac6;">U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0,14,2,U8X8_PIN_NONE);</span><br><span style="background-color:#f8cac6;">int pinDHT11=4;</span><br><span style="background-color:#f8cac6;">int led1=15;</span><br><span style="background-color:#f8cac6;">int led2=12;</span><br><span style="background-color:#f8cac6;">int led3=13;</span><br><span style="background-color:#f8cac6;">int m=5;</span><br><span style="background-color:#f8cac6;">SimpleDHT11 dht11(pinDHT11);</span></p>
<p><br><span style="background-color:#f8cac6;">void setup() {</span><br><span style="background-color:#f8cac6;"> // put your setup code here, to run once:</span><br><span style="background-color:#f8cac6;"> pinMode(led1,OUTPUT);</span><br><span style="background-color:#f8cac6;"> pinMode(led2,OUTPUT);</span><br><span style="background-color:#f8cac6;"> pinMode(led3,OUTPUT);</span><br><span style="background-color:#f8cac6;"> pinMode(m,OUTPUT);</span><br><span style="background-color:#f8cac6;"> digitalWrite(m,0);</span><br><span style="background-color:#f8cac6;"> digitalWrite(led1,0);</span><br><span style="background-color:#f8cac6;"> digitalWrite(led2,0);</span><br><span style="background-color:#f8cac6;"> digitalWrite(led3,0);</span><br><span style="background-color:#f8cac6;"> Serial.begin(115200);</span><br><span style="background-color:#f8cac6;"> u8g2.begin();</span><br><span style="background-color:#f8cac6;"> u8g2.enableUTF8Print();</span><br><span style="background-color:#f8cac6;">}</span><br><span style="background-color:#f8cac6;">int a=0;</span><br><span style="background-color:#f8cac6;">void loop() {</span><br><span style="background-color:#f8cac6;"> // put your main code here, to run repeatedly:</span><br><span style="background-color:#f8cac6;"> </span><br><span style="background-color:#f8cac6;"> if(Serial.available())</span><br><span style="background-color:#f8cac6;"> {</span><br><span style="background-color:#f8cac6;"> a=Serial.read();</span><br><span style="background-color:#f8cac6;"> switch(a)</span><br><span style="background-color:#f8cac6;"> {</span><br><span style="background-color:#f8cac6;"> case 65://打开台灯</span><br><span style="background-color:#f8cac6;"> {</span><br><span style="background-color:#f8cac6;"> digitalWrite(led1,1);</span><br><span style="background-color:#f8cac6;"> digitalWrite(led2,1);</span><br><span style="background-color:#f8cac6;"> digitalWrite(led3,0);</span><br><span style="background-color:#f8cac6;"> break;</span><br><span style="background-color:#f8cac6;"> }</span><br><span style="background-color:#f8cac6;"> </span><br><span style="background-color:#f8cac6;"> case 66://关闭台灯</span><br><span style="background-color:#f8cac6;"> {</span><br><span style="background-color:#f8cac6;"> digitalWrite(led1,0);</span><br><span style="background-color:#f8cac6;"> digitalWrite(led2,0);</span><br><span style="background-color:#f8cac6;"> digitalWrite(led3,0);</span><br><span style="background-color:#f8cac6;"> break; </span><br><span style="background-color:#f8cac6;"> } </span><br><span style="background-color:#f8cac6;"> </span><br><span style="background-color:#f8cac6;"> case 67://亮度加</span><br><span style="background-color:#f8cac6;"> {</span><br><span style="background-color:#f8cac6;"> digitalWrite(led1,1);</span><br><span style="background-color:#f8cac6;"> digitalWrite(led2,1);</span><br><span style="background-color:#f8cac6;"> digitalWrite(led3,1);</span><br><span style="background-color:#f8cac6;"> break; </span><br><span style="background-color:#f8cac6;"> } </span><br><span style="background-color:#f8cac6;"> </span><br><span style="background-color:#f8cac6;"> case 68://亮度减</span><br><span style="background-color:#f8cac6;"> {</span><br><span style="background-color:#f8cac6;"> digitalWrite(led1,1);</span><br><span style="background-color:#f8cac6;"> digitalWrite(led2,0);</span><br><span style="background-color:#f8cac6;"> digitalWrite(led3,0);</span><br><span style="background-color:#f8cac6;"> break; </span><br><span style="background-color:#f8cac6;"> } </span><br><span style="background-color:#f8cac6;"> </span><br><span style="background-color:#f8cac6;"> case 69://打开风扇</span><br><span style="background-color:#f8cac6;"> {</span><br><span style="background-color:#f8cac6;"> digitalWrite(m,1);</span><br><span style="background-color:#f8cac6;"> break; </span><br><span style="background-color:#f8cac6;"> } </span><br><span style="background-color:#f8cac6;"> </span><br><span style="background-color:#f8cac6;"> case 70://关闭风扇</span><br><span style="background-color:#f8cac6;"> {</span><br><span style="background-color:#f8cac6;"> digitalWrite(m,0);</span><br><span style="background-color:#f8cac6;"> break; </span><br><span style="background-color:#f8cac6;"> } </span><br><span style="background-color:#f8cac6;"> </span><br><span style="background-color:#f8cac6;"> case 71://显示温度</span><br><span style="background-color:#f8cac6;"> {</span><br><span style="background-color:#f8cac6;"> byte temperature=0;</span><br><span style="background-color:#f8cac6;"> byte humidity=0;</span><br><span style="background-color:#f8cac6;"> dht11.read(&temperature, &humidity, NULL);</span><br><span style="background-color:#f8cac6;"> u8g2.setFont(u8g2_font_unifont_t_chinese2); //设置字体</span><br><span style="background-color:#f8cac6;"> u8g2.firstPage();</span><br><span style="background-color:#f8cac6;"> do {</span><br><span style="background-color:#f8cac6;"> u8g2.setCursor(0,20);</span><br><span style="background-color:#f8cac6;"> u8g2.print("temperature:"); // Chinese "Hello World" </span><br><span style="background-color:#f8cac6;"> u8g2.print(int(temperature));</span><br><span style="background-color:#f8cac6;"> } while ( u8g2.nextPage() );</span><br><span style="background-color:#f8cac6;"> break; </span><br><span style="background-color:#f8cac6;"> } </span><br><span style="background-color:#f8cac6;"> </span><br><span style="background-color:#f8cac6;"> case 72://显示湿度</span><br><span style="background-color:#f8cac6;"> {</span><br><span style="background-color:#f8cac6;"> byte temperature=0;</span><br><span style="background-color:#f8cac6;"> byte humidity=0;</span><br><span style="background-color:#f8cac6;"> dht11.read(&temperature, &humidity, NULL);</span><br><span style="background-color:#f8cac6;"> u8g2.setFont(u8g2_font_unifont_t_chinese2); //设置字体</span><br><span style="background-color:#f8cac6;"> u8g2.firstPage();</span><br><span style="background-color:#f8cac6;"> do {</span><br><span style="background-color:#f8cac6;"> u8g2.setCursor(0,20);</span><br><span style="background-color:#f8cac6;"> u8g2.print("temperature:"); // Chinese "Hello World" </span><br><span style="background-color:#f8cac6;"> u8g2.print(int(temperature));</span><br><span style="background-color:#f8cac6;"> u8g2.setCursor(0,40);</span><br><span style="background-color:#f8cac6;"> u8g2.print("humidity:"); // Chinese "Hello World"</span><br><span style="background-color:#f8cac6;"> u8g2.print(int(humidity));</span><br><span style="background-color:#f8cac6;"> u8g2.print("%");</span><br><span style="background-color:#f8cac6;"> } while ( u8g2.nextPage() );</span><br><span style="background-color:#f8cac6;"> break; </span><br><span style="background-color:#f8cac6;"> } </span><br><span style="background-color:#f8cac6;"> </span><br><span style="background-color:#f8cac6;"> case 75://关闭显示</span><br><span style="background-color:#f8cac6;"> {</span><br><span style="background-color:#f8cac6;"> u8g2.clear();</span><br><span style="background-color:#f8cac6;"> break; </span><br><span style="background-color:#f8cac6;"> } </span><br><span style="background-color:#f8cac6;"> }</span><br><span style="background-color:#f8cac6;"> }</span><br><span style="background-color:#f8cac6;">}</span></p>
评论(0)