LM75AD温度传感器读写

#include "LM75AD.h"
#include "IIC.h"

//	 
/*
0x00  Temperature Register      
0x01  Configuration register  器件模式 写00普通模式(100ms更新一次温度值) 写01为ShutDown模式
0x02  Hysteresis register
0x03  Over_temperature shutdown register

Temp Register 
MSByte                LSByte
7   6  5  4  3  2  1  0  7  6  5  4 3 2 1 0
D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 X X X X X

D10=0    ℃=+(Temp Data×0.125) 	
D10=1    ℃=-(Temp Data×0.125)


Address Table
MSB          LSB
1 0 0 1 A2 A1 A0

1 0 0 1 0  0  1 0/1       =0x92
*/
/

 
//LM75AD IO初始化
void LM75AD_Init(void)
{
    I2C_WriteByte(0x01,0x00,LM75AD_ADDR);
}

float LM75_Temp(void)
{
    float tempture;
    int temp;
    temp=I2C_ReadByte(0x00,LM75AD_ADDR,2);
    tempture=temp>>5;
    return tempture*0.125;	
}
头文件
#ifndef __LM75AD_H
#define __LM75AD_H	 
#include "sys.h"
 
#define LM75AD_ADDR 0x92   //默认地址0x90 这里我将A0接至了VCC

void LM75AD_Init(void);
float LM75_Temp(void);
		 				    
#endif

实际效果(IIC驱动见前文)



评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值