- 1、本文档被系统程序自动判定探测到侵权嫌疑,本站暂时做下架处理。
- 2、如果您确认为侵权,可联系本站左侧在线QQ客服请求删除。我们会保证在24小时内做出处理,应急电话:400-050-0827。
- 3、此文档由网友上传,因疑似侵权的原因,本站不提供该文档下载,只提供部分内容试读。如果您是出版社/作者,看到后可认领文档,您也可以联系本站进行批量认领。
查看更多
SHT20源码
SHTxx?
Humidity??Temperature?
Sensmitter?
Application?Note?
Sample?Code?
1?Introduction?
This?application?note?gives?an?example?for?microcontroller?C?code.?It?includes?code?for:?
Readout?of?Humidity?(RH)?or?Temperature?(T)?with?basic?error?handling?
Calculation?of?RH?linearization?and?temperature?compensation?
Access?to?status?register?
Dewpoint?calculation?from?RH?and?T
UART?handling?
2?Sample?Code?
/****************************************************************
Project:??????????SHT11?demo?program?(V2.0)?
Filename:?????????SHT11.c?????
Prozessor:????????80C51?family?
Compiler:?????????Keil?Version?6.14?
Autor:????????????MST?
Copyrigth:????????(c)?Sensirion?AG???????
****************************************************************/?
#include?AT89s53.h?//Microcontroller?specific?library,?e.g.?port?definitions?
#include?intrins.h?//Keil?library?(is?used?for?_nop()_?operation)???
#include?math.h????//Keil?library???
#include?stdio.h???//Keil?library?
?
typedef?union??
{ unsigned?int?i;?
float?f;?
}?value;?
?
//---------------------------------------------------------------------------------
//?modul-var?
//------------------------------------------------------------------------------
enum?{TEMP,HUMI};?
#define?DATA???P1_1?
#define?SCK????P1_0?
#define?noACK? 0?
#define?ACK?? ?1?
???????????????????? ? //adr??command??r/w?
#define?STATUS_REG_W?0x06? ??//000???0011????0?
#define?STATUS_REG_R?0x07??? //000???0011????1?
#define?MEASURE_TEMP?0x03???//000???0001????1?
#define?MEASURE_HUMI?0x05???//000???0010????1?
#define?RESET????????0x1e?? ?//000???1111????0?
//---------------------------------------------------------------------------------
char s_write_byte(unsigned?char?value)?
//---------------------------------------------------------------------------------
//?writes?a?byte?on?the?Sensibus?and?checks?the?acknowledge??
{??
unsigned?char?i,error=0;???
for?(i=0x80;i0;i/=2)????????????? //shift?bit?for?masking?
{ ?if?(i??value)
文档评论(0)