本例实验采用板载三位独立按键,可以搭配实现各种相关的功能。
本例实验的SPI彩色液晶1.77寸显示屏(ST7735驱动)
TFT177-SPI,型号为SX177QQVGA,像素128X160TFT,驱动芯片为ST7735S,这是一款支持SPI接口的1.77寸TFT彩屏,可以显示文字、图形、图片等内容,提高用户互动体验度。
电原理图
本例实验采用DHT11
是一款含有已校准数字信号输出的温湿度复合传感器。它应用专用的数字模块采集技术和温湿度传感技术,确保产品具有极高的可靠性与卓越的长期稳定性。传感器包括一个电阻式感湿元件和一个NTC测温元件,并与一个高性能8位单片机相连接。因此该产品具有品质卓越、超快响应、抗干扰能力强、性价比极高等优点。每个DHT11传感器都在极为精确的湿度校验室中进行校准。校准系数以程序的形式储存在OTP内存中,传感器内部在检测信号的处理过程中要调用这些校准系数。单线制串行接口,使系统集成变得简易快捷。超小的体积、极低的功耗,信号传输距离可达20米以上,使其成为各类应用甚至最为苛刻的应用场合的最佳选则。产品为4针单排引脚封装。连接方便,特殊封装形式可根据用户需求而提供。
电原理图
【花雕动手做】实验二十五:使用按键和语音控制显示DHT11温度与湿度
实验开源代码
#define ASC2_12
#define ST7735_CS_PIN 9
#define ST7735_CS_GPIO_PIN gpio_pin_1
#define ST7735_DC_PIN 1
#define ST7735_DC_GPIO_PIN gpio_pin_1
#define ST7735_RST_PIN 25
#define ST7735_RST_GPIO_PIN gpio_pin_1
#define ST7735_SCK_PIN 3
#define ST7735_SCK_GPIO_PIN gpio_pin_3
#define ST7735_MOSI_PIN 2
#define ST7735_MOSI_GPIO_PIN gpio_pin_2
#define ASC2_32
#define ST7735S_RGB_GBR_ORDER 0
#define ASC2_16
#include "asr.h"
extern "C"{ void * __dso_handle = 0 ;}
#include "setup.h"
#include "myLib/asr_st7735.h"
#include "myLib/asr_event.h"
#include "myLib/asr_dhtxx.h"
uint32_t snid;
uint8_t wen;
uint8_t shi;
void pins_attached();
void hardware_init();
SPITFT spi_tft(128, 160);
//{ID:250,keyword:"命令词",ASR:"最大音量",ASRTO:"音量调整到最大"}
//{ID:251,keyword:"命令词",ASR:"中等音量",ASRTO:"音量调整到中等"}
//{ID:252,keyword:"命令词",ASR:"最小音量",ASRTO:"音量调整到最小"}
DHTxx asr_dht_7(7, DHT11);
void pins_attached(){
while (1) {
if((digital_read((18)) == 0)){
digital_write((21),1);
delay(200);
enter_wakeup(5000);
delay(200);
//{ID:500,keyword:"命令词",ASR:"耍接官",ASRTO:"按键模式读取温度"}
play_audio(500);
spi_tft.clear((0x8FFF));
spi_tft.set_text_color((0x001F),(0x8FFF));
spi_tft.set_cursor(30,50);
spi_tft.draw_hanzi_16("当前温度");
delay(1000);
wen = asr_dht_7.read_temperature(0);
spi_tft.set_cursor(55,80);
spi_tft.set_text_size(16);
spi_tft.println((String(wen)));
//{ID:501,keyword:"命令词",ASR:"接耍官",ASRTO:"当前温度为摄氏"}
play_audio(501);
play_num((int64_t)(wen * 100), 1);
//{ID:502,keyword:"命令词",ASR:"官耍接",ASRTO:"度"}
play_audio(502);
}
if((digital_read((4)) == 0)){
digital_write((21),1);
delay(200);
enter_wakeup(5000);
delay(200);
//{ID:503,keyword:"命令词",ASR:"丝耍接",ASRTO:"按键模式读取湿度"}
play_audio(503);
spi_tft.clear((0x8FFF));
spi_tft.set_text_color((0xF800),(0x8FFF));
spi_tft.set_cursor(30,50);
spi_tft.draw_hanzi_16("当前湿度");
delay(1000);
shi = asr_dht_7.read_temperature(1);
spi_tft.set_cursor(55,80);
spi_tft.set_text_size(16);
spi_tft.println((String(shi)));
//{ID:504,keyword:"命令词",ASR:"粮耍接",ASRTO:"当前湿度为百分之"}
play_audio(504);
play_num((int64_t)(shi * 100), 1);
}
delay(1);
}
vTaskDelete(NULL);
}
void ASR_CODE()
{
//{ID:505,keyword:"命令词",ASR:"这个有用",ASRTO:"谢谢鼓励,给你了"}
if(snid == 505){
}
//{ID:506,keyword:"唤醒词",ASR:"智能管家",ASRTO:"我在"}
if(snid == 506){
digital_write((21),1);
spi_tft.clear((0xFFFF));
}
//{ID:507,keyword:"命令词",ASR:"当前温度",ASRTO:""}
if(snid == 507){
spi_tft.clear((0x001F));
spi_tft.set_text_color((0xFFFF),(0x001F));
spi_tft.set_cursor(30,50);
spi_tft.draw_hanzi_16("当前温度");
delay(1000);
wen = asr_dht_7.read_temperature(0);
spi_tft.set_cursor(55,80);
spi_tft.set_text_size(16);
spi_tft.println((String(wen)));
//{ID:508,keyword:"命令词",ASR:"菌耍接",ASRTO:"当前温度为摄氏"}
play_audio(508);
play_num((int64_t)(wen * 100), 1);
//{ID:509,keyword:"命令词",ASR:"纯耍接",ASRTO:"度"}
play_audio(509);
}
//{ID:510,keyword:"命令词",ASR:"当前湿度",ASRTO:""}
if(snid == 510){
spi_tft.clear((0xF800));
spi_tft.set_text_color((0xFFFF),(0xF800));
spi_tft.set_cursor(30,50);
spi_tft.draw_hanzi_16("当前湿度");
delay(1000);
shi = asr_dht_7.read_temperature(1);
spi_tft.set_cursor(55,80);
spi_tft.set_text_size(16);
spi_tft.println((String(shi)));
//{ID:511,keyword:"命令词",ASR:"趣耍接",ASRTO:"当前湿度为百分之"}
play_audio(511);
play_num((int64_t)(shi * 100), 1);
}
//{ID:512,keyword:"命令词",ASR:"同时读取",ASRTO:""}
if(snid == 512){
spi_tft.clear((0xFFFF));
spi_tft.set_text_color((0x001F),(0xFFFF));
spi_tft.set_cursor(30,30);
spi_tft.draw_hanzi_16("当前温度");
delay(1000);
wen = asr_dht_7.read_temperature(0);
spi_tft.set_cursor(55,60);
spi_tft.set_text_size(16);
spi_tft.println((String(wen)));
//{ID:513,keyword:"命令词",ASR:"暖耍接",ASRTO:"当前温度为摄氏"}
play_audio(513);
play_num((int64_t)(wen * 100), 1);
//{ID:514,keyword:"命令词",ASR:"猛耍接",ASRTO:"度"}
play_audio(514);
delay(2000);
spi_tft.set_text_color((0xF800),(0xFFFF));
spi_tft.set_cursor(30,90);
spi_tft.draw_hanzi_16("当前湿度");
delay(1000);
shi = asr_dht_7.read_temperature(1);
spi_tft.set_cursor(55,120);
spi_tft.set_text_size(16);
spi_tft.println((String(shi)));
//{ID:515,keyword:"命令词",ASR:"耍官接",ASRTO:"当前湿度为百分之"}
play_audio(515);
play_num((int64_t)(shi * 100), 1);
}
}
void hardware_init(){
spi_tft.init();
spi_tft.set_direction(2);
spi_tft.set_text_wrap(true);
spi_tft.set_text_size(32);
spi_tft.set_bg_mode(1);
xTaskCreate(pins_attached,"pins_attached",256,NULL,4,NULL);
vTaskDelete(NULL);
}
void setup()
{
//{speak:小伦-放松,vol:20,speed:10,platform:haohaodada,version:V3}
//{playid:10001,voice:欢迎使用人工智能AI语音助手,用智能管家唤醒我}
//{playid:10002,voice:我退下了,用智能管家唤醒我}
asr_dht_7.init();
digital_write((4),1);
digital_write((21),0);
digital_write((19),1);
//{ID:84,keyword:"命令词",ASR:"条耍改",ASRTO:"零"}
//{ID:85,keyword:"命令词",ASR:"官接思",ASRTO:"一"}
//{ID:86,keyword:"命令词",ASR:"痛官松",ASRTO:"二"}
//{ID:87,keyword:"命令词",ASR:"削丝误",ASRTO:"三"}
//{ID:88,keyword:"命令词",ASR:"景粮载",ASRTO:"四"}
//{ID:89,keyword:"命令词",ASR:"博菌避",ASRTO:"五"}
//{ID:90,keyword:"命令词",ASR:"裁纯碉",ASRTO:"六"}
//{ID:91,keyword:"命令词",ASR:"插趣悟",ASRTO:"七"}
//{ID:92,keyword:"命令词",ASR:"辞暖慌",ASRTO:"八"}
//{ID:93,keyword:"命令词",ASR:"纵猛淡",ASRTO:"九"}
//{ID:94,keyword:"命令词",ASR:"锦耗暂",ASRTO:"十"}
//{ID:95,keyword:"命令词",ASR:"燃智截",ASRTO:"百"}
//{ID:96,keyword:"命令词",ASR:"佛驻延",ASRTO:"千"}
//{ID:97,keyword:"命令词",ASR:"隔枪绍",ASRTO:"万"}
//{ID:98,keyword:"命令词",ASR:"惨愤昂",ASRTO:"亿"}
//{ID:99,keyword:"命令词",ASR:"丙迈扯",ASRTO:"负"}
//{ID:100,keyword:"命令词",ASR:"铸猜隆",ASRTO:"点"}
set_gpio_input((18));
set_gpio_input((4));
xTaskCreate(hardware_init,"hardware_init",256,NULL,100,NULL);
}
训练模型与编译烧录
实验记录视频
实验二十五:使用按键和语音控制显示DHT11温度与湿度
附录系列实验:
【花雕动手做】ASRPRO-Plus语音识别(01)—开发板三种开发环境的搭建
https://blog.csdn.net/weixin_41659040/article/details/133909855
【花雕动手做】ASRPRO-Plus语音识别(02)—核心芯片、参数与电原理图
https://blog.csdn.net/weixin_41659040/article/details/133900928
【花雕动手做】ASRPRO-Plus语音识别(03)—板载硬件和12项应用功能
https://blog.csdn.net/weixin_41659040/article/details/133970323
【花雕动手做】ASRPRO-Plus语音识别(04)—控制点亮与闪烁板载LED
https://blog.csdn.net/weixin_41659040/article/details/134020401
【花雕动手做】ASRPRO-Plus语音识别(05)—WS2812B的点亮和变色
https://blog.csdn.net/weixin_41659040/article/details/134185082
【花雕动手做】ASRPRO-Plus语音识别(06)—点亮TM1650四位数码管
https://blog.csdn.net/weixin_41659040/article/details/134207483
【花雕动手做】ASRPRO-Plus语音识别(06)—会数数的语音控制数码管
https://blog.csdn.net/weixin_41659040/article/details/134214086
【花雕动手做】ASRPRO-Plus语音识别(07)—点亮ST7735的1.77TFT彩屏
https://blog.csdn.net/weixin_41659040/article/details/134308542
【花雕动手做】ASRPRO-Plus语音识别(08)— PT0603光敏三极管
https://blog.csdn.net/weixin_41659040/article/details/135009618
【花雕动手做】ASRPRO-Plus语音识别(09)— DTH11数字式温湿度传感器
https://blog.csdn.net/weixin_41659040/article/details/135022999
【花雕动手做】ASRPRO语音识别(10)—实时测亮度、温湿度的智能气象站
https://blog.csdn.net/weixin_41659040/article/details/135046594
【花雕动手做】ASRPRO-Plus语音识别(11)—TM1650数码管显示温湿度
https://blog.csdn.net/weixin_41659040/article/details/135049040
【花雕动手做】ASRPRO语音识别(12)—ST7735彩屏显示英文与中文
https://blog.csdn.net/weixin_41659040/article/details/135082849
【花雕动手做】ASRPRO语音识别(13)—1.8寸彩屏显示大字号中文
https://blog.csdn.net/weixin_41659040/article/details/135091398
【花雕动手做】ASRPRO语音识别(14)—ST7735彩屏显示环境亮度
https://blog.csdn.net/weixin_41659040/article/details/135165021
【花雕动手做】ASRPRO语音识别(15)—1.8寸彩屏显示字号变换
https://blog.csdn.net/weixin_41659040/article/details/135170449
【花雕动手做】ASRPRO语音识别(16)—1.8寸彩屏连续显示亮度
https://blog.csdn.net/weixin_41659040/article/details/135193729
【花雕动手做】ASRPRO语音识别(17)—按键控制彩屏和继电器
https://blog.csdn.net/weixin_41659040/article/details/135232092
【花雕动手做】ASRPRO语音识别(18)—按键和语音控制彩屏变色
https://blog.csdn.net/weixin_41659040/article/details/135239614
【花雕动手做】ASRPRO语音识别(19)—语音和按键控制继电器
https://blog.csdn.net/weixin_41659040/article/details/135298357
【花雕动手做】ASRPRO语音识别(20)—彩屏显示DHT11温湿度
https://blog.csdn.net/weixin_41659040/article/details/135327244
【花雕动手做】ASRPRO语音识别(21)—报亮度温湿度的气象站
https://blog.csdn.net/weixin_41659040/article/details/135327217
【花雕动手做】ASRPRO语音识别(22)—红外对管控制TFT彩屏
https://blog.csdn.net/weixin_41659040/article/details/135347986