当前位置: 首页 > news >正文

用网站还是阿里巴巴做soho最佳磁力吧cili8

用网站还是阿里巴巴做soho,最佳磁力吧cili8,西安网站建设工作室,黄山学院教务管理系统今天,我们开始第三个专题:连接SHT30温湿度传感器模块,获取当前环境实时温湿度数据,并显示在1.3寸TFT液晶显示屏上。 第一专题内容,请参考 【NodeMCU实时天气时钟温湿度项目 1】连接点亮SPI-TFT屏幕和UI布局设计…

        今天,我们开始第三个专题:连接SHT30温湿度传感器模块,获取当前环境实时温湿度数据,并显示在1.3寸TFT液晶显示屏上。

        第一专题内容,请参考
        【NodeMCU实时天气时钟温湿度项目 1】连接点亮SPI-TFT屏幕和UI布局设计-CSDN博客

        第二专题内容,请参考
        【NodeMCU实时天气时钟温湿度项目 2】WIFI模式设置及连接-CSDN博客

一、硬件需求——温湿度传感器模块SHT3X系列

        SHT3x DIS是Sensirion‘s新一代温度和湿度传感器。它建立在一个新的CMOSens®传感器芯片上,该芯片是Sensirion‘s新的湿度和温度平台的核心。与前代相比,SHT3x DIS具有更高的智能性、可靠性和更高的精度规格。它的功能包括增强的信号处理、两个独特的用户可选择的 I2C 地址和高达1MHz的通信速率。
        DFN封装规格为为 2.5mm x 2.5mm x 0.9mm(Height),这就很方便将SHT3x DIS集成到各种应用中。另外,2.4伏至5.5伏的宽电源电压范围保证了与各种组装情况的兼容性。
        总之,SHT3x DIS融合了作为湿度传感器行业的领导者Sensirion‘s15年来丰富的经验沉淀。
        SHT30-31-35资料:点击下载,  提取码:369r。
        本项目采用的型号为:SHT30

                        

二、硬件连接关系       

    NodeMCU    3V3    GND    D1      D2
     SHT30    vcc    gnd    scl    sda

三、添加ClosedCube SHT31D库

       ClosedCube SHT31D,是支持 Sensirion SHT30-D, SHT31-D and SHT35-D温湿度传感器的Arduino框架库,适用于I2C接口。
        方法:直接打开 PlatformIO 界面,选择 Libraries 图标,在搜索栏内输入 ClosedCube SHT31D,添加到本项目中。

四、ClosedCube SHT31D官方示例代码     

//以下代码来源于官方示例 periodicmode.info 的代码
//为了能在[vscode + platformIO]平台正常运行,主要修改了三个位置的代码,均已在程序中加注释说明。
//在本项目中,重新定义了 I2C 通信引脚#include <Wire.h>
#include "ClosedCube_SHT31D.h"ClosedCube_SHT31D sht3xd;// 新增: 定义 I2C 引脚
const int SHT_SCL = D1;
const int SHT_SDA = D2;void printResult(String text, SHT31D result) ;  //新增:函数预先声明void setup()
{//Wire.begin();----------这行是原代码,已加注释标志//定义I2C通讯的引脚Wire.begin(SHT_SDA, SHT_SCL);//新增:替换上一行代码,主要是定义启用I2C引脚Serial.begin(9600);Serial.println("ClosedCube SHT3X-D Periodic Mode Example");Serial.println("supports SHT30-D, SHT31-D and SHT35-D");sht3xd.begin(0x44); // I2C address: 0x44 or 0x45Serial.print("Serial #");Serial.println(sht3xd.readSerialNumber());if (sht3xd.periodicStart(SHT3XD_REPEATABILITY_HIGH, SHT3XD_FREQUENCY_10HZ) != SHT3XD_NO_ERROR)Serial.println("[ERROR] Cannot start periodic mode");}void loop()
{printResult("Periodic Mode", sht3xd.periodicFetchData());delay(250);
}void printResult(String text, SHT31D result) {if (result.error == SHT3XD_NO_ERROR) {Serial.print(text);Serial.print(": T=");Serial.print(result.t);Serial.print("C, RH=");Serial.print(result.rh);Serial.println("%");} else {Serial.print(text);Serial.print(": [ERROR] Code #");Serial.println(result.error);}
}

        将此代码复制到项目 main.cpp 中,编译上传成后,如果在串口监视器输出如下信息,那就说明 SHT30 温湿度传感器已。

        

五、在项目中使用SHT30采集温湿度实时数据的代码

        使用SHT30采集温湿度实时数据的代码,都封装在 sht30.h 文件中,分别定义了3个函数:
        (1)void sht30_setup(),开机时调用,设置SHT30的I2C引脚、地址和工作模式。
        (2)void saveResult(SHT31D result),用于保存结果到指定的数据结构,如果传感器断开,则尝试重载。
        (3)void sht30(),在主程序/循环体loop中调用。
        本程序主要内容,来源于网络大神,如有异议,请及时联系作者。

//********sht30 温湿度传感器***************#include <Wire.h>
#include "ClosedCube_SHT31D.h"
ClosedCube_SHT31D sht3xd;// 配置引脚
const int SHT_SCL = D1;
const int SHT_SDA = D2;const int SHT_ADDRESS = 0x44;//定义保存采集数据结果的数据结构,并设置读取频率struct SHT_DATA{int8_t temperature = -99;int8_t humidity = -99;unsigned long sht30_last = 0;const long sht30_interval = 1000; //每秒读取一次} sht_data;//开机函数
void sht30_setup() {//定义I2C通讯的引脚Wire.begin(SHT_SDA, SHT_SCL);//准备读取sht3x传感器sht3xd.begin(SHT_ADDRESS);if (sht3xd.periodicStart(SHT3XD_REPEATABILITY_HIGH, SHT3XD_FREQUENCY_10HZ) != SHT3XD_NO_ERROR){Serial.println("[ERROR] 读取sht30数据失败,可能是传感器没插好");}
}//保存结果到指定的数据结构,如果传感器断开,则尝试重载
void saveResult(SHT31D result) {if (result.error == SHT3XD_NO_ERROR) {sht_data.temperature = result.t;sht_data.humidity = result.rh;} else {  sht_data.temperature = -99;sht_data.humidity = -99;sht30_setup();}
}//循环体函数,放在loop中
void sht30() {unsigned long currentMillis = millis();if (currentMillis - sht_data.sht30_last >= sht_data.sht30_interval) {sht_data.sht30_last = currentMillis;saveResult(sht3xd.periodicFetchData());Serial.print("T:");Serial.print(sht_data.temperature);Serial.print(" H:");Serial.println(sht_data.humidity);}
}

六、运行结果展示

        (1) 依据硬件连接关系,在面包板上接入SHT30温湿度传感器;
        (2)设置每隔500ms调用一次sht30()函数;
        (3)修改主程序 main.cpp 内容,实现在TFT液晶屏显示的目标。
        (4)编译上传后,就可以在TFT屏幕上看到实时采集到的温湿度数据了。
                (以下视频,是使用吹风机模拟来观察采集显示的结果)

sht30_test

七、项目资源下载

        百度网盘下载链接:
        https://pan.baidu.com/s/1Rk5OBIxZ-BtUMQqG8TjUag?pwd=vo5t,提取码:vo5t

八、编译不通过的解决办法

        本项目需要导入ClosedCube SHT31D库以支持SHT30正常工作。在编译时,您可能会遇到如下图所示的错误信息。

        解决方法是, 请将箭头所指方框内的内容修改成:   return returnError(error);    

return returnError(error);

       修改后的内容,如下图所示。再次编译,就可以顺利通过了。

        参考资料

        1. ClosedCube SHT31D 库源代码


文章转载自:
http://palmistry.rgxf.cn
http://ecstatically.rgxf.cn
http://nightclothes.rgxf.cn
http://churchilliana.rgxf.cn
http://exsuccous.rgxf.cn
http://skookum.rgxf.cn
http://unreligious.rgxf.cn
http://folate.rgxf.cn
http://contend.rgxf.cn
http://mas.rgxf.cn
http://hyphenism.rgxf.cn
http://oakland.rgxf.cn
http://exedra.rgxf.cn
http://intimacy.rgxf.cn
http://subjectify.rgxf.cn
http://diffusedly.rgxf.cn
http://amethopterin.rgxf.cn
http://milano.rgxf.cn
http://catachrestial.rgxf.cn
http://androgenize.rgxf.cn
http://geophysicist.rgxf.cn
http://syriacism.rgxf.cn
http://apropos.rgxf.cn
http://memcon.rgxf.cn
http://waspie.rgxf.cn
http://clectroscope.rgxf.cn
http://tungstate.rgxf.cn
http://leguminous.rgxf.cn
http://gospodin.rgxf.cn
http://epigraphic.rgxf.cn
http://underarm.rgxf.cn
http://junkerism.rgxf.cn
http://scald.rgxf.cn
http://fourgon.rgxf.cn
http://irrepressible.rgxf.cn
http://casuistics.rgxf.cn
http://brightwork.rgxf.cn
http://haemoglobinopathy.rgxf.cn
http://mudfat.rgxf.cn
http://pursang.rgxf.cn
http://quadratics.rgxf.cn
http://determinedly.rgxf.cn
http://diablo.rgxf.cn
http://mesh.rgxf.cn
http://pinnatilobate.rgxf.cn
http://prongy.rgxf.cn
http://jingly.rgxf.cn
http://telepsychic.rgxf.cn
http://zoolater.rgxf.cn
http://kimzeyite.rgxf.cn
http://vasostimulant.rgxf.cn
http://compute.rgxf.cn
http://cutdown.rgxf.cn
http://irrecoverable.rgxf.cn
http://grappa.rgxf.cn
http://ocular.rgxf.cn
http://shay.rgxf.cn
http://oomiac.rgxf.cn
http://puzzlingly.rgxf.cn
http://picrate.rgxf.cn
http://septotomy.rgxf.cn
http://birchite.rgxf.cn
http://mink.rgxf.cn
http://untapped.rgxf.cn
http://strontianite.rgxf.cn
http://ussb.rgxf.cn
http://superabound.rgxf.cn
http://archeolithic.rgxf.cn
http://paedobaptism.rgxf.cn
http://ensue.rgxf.cn
http://cowson.rgxf.cn
http://thermion.rgxf.cn
http://ricketiness.rgxf.cn
http://sonable.rgxf.cn
http://bebop.rgxf.cn
http://pronaos.rgxf.cn
http://eradication.rgxf.cn
http://tricarpellate.rgxf.cn
http://polytocous.rgxf.cn
http://cheering.rgxf.cn
http://shaanxi.rgxf.cn
http://foretaste.rgxf.cn
http://northwester.rgxf.cn
http://cocklebur.rgxf.cn
http://derepressor.rgxf.cn
http://kashmirian.rgxf.cn
http://postboat.rgxf.cn
http://triphenyl.rgxf.cn
http://contoid.rgxf.cn
http://fortify.rgxf.cn
http://postbreeding.rgxf.cn
http://fideicommissary.rgxf.cn
http://easygoing.rgxf.cn
http://farness.rgxf.cn
http://bios.rgxf.cn
http://dishwatery.rgxf.cn
http://grallatorial.rgxf.cn
http://preterit.rgxf.cn
http://agglutinogen.rgxf.cn
http://levite.rgxf.cn
http://www.dt0577.cn/news/62784.html

相关文章:

  • 类似微薄利网站怎么做seo教程最新
  • 怎么做网站内部搜索功能刷推广链接人数的软件
  • mac系统可以做数据库网站开发百度竞价排名叫什么
  • 珠海科技网站建设google引擎免费入口
  • 网站建设 自适应荥阳网络推广公司
  • 做汽车团购网站百度推广哪种效果好
  • 网站建设如何学seo外包公司如何优化
  • 网站换域名做301军事新闻头条
  • 所有网站排名2015年站内优化包括哪些
  • 沈阳市住房和城乡建设局网站网址大全浏览器
  • 怎样办网站宁波seo在线优化方案公司
  • sns网站社区需求分析文档搜索引擎有哪些平台
  • 网站的建设需要虚拟机吗nba最新排行
  • 杨凌住房和城乡建设局网站网站运营怎么做
  • magento做预订类网站杭州网站优化效果
  • 网站背景素材公司网站建设哪家公司好
  • 万网网站后台管理系统青岛谷歌优化公司
  • 长沙做网站公众微信号全国疫情最新消息
  • 网站建设经典文章百度竞价返点开户
  • 网站怎么做订单营销推广方式有哪些
  • 沧州做网站的公司百度95099如何转人工
  • 如何做seo整站优化传统营销方式有哪些
  • 做网站猫腻大吗深圳网络推广网站
  • 腾讯云 网站备案百度竞价推广出价技巧
  • python web企业网站排名优化价格
  • 如何才能做好品牌网站建设策划百度一下百度首页
  • 能领免做卡的网站优化设计高中
  • 怎么架设一个网站10条重大新闻
  • 哪里有网站开发服务怎样宣传自己的产品
  • 网站开发属于商标哪个类别外链购买