历史上的今天
今天是:2024年10月30日(星期三)
2019年10月30日 | SHT10温湿度传感器应用,含单片机源码
2019-10-30 来源:51hei
早几年用了SHT10的温湿度传感器,稳定,可靠,就是更新数据时间比较长些,
电路很简单,请看手册,
已经在产品中使用了,请放心使用和指正,
#include #include #include /*********************************************************************************************************/ #include "sht.h" #include "uart.h" #include "key.h" #include "IO.h" #include "Lcd.h" /*********************************************************************************************************/ enum {TEMP,HUMI}; /*********************************************************************************************************/ //0: 温度1, 1:湿度1 , 2 : 温度2, 3: 湿度2 float todao[4]; //{temp,rh}; 模拟量寄存器从1到2 float humi_val1; //湿度变量 float temp_val1; //温度变量 unsigned int humi_val; //湿度变量 unsigned int temp_val; //温度变量 unsigned char checksum; /* const float C1=-4; // for 12 Bit RH const float C2=+0.0405; // for 12 Bit RH const float C3=-0.0000028; // for 12 Bit RH const float T1=+0.01; // for 12 Bit RH const float T2=+0.00008; // for 12 Bit RH */ const float C1=-2.0468; // for 12 Bit RH const float C2=+0.0367; // for 12 Bit RH const float C3=-0.0000015955; // for 12 Bit RH const float T1=+0.01; // for 12 Bit RH const float T2=+0.00008; // for 12 Bit RH /*********************************************************************************************************/ extern unsigned char wendu1_biaozhi; extern unsigned char wendu2_biaozhi; extern unsigned char R_KeyValue1; /*********************************************************************************************************/ /********************************************************************************************************** ** 函数名称: s_write_byte() ** 函数功能: SHT10写单个字节, 写一个字节并输出ACK验证 ** 入口参数: 写入单个字节 ** 出口参数: ACK验证 ** 说 明: writes a byte on the Sensibus and checks the acknowledge *********************************************************************************************************/ unsigned char s_write_byte(unsigned char value) { unsigned char i,j,error1=0; SHT10_SDA1_OUT; for(i=0x80;i>0;i/=2) //shift bit for masking { if (i & value) SHT10_SDA1_OUT1; //masking value with i , write to SENSI-BUS else SHT10_SDA1_OUT0; SHT10_SCK1_OUT1; //clk for SENSI-BUS for(j = 0; j<40;j++) { NOP(); //pulswith approx. 5 us } SHT10_SCK1_OUT0; } NOP(); NOP(); NOP();
史海拾趣
|
接受 7 楼提议,这类题目应当在《初学者园地》栏目进行类似内容的讨论。暂时保留2日后转移。 从<电子设计1000例>选出这个电路,我的问题是: 如何利用交流等效电路的方法,半定量的分析解释这个电路的工作原理. (本主题原是对thtlj ...… 查看全部问答> |
|
我用的是mini2440 但是mini2440 用的是12m的晶振 现在想移植一个官方的2440 的bsp 现在发现官方的bsp是用的16m的晶振,我现在改了mpll 和 pllval 但是烧进去以后串口还是没有信息。但是用jlink看发现在内存中0x30 ...… 查看全部问答> |
|
刚得到消息,针对板子的LINUX内核即将(大约是两周左右)更新到3.0,并且real6410将支持录音等多数功能,需要的朋友到时可以去华天正的ftp下载! [ 本帖最后由 wanghongyang 于 2011-12-2 10:45 编辑 ]… 查看全部问答> |
|
xilinx fpga开发实用教程 100多M 下面看下介绍: 内容简介 《Xilinx FPGA开发实用教程》系统讲述了Xilinx FPGA的开发知识,包括FPGA开发简介、Verilog HDL语言基础、基于Xilinx芯片的HDL语言高级进阶、ISE开发环境使用指南、FP ...… 查看全部问答> |




