新聞中心

EEPW首頁 > 手機與無線通信 > 設(shè)計應(yīng)用 > 基于nRF24E01的無線溫度采集系統(tǒng)設(shè)計

基于nRF24E01的無線溫度采集系統(tǒng)設(shè)計

作者: 時間:2010-08-02 來源:網(wǎng)絡(luò) 收藏

圖2 數(shù)據(jù)發(fā)送流程圖


RF24E01的主要程序代碼如下:


(1)對DSl8B20的數(shù)據(jù)讀寫是通過時間隙處理位和命令字來確認(rèn)信息交換。根據(jù)“單線復(fù)位脈沖時序和1-wire presence detect”的時序圖程序如下:
uint get_temperature()
{
float wendu;
uchar a,b;
ds_reset();
delay(1); //約2ms
ds_write_byte(0xcc);
ds_write_byte(0xbe);
a=ds_read_byte();
b=ds_read_byte();
temp=b;
return temp;
//返回相關(guān)數(shù)據(jù)
}


(2)發(fā)送函數(shù),把數(shù)據(jù)通過發(fā)射出去,實現(xiàn)函數(shù)如下:
void Transmitter(unsigned char b){//發(fā)送函數(shù)
unsigned char mtemp;
CS=1;
Delay100us(0);
for(mtemp=0;mtemptconf.n;mtemp++){
SpiReadWrite(tconf.buf[mtemp]);//發(fā)送發(fā)送器配置字
}
CS=0;
TransmitPacket(b);
//發(fā)送數(shù)據(jù)包
}
}


上一頁 1 2 下一頁

評論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉