传感器课设——温湿度传感器sht10监控系统(温湿度采集、液晶1602显示、键盘控制、声光报警)程序
- 格式:doc
- 大小:45.50 KB
- 文档页数:8
温湿度传感器SHT10驱动程序——基于MSP430这是暑假时用430的单片机写的温湿度传感器SHT10的程序,参考了官方的51例程,分享一下~~/****************************************Copyright(c)********************************************************************************************LiPeng********************* *************************************--------------FileInfo-------------------------------------------------------------------------------** File Name: Sht10_Driver.c** Created by: LiPeng** Created date: 2008-09-15** Version: 1.0** Descriptions: The original version****------------------------------------------------------------------------------------------------------** Modified by:** Modified date:** Version:** Descriptions:****------------------------------------------------------------------------------------------------------** System Function: Sht10 Driver------温湿度传感器SHT10驱动** 使用MSP430-F413连接方式:** VCC: P6.3** SCK: P6.4** SDA: P6.5*********************************************************************** ***********************************/#include <msp430x14x.h>/*宏定义,延时函数,参数为1时相应延时分别为1us和1ms*/#define CPU_F (double)1000000#define delay_us(x) __delay_cycles((long)(CPU_F * (double)x/1000000.0)) #define delay_ms(x) __delay_cycles((long)(CPU_F * (double)x/1000.0))/*常量定义*/#define uint unsigned int#define uchar unsigned char#define ulong unsigned long//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#define bitselect 0x01 //选择温度与湿度的低位读#define noACK 0#define ACK 1#define HUMIDITY 2#define TEMPERATURE 1#define SCK BIT4#define SDA BIT5#define SVCC BIT3#define SCK_H P6OUT|=SCK#define SCK_L P6OUT&=~SCK#define SDA_H P6OUT|=SDA#define SDA_L P6OUT&=~SDA#define SVCC_H P6OUT|=SVCC#define SVCC_L P6OUT&=~SVCCtypedef union{unsigned int i;float f;}value;uint table_temp[3];uint table_humi[3];uint temten;uint humi_true;/******************************************************************** ****************************************Function Name: S_Init**Description: 初始化**Input Parameters: 无**Output Parameters: 无*************************************/void S_Init(){P6SEL&=~(SCK+SDA+SVCC); //选择P6.3 P6.4 为IO端口,输出 P6.5输入P6DIR|=(SCK+SVCC);P6DIR&=~SDA;BCSCTL1=(XT2OFF+RSEL2); //关闭XT2,1MHz DOCDCOCTL=DCO2; //设定DCO频率为1MHz}/******************************************************************** ****************************************Function Name: S_Transstart**Description: 发送开始时序**** generates a transmission start** _____ ________** DATA: |_______|** ___ ___** SCK : ___| |___| |______**Input Parameters: 无**Output Parameters: 无********************************************************************* *************************************/void S_Transstart(){P6DIR|=SDA;SDA_H;SCK_L;_NOP();SCK_H;_NOP();SDA_L;_NOP();SCK_L;_NOP();_NOP();_NOP();SCK_H;_NOP();SDA_H;_NOP();SCK_L;P6DIR&=~SDA;}****************************************Function Name: S_WriteByte**Description: 写时序**Input Parameters: 无**Output Parameters: 无********************************************************************* *************************************/char S_WriteByte(unsigned char value){unsigned char i,error=0;P6DIR|=SDA;for(i=0x80;i>0;i/=2) //shift bit for masking{if(i&value)SDA_H; //masking value with i , write to SENSI-BUSelseSDA_L;SCK_H; //clk for SENSI-BUS_NOP();_NOP();_NOP(); //pulswith approx. 5 usSCK_L;}SDA_H; //release DATA-lineP6DIR&=~SDA; //Change SDA to be inputSCK_H; //clk #9 for ackerror=P6IN; //check ack (DATA will be pulled down by SHT11)error&=SDA;P6DIR|=SDA;SCK_L;if(error)return 1; //error=1 in case of no acknowledgereturn 0;}/******************************************************************** ****************************************Function Name: S_ReadByte**Description: 读时序**Input Parameters: ack--->reads a byte form the Sensibus and gives an acknowledge in case of "ack=1"**Output Parameters: 无********************************************************************* *************************************/char S_ReadByte(unsigned char ack){unsigned char i,val=0;P6DIR|=SDA;SDA_H; //release DATA-lineP6DIR&=~SDA;for(i=0x80;i>0;i/=2) //shift bit for masking{SCK_H; //clk for SENSI-BUSif(P6IN&SDA)val=(val|i); //read bitSCK_L;}P6DIR|=SDA;if(ack) //in case of "ack==1" pull down DATA-LineSDA_L;elseSDA_H;SCK_H; //clk #9 for ack_NOP();_NOP();_NOP(); //pulswith approx. 5 usSCK_L;SDA_H; //release DATA-lineP6DIR&=~SDA;return val;}/******************************************************************** ****************************************Function Name: S_Connectionreset**Description: 通讯复位时序** communication reset: DATA-line=1 and at least 9 SCK cycles followed by transstart** _____________________________________________________ ________** DATA: |_______|** _ _ _ _ _ _ _ _ _ ___ ___** SCK : __| |__| |__| |__| |__| |__| |__| |__| |__| |______| |___| |______ **Input Parameters: 无**Output Parameters: 无********************************************************************* *************************************/void S_Connectionreset(){unsigned char ClkCnt;P6DIR|=SDA;SDA_H;SCK_L; //Initial statefor(ClkCnt=0;ClkCnt<9;ClkCnt++) //9 SCK cycles{SCK_H;SCK_L;}S_Transstart(); //transmission start}/******************************************************************** ****************************************Function Name: S_Softreset**Description: 软件复位时序resets the sensor by a softreset**Input Parameters: 无**Output Parameters: 无********************************************************************* *************************************/char S_Softreset(){unsigned char error=0;S_Connectionreset(); //reset communicationerror+=S_WriteByte(RESET); //send RESET-command to sensorreturn error; //error=1 in case of no response form the sensor}/******************************************************************** ****************************************Function Name: S_WriteStatusReg**Description: 写状态寄存器**Input Parameters: *p_value**Output Parameters: 无********************************************************************* *************************************/char S_WriteStatusReg(unsigned char *p_value){unsigned char error=0;S_Transstart(); //transmission starterror+=S_WriteByte(STATUS_REG_W); //send command to sensorerror+=S_WriteByte(*p_value); //send value of status registerreturn error; //error>=1 in case of no response form the sensor}/******************************************************************** ****************************************Function Name: S_Mearsure**Description: 读时序 makes a measurement (humidity/temperature) withchecksum**Input Parameters: *p_value ,*p_checknum ,mode**Output Parameters: 无********************************************************************* *************************************/unsigned char S_Measure(unsigned char *p_value, unsigned char*p_checksum, unsigned char mode){unsigned error=0;unsigned int i;S_Transstart(); //transmission startswitch(mode){ //send command to sensorcase TEMPERATURE: error+=S_WriteByte(MEASURE_TEMP); break;case HUMIDITY: error+=S_WriteByte(MEASURE_HUMI); break;}P6DIR&=~SDA;for(i=0;i<65535;i++) //wait until sensor has finished the measurement if((P6IN&SDA)==0)break;if(P6IN&SDA)error+=1; //or timeout (~2 sec.) is reached*(p_value)=S_ReadByte(ACK); //read the first byte (MSB)*(p_value+1)=S_ReadByte(ACK); //read the second byte (LSB)*p_checksum=S_ReadByte(noACK); //read checksumreturn(error);}/******************************************************************** ****************************************Function Name: S_Calculate**Description: 计算**Input Parameters: humi [Ticks] (12 bit)** temp [Ticks] (14 bit)**Output Parameters: humi [%RH]** temp [癈]********************************************************************* *************************************/void S_Calculate(unsigned int *p_humidity ,unsigned int *p_temperature) {const float C1=-4.0; // for 8 Bitconst float C2=+0.648; // for 8 Bitconst float C3=-0.0000072; // for 8 Bitconst float D1=-39.6; // for 12 Bit @ 3Vconst float D2=+0.04; // for 12 Bit @ 3Vconst float T1=0.01; // for 8 bitconst float T2=0.00128; // for 8 bitfloat rh=*p_humidity; // rh: Humidity [Ticks] 12 Bitfloat t=*p_temperature; // t: Temperature [Ticks] 14 Bitfloat rh_lin; // rh_lin: Humidity linearfloat rh_true; // rh_true: Temperature compensated humidityfloat t_C; // t_C : Temperature [癈]t_C=t*D2+D1; //calc. temperature from ticks to [癈]rh_lin=C3*rh*rh + C2*rh + C1; //calc. humidity from ticks to [%RH]rh_true=(t_C-25)*(T1+T2*rh)+rh_lin; //calc. temperature compensated humidity [%RH]if(rh_true>100)rh_true=100; //cut if the value is outside ofif(rh_true<0.1)rh_true=0.1; //the physical possible range*p_temperature=t_C; //return temperature [癈]*p_humidity=rh_true; //return humidity[%RH]}void main(){value humi_val,temp_val;unsigned char error,checksum;unsigned int i,temphigh,templow;unsigned int RegCMD=0x01;WDTCTL=WDTPW+WDTHOLD; //Stop watchdog timer to prevent time out resetS_Init();SVCC_H;S_Connectionreset();S_WriteStatusReg((unsigned char *)&RegCMD);while(1){error=0;error+=S_Measure((unsigned char*) &humi_val.i,&checksum,HUMIDITY);//measure humidityerror+=S_Measure((unsigned char*) &temp_val.i,&checksum,TEMPERATURE); //measure temperatureif(error!=0)S_Connectionreset(); //in case of an error: connection resetelse{templow=(humi_val.i&0xff00);humi_val.i=templow>>8;temphigh=((temp_val.i&0xf)<<8);templow=((temp_val.i&0xff00)>>8);temp_val.i=temphigh+templow;S_Calculate(&humi_val.i,&temp_val.i); //calculate humidity, temperature//temp_val_NOP();//printf("temp:%5.1fC humi:%5.1f%% dewpoint:%5.1fC\n",temp_val.f,humi_val.f,dew_point);}//----------wait approx. 0.8s to avoid heating upSHTxx------------------------------for (i=0;i<40000;i++); //(be sure that the compiler doesn't eliminate this line!)//-----------------------------------------------------------------------------------}}。
SHT10温湿度传感器的通信协议命令包含:1.读取站号命令2.写站号命令3.读取数据4.手动矫正数据串口参数设置:读站号命令(固定命令)主站从站地址功能码H地址L地址 H数据L数据 CRC00 03 00 01 00 01 CRClo CRChi 从站从站地址功能码H地址L地址H数据CRC00 03 02 00 XX CRClo CRChi 注:返回帧与主站相同设备地址:(XX=01-FF)示例:命令00 03 00 01 00 01 D4 1B(固定命令)回复00 03 02 00 FF C5 C4 (设备默认站号FF)写站号命令主站从站地址功能码H地址L地址寄存器个数寄存器个数数据长度数据CRC00 10 00 01 00 01 02 00 XX CRClo CRChi 注:(XX=0X01-0XFF)从站从站地址功能码 H地址L地址寄存器个数CRC00 10 00 01 00 01 CRClo CRChi 示例:命令00 10 00 01 00 01 02 00 33 EA 04回复00 10 00 01 00 01 51 D8读数据主站从站地址功能码 H地址L地址寄存器个数寄存器个数CRCXX 03 00 00 00 02 CRClo CRChi注:(XX=0X01-0XFF)从站从站地址功能码数据长度数据数据CRCXX 03 04 19 AD 1B E4 CRClo CRCh 示例命令FF 03 00 00 00 02 D1 D5回复FF 03 04 19 AD 1B E4 79 FA注:温度:第4,5个字节19 AD温度=读数/100-40度湿度:第5,6个字节1B E4。
大棚温湿度自动控制系统设计摘要:本设计是基于STC89C52RC单片机的大棚温湿度自动控制系统,采用SHT10作为温湿度传感器,LCD1602液晶屏进行显示。
SHT10使用类似于I2C总线的时序与单片机进行通信,由于它高度集成,已经包括A/D转换电路,所以使用方便,而且准确、耐用。
LCD1602能够分两行显示数据,第一行显示温度,第二行显示湿度。
这个控制系统能够测量温室大棚中的温度和湿度,将其显示在液晶屏LCD1602上,同时将其与设定值进行对比,如果超出上下限,将进行报警并启动温湿度调节设备。
此外,还可以通过独立式键盘对设定的温湿度进行修改。
通过设计系统原理图、用Proteus软件进行仿真,证明了该系统的可行性。
关键词:STC89C52RC,SHT10,I2C总线,独立式键盘,温湿度自动控制Abstract:This design is an automatic temperature and humidity controller for greenhouses,with the STC89C52RC MCU being its main controller. It uses the SHT10 as the temperature and humidity sensor,and the LCD1602 to display the messages。
The SHT10 uses a timing sequence much like the I2C to communicate with the micro—controller. Because it's a highly integrated chip, it already includes an analog to digital converter。
Therefore, it’s quite convenient to use, and also accurate and durable. The LCD1602 can display two lines of messages,with the first line for temperature and the second line for humidity。
由于温度与湿度不管是从物理量本身还是在实际人们的生活中都有着密切的关系,所以温湿度一体的传感器就会相应产生。
DHT11与单片机之间能采用简单的单总线进行通信,仅仅需要一个I/O口。
操作简单,使用基亚5110二手屏幕显示DHT11传感器读出来的温度和湿度值。
关键字:AT89S52;5110液晶;DHT11传感器;单总线AbstractBecause of the temperature and the humidity from both the physical quantity itself or in the actual life of people are closely related, so the temperature and humidity sensor integrated will arise accordingly. Between DHT11 and SCM can adopt the simple single bus, only need a I\/O port. Simple operation, using the base of 5110 secondhand screen display DHT11 sensor Read out the temperature and humidity.Keywords: AT89S52; DHT11 5110 LCD; sensor; single bus引言 ------------------------------------------11.1 DHT11描述---------------------------------------------------21.2 管脚排列----------------------------------------------21.3 应用电路连接说明--------------------------------------21.4 DHT11数据结构-----------------------------------------31.5 DHT11的传输时序---------------------------------------31.5.1 DHT11开始发送数据流程--------------------------31.5.2 主机复位信号和DHT11响应信号 --------------------31.5.3 数字‘0’信号表示方法-----------------------------31.5.4 数字‘1’信号表示方法-----------------------------42、诺基亚5110液晶简介(PCD8544驱动)--------------------42.1 引脚---------------------------------------------------4 2.2 功能描述:---------------------------------------------52.2.1 地址计数器 (AC)--------------------------------52.2.2 初始化-------------------------------------------52.2.3复位的作用----------------------------------------62.2.4显示控制------------------------------------------62.2.5 串行接口时序--------------------------------------62.2.6 指令集 ------------------------------------------63、总结-------------------------------------------------74、谢辞-------------------------------------------------85、参考文献---------------------------------------------96、附录-------------------------------------------------105.1 实验总框架图---------------------------------------------10 5.2 硬件部分-------------------------------------------------105.2.1硬件原理图-------------------------------------------10 5.2.2 硬件PCB图-------------------------------------------11 5.2.3 所需元器件-------------------------------------------115.3 实验效果-------------------------------------------------11 5.4 实验软件程序---------------------------------------------12引言可靠性与卓越的长期稳定性。
小型智能系统设计------- 实验项目报告实验名称:基于STC 89C52单片机的温湿度变送器实验日期: 2014年5月——2014年6月院系:电子科学与工程学院专业:微电子科学与工程指导老师:张熠姓名:高波学号:B13020927EDA实验室开课时间:2013/2014 学年第二学期摘要随着人们生活水平的不断提高,利用单片机实现智能控制无疑是人们追求的目标之一,它给人带来的方便也是毋庸置疑的,其中温度传感器就是其中的一个典型例子,但是人们对单片机的控制要求越来越高。
要为现代人工作,生活,科研,学习提供更好、更方便、更人性化的设施就要从单片机技术入手,一切向数字化、智能控制化方向发展。
温湿度变送器基于STC 89C52 单片机,配以DHT11传感器、DS1302显示器以及RS485中继站,具有精度高、适用范围广、生产加工简单、成本低、支持远距离传送、操作简单等优点。
是工农业生产和日常生活都非常实用的一种器件。
目录序言 (3)第一章温度采集器总体设计方案 (4)1.0 温度采集器设计方案论述 (4)1.1 方案明细 (4)第二章硬件设计 (7)2.0 1-wire总线协议介绍 (7)2.1S T C89C52的简单介绍 (8)2.2D H T11特点及电气特性 (9)2.3 MAX232特点及电气特性 (10)2.4 11.0592晶体振荡器电气特性 (13)第三章系统软件设计 (13)3.0主程序设计 (13)3.1 温度程序设计(DHT11模块) (13)3.2 时间程序设计(DS1302模块) (14)第四章总结与体会 (14)第五章软件仿真与系统调试 (16)5.0 protues软件仿真 (19)5.1 keil version仿真 (25)5.2 实物照片 (29)第六章附录 (29)6.0 主程序源代码 (30)序言智能温度传感器智能温度传感器(亦称数字温度传感器)是在20世纪90年代中期问世的。
信息与电气工程学院课程设计说明书〔2015 /2016 学年第 2 学期〕课程名称:单片机应用课程设计题目:温湿度监测系统专业班级:自动化3班学生:学号:指导教师:苗敬利、王立国、王静爽、侯帅、何明星、赵奇设计周数:2周设计成绩:2016 年7 月6 日摘要本设计实现的是单片机温湿度测量与控制系统,通过在LCD1602上实时显示室内环境的温度和相对湿度。
系统采用集温湿度传感器与A/D转换器为一体的DHT90传感器芯片,通过单片机AT89C52处理进行显示,其它模块包括了实时时钟/日期产生电路和超限报警处理电路,对所测量的值进行实时显示和报警处理。
本文介绍了基于ATMEL公司的AT89C52系列单片机的温湿度实时测量与控制系统和显示系统的设计,包括介绍了硬件结构原理,并分析了相应的软件的设计及其要点,包括软件设计流程及其程序实现。
系统结构简单、实用,提高了测量精度和效率。
关键词: 温湿度;SHT10传感器;单片机;DHT11传感器1设计目的:制定温湿度监测系统的操作流程,指导温湿度监测系统的正确使用和维护,防止温湿度监测系统操作不当而造成损坏,并保证测试的数据准确。
2 温湿度检测的简介2.1 系统的概述温湿度测量技术在当今的工厂加工、医疗区域、农业区域中已经起来重要的位子,例如资源的节约、产品质量的提高、产品数目的提高,这些问题现在已经越来越受到外界的关注了。
当今,知识信息和知识的工业化已经开始了飞一般的进步,温度与湿度的问题影响的范围距离已经不再之前谈到的那些方面,它还表达在科技发展、卫生用品、医药卫生、国家安全基础等多种方面。
就上述几个问题和情况,温湿度检测的准确性、稳定性、快速性、安全性这些方面的设计要求变得尤其重要。
在最近几年中,使用SHT10控制的温湿度传感器和温湿度数据的网上直接检验技术现已成为当下的一种发展方向和追求。
本次毕业设计介绍和实现了一种单片机与自动化温湿度传感器互相结合,它们两就组成了一种简单的温湿度检测器系统。
温湿度监控C语言源程序#include <reg51.h>#include <intrins.h>#include <math.h> //Keil library#include <stdio.h> //Keil library/******************** LCD1602设置****************************************/#define LCD_DB P0sbit LCD_RS=P2^5;sbit LCD_RW=P2^6;sbit LCD_E=P2^7;/******定义函数****************/#define uchar unsigned char#define uint unsigned intvoid LCD_init(void); //初始化函数void LCD_write_command(uchar command); //写指令函数void LCD_write_data(uchar dat); //写数据函数void LCD_disp_char(uchar x,uchar y,uchar dat);//在某个屏幕位置上显示一个字符,X (0-15),y(1-2)void LCD_disp_str(uchar x,uchar y,uchar *str); //LCD1602显示字符串函数void delay_n10us(uint n); //延时函数/**************************************模块名称:LCD_init(); 功能:初始化LCD1602***************************************/void LCD_init(void){delay_n10us(10);LCD_write_command(0x38);//设置8位格式,2行,5x7delay_n10us(10);LCD_write_command(0x0c);//整体显示,关光标,不闪烁delay_n10us(10);LCD_write_command(0x06);//设定输入方式,增量不移位delay_n10us(10);LCD_write_command(0x01);//清除屏幕显示delay_n10us(100); //延时清屏,延时函数,延时约n个10us}/*****************************************模块名称:LCD_write_command();功能:LCD1602写指令函数******************************************/void LCD_write_command(uchar dat){delay_n10us(10);LCD_RS=0; //指令LCD_RW=0; //写入LCD_E=1; //允许LCD_DB=dat;delay_n10us(10); // 用for循环1次就能完成普通写指令。
LCD_E=0;delay_n10us(10); // 用for循环1次就能完成普通写指令。
}/****************************************模块名称:LCD_write_data();功能:LCD1602写数据函数******************************************/void LCD_write_data(uchar dat){delay_n10us(10);LCD_RS=1; //数据LCD_RW=0; //写入LCD_E=1; //允许LCD_DB=dat;delay_n10us(10);LCD_E=0;delay_n10us(10);}/*******************************************************模块名称:LCD_disp_char();功能:LCD1602显示一个字符函数,在某个屏幕位置上显示一个字符,X(0-15),y(1-2)。
*********************************************************/void LCD_disp_char(uchar x,uchar y,uchar dat){uchar address;if(y==1)address=0x80+x;elseaddress=0xc0+x;LCD_write_command(address);LCD_write_data(dat);}/***************************************************模块名称:LCD_disp_str();功能:LCD1602显示字符串函数,在某个屏幕起始位置{X(0-15),y(1-2)}上显示字符串。
***************************************************/void LCD_disp_str(uchar x,uchar y,uchar *str){ uchar address;if(y==1) address=0x80+x;elseaddress=0xc0+x; LCD_write_command(address);while(*str!='\0'){ LCD_write_data(*str); str++; } }/****************************************模块名称:delay_n10us();功能:延时函数,延时约n个10us*****************************************/void delay_n10us(uint n) //延时n个10us-12M晶振{uint i;for(i=n;i>0;i--){_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();}}/***************SHT10设置****************************************/sbit DA TA = P3^0; //定义通讯数据端口sbit SCK = P3^1; //定义通讯时钟端口typedef union{ unsigned int i; //定义了两个共用体float f;} value;enum {TEMP,HUMI}; //TEMP=0,HUMI=1#define noACK 0 //用于判断是否结束通讯#define ACK 1 //结束数据传输//adr command r/w#define STA TUS_REG_W 0x06 //000 0011 0#define STA TUS_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/****************定义函数****************/void s_transstart(void); //启动传输函数void s_connectionreset(void); //连接复位函数char s_write_byte(unsigned char value);//SHT10写函数char s_read_byte(unsigned char ack); //SHT10读函数char s_measure(unsigned char *p_value, unsigned char *p_checksum, unsigned char mode); //测量温湿度函数void calc_sht10(float *p_humidity ,float *p_temperature);//温湿度补偿/************************************************模块名称:s_transstart();功能:启动传输函数*************************************************/void s_transstart(void)// generates a transmission start// _____ ________// DA TA: |_______|// ___ ___// SCK : ___| |___| |______{DA TA=1; SCK=0; //Initial state_nop_(); SCK=1; _nop_(); DA TA=0; _nop_(); SCK=0; _nop_();_nop_();_nop_();SCK=1; _nop_(); DA TA=1; _nop_(); SCK=0;}/**********************************************模块名称:s_connectionreset(); 功能:连接复位函数************************************************/void s_connectionreset(void)// communication reset: DA TA-line=1 and at least 9 SCK cycles followed by transstart// _____________________________________________________ ________ // DA TA: |_______|// _ _ _ _ _ _ _ _ _ ___ ___// SCK : __| |__| |__| |__| |__| |__| |__| |__| |__| |______| |___| |______{unsigned char i;DA TA=1; SCK=0; //Initial statefor(i=0;i<9;i++) //9 SCK cycles{SCK=1;SCK=0;}s_transstart(); //transmission start}/**********************************************模块名称:s_write_byte(); 功能:SHT10写函数**********************************************/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;i>0;i/=2) //shift bit for masking{if (i & value) DA TA=1; //masking value with i , write to SENSI-BUSelse DA TA=0;SCK=1; //clk for SENSI-BUS_nop_();_nop_();_nop_(); //pulswith approx. 3 usSCK=0;}DA TA=1; //release DA TA-lineSCK=1; //clk #9 for ackerror=DA TA; //DA TA在第9个上升沿将被SHT10下拉为低电平。