求购CC2430+SHT11温湿度采集程序

ggfysj 2009-12-20 07:09:54
我需要解决CC2430+SHT11温湿度采集,并能组网发送。通过串口在电脑上显示。有谁有相关程序可与我联系,资源分可以随便给,甚至可以花钱购买。联系邮箱:gongguanfei@139.com.谢谢!
...全文
940 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
houhou0804 2012-05-27
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]
我做过SHT10的,楼主你看看读写时序是否和SHT11相同,如果相同那没我的程序可以直接用到你的SHT11上!
[/Quote] 大哥,能把程序给我发一份吗?正在学习中,谢谢。591770855@qq.com
gfchen1989 2011-05-26
  • 打赏
  • 举报
回复
8楼的那个是采集还是发送的程序?求教,QQ:601765796
DGC_gfc 2011-05-11
  • 打赏
  • 举报
回复
我只要采集和发送的子程序?急求 3q
lujiajia111 2011-03-02
  • 打赏
  • 举报
回复
我也求啊
hong_realm 2010-06-05
  • 打赏
  • 举报
回复
楼上的大哥,你的这个程序是用在单片机力,还是用在ARM里的呀?
dunwoo 2010-06-04
  • 打赏
  • 举报
回复
void Delay(uint8 n)
{
uint8 tt;
for(tt = 0;tt<n;tt++);
for(tt = 0;tt<n;tt++);
for(tt = 0;tt<n;tt++);
for(tt = 0;tt<n;tt++);
for(tt = 0;tt<n;tt++);
}


char s_write_byte(unsigned char value)
{
IIC_DATA_OUT;
unsigned char i,error=0;
for (i=0x80;i>0;i/=2) //shift bit for masking
{
Delay(2);
if (i & value) DQDATA=1; //masking value with i , write to SENSI-BUS
else DQDATA=0;
Delay(2);
SCK=1; //clk for SENSI-BUS
Delay(2); //pulswith approx.5 us
SCK=0;
}

Delay(4);
DQDATA=1; //release DATA-line
IIC_DATA_IN;
SCK=1; //clk #9 for ack

Delay(2);
error=DQDATA; //check ack (DATA will be pulled down by SHT11)
SCK=0;
return error; //error=1 in case of no acknowledge
}

char s_read_byte(unsigned char ack)
{

unsigned char i,val=0;
DQDATA=1; //release DATA-line
IIC_DATA_IN;
for (i=0x80;i>0;i/=2) //shift bit for masking
{
Delay(2);
SCK=1; //clk for SENSI-BUS
Delay(2);
if (DQDATA) val=(val | i); //read bit
SCK=0;
}
Delay(2);
IIC_DATA_OUT;
DQDATA=!ack; //in case of "ack==1" pull down DATA-Line

SCK=1; //clk #9 for ack
Delay(2);
SCK=0;
DQDATA=1; //release DATA-line
return val;
}


void s_transstart(void)

// generates a transmission start
// _____ ________
// DATA: |_______|
// ___ ___
// SCK : ___| |___| |______
{

DQDATA=1;
SCK=0; //Initial state
Delay(2);
SCK=1;
Delay(2);
DQDATA=0;
Delay(2);
SCK=0;
Delay(2);
SCK=1;
Delay(2);
DQDATA=1;
Delay(2);
SCK=0;
}

void s_connectionreset(void)
// communication reset: DATA-line=1 and at least 9 SCK cycles followed by transstart
// _____________________________________________________ ________
// DATA: |_______|
// _ _ _ _ _ _ _ _ _ ___ ___
// SCK : __| |__| |__| |__| |__| |__| |__| |__| |__| |______| |___| |______
{
unsigned char i;

DQDATA=1;
SCK=0; //Initial state
Delay(2);
for(i=0;i<9;i++) //9 SCK cycles
{ SCK=1;
Delay(2);
SCK=0;
Delay(2);
}
//s_transstart(); //transmission start
}


//----------------------------------------------------------------------------------
char s_softreset(void)
//----------------------------------------------------------------------------------
// resets the sensor by a softreset
{
unsigned char error=0;
s_connectionreset(); //reset communication
error+=s_write_byte(RESET); //send RESET-command to sensor
return error; //error=1 in case of no response form the sensor
}

//----------------------------------------------------------------------------------
char s_read_statusreg(unsigned char *p_value, unsigned char *p_checksum)
//----------------------------------------------------------------------------------
// reads the status register with checksum (8-bit)
{
unsigned char error=0;
s_transstart(); //transmission start
error=s_write_byte(STATUS_REG_R); //send command to sensor
*p_value=s_read_byte(ACK); //read status register (8-bit)
*p_checksum=s_read_byte(noACK); //read checksum (8-bit)
return error; //error=1 in case of no response form the sensor
}

//----------------------------------------------------------------------------------
char s_write_statusreg(unsigned char *p_value)
//----------------------------------------------------------------------------------
// writes the status register with checksum (8-bit)
{
unsigned char error=0;
s_transstart(); //transmission start
error+=s_write_byte(STATUS_REG_W);//send command to sensor
error+=s_write_byte(*p_value); //send value of status register
return error; //error>=1 in case of no response form the sensor
}

//----------------------------------------------------------------------------------
char s_measure(unsigned char *p_value, unsigned char *p_checksum, unsigned char mode)
//----------------------------------------------------------------------------------
// makes a measurement (humidity/temperature) with checksum
{
unsigned error=0;
unsigned int i;

s_transstart(); //transmission start
switch(mode){ //send command to sensor
case TEMP : error+=s_write_byte(MEASURE_TEMP); break;
case HUMI : error+=s_write_byte(MEASURE_HUMI); break;
default : break;
}
DQDATA=1; //release DATA-line
IIC_DATA_IN;
for (i=0;i<65535;i++)
{
Delay(10);
if(DQDATA==0) break;//wait until sensor has finished the measurement
}

//for (i=0;DQDATA && i<75000;i++) //test--i=21995 or 6327
// { } //wait until sensor has finished the measurement

if(DQDATA) error+=1; // or timeout (~2 sec.) is reached
*(p_value) =s_read_byte(ACK); //read the first byte (MSB)
*(p_value+1)=s_read_byte(ACK); //read the second byte (LSB)
*p_checksum =s_read_byte(noACK); //read checksum
return error;
}


//----------------------------------------------------------------------------------------
void calc_sth10(float *p_humidity ,float *p_temperature)
//----------------------------------------------------------------------------------------
// calculates temperature [癈] and humidity [%RH]
// input : humi [Ticks] (12 bit)
// temp [Ticks] (14 bit)
// output: humi [%RH]
// temp [癈]
{
const float C1=-4.0; // for 12 Bit
const float C2=+0.0405; // for 12 Bit
const float C3=-0.0000028; // for 12 Bit
const float T1=+0.01; // for 14 Bit @ 5V
const float T2=+0.00008; // for 14 Bit @ 5V

float rh=*p_humidity; // rh: Humidity [Ticks] 12 Bit
float t=*p_temperature; // t: Temperature [Ticks] 14 Bit
float rh_lin; // rh_lin: Humidity linear
float rh_true; // rh_true: Temperature compensated humidity
float t_C; // t_C : Temperature [癈]

t_C=t*0.01 - 40; //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 of
if(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]
}




//主测量里调用

Derror+=s_measure((unsigned char*) &humi_val.i,&checksum,HUMI); //measure humidity
Derror+=s_measure((unsigned char*) &temp_val.i,&checksum,TEMP); //measure temperature
if(Derror!=0) s_connectionreset(); //in case of an error: connection reset
else
{

temp=(unsigned char*) &humi_val.i;
m_temp=(unsigned int)temp;
f_temp*=m_temp;
f_temp-=40;
f_temp*=10;
m_temp=(unsigned int)f_temp;

humi_val.f=(float)humi_val.i; //converts integer to float
temp_val.f=(float)temp_val.i; //converts integer to float
calc_sth10(&humi_val.f,&temp_val.f); //calculate humidity, temperature
ggfysj 2009-12-20
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 bobommsky 的回复:]
我做过SHT10的,楼主你看看读写时序是否和SHT11相同,如果相同那没我的程序可以直接用到你的SHT11上!
[/Quote]时序差不多,能发给我调调么?
z569362161 2009-12-20
  • 打赏
  • 举报
回复
学习
vanchristin 2009-12-20
  • 打赏
  • 举报
回复
关注,正在做一个无线传感器网络
bobommsky 2009-12-20
  • 打赏
  • 举报
回复
我做过SHT10的,楼主你看看读写时序是否和SHT11相同,如果相同那么我的程序可以直接用到你的SHT11上!

[Quote=引用 3 楼 bobommsky 的回复:]
我做过SHT10的,楼主你看看读写时序是否和SHT11相同,如果相同那没我的程序可以直接用到你的SHT11上!
[/Quote]
bobommsky 2009-12-20
  • 打赏
  • 举报
回复
我做过SHT10的,楼主你看看读写时序是否和SHT11相同,如果相同那没我的程序可以直接用到你的SHT11上!
晴天1999 2009-12-20
  • 打赏
  • 举报
回复
新手哈!多多指教哟!
yxwsbobo 2009-12-20
  • 打赏
  • 举报
回复
恩,不错 帮你顶,我来接分的

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧