2517 views|3 replies

2015

Posts

0

Resources
The OP
 

Wireless temperature transmitter based on ZigBee [Copy link]

The function of the system is to use pt100 thermal resistor to collect temperature data, use resistance bridge to obtain accurate voltage value, use AD conversion chip tlc549 to perform AD conversion, and then send the collected temperature data to the host part through ZigBee module, and use LCD1602 to display it. Here I store the sent data once a minute and update it once an hour. You can also choose off-chip memory to accommodate more data.

The actual picture produced is as follows:


See the program for temperature acquisition.
#include <STC89C5xRC.H>
#include <intrins.h>
#define uchar unsigned char //unsigned character macro definition variable range 0~255
#define uint unsigned int //unsigned integer macro definition variable range 0~65535
sbit CS=P0^0; //tlc549 chip select
sbit CLK=P0^2; //tlc549 clock
sbit DAT=P0^1; //tlc549 data


uchar bdata ADCdata;
sbit ADbit=ADCdata^0; //define addressable variable
uchar n,AD_DATA;
uchar temper[3]; //one-time temperature storage array


uchar Data_start[]={0xFE,0X08,0x91,0x90,0xBB,0x37};
uchar Data_end[]={0xFF};
/*························1 millisecond delay function······························*/
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
/************************Read temperature and voltage function********************************/
uchar TLC549ADC(void)
{
uchar i;
CS=1;
CLK=0;
DAT=1;
CS=0;
for(i=0;i<8;i++)
{
CLK=1;
// Delay_MS(5);
_nop_(); _nop_();_nop_();
_nop_();
ADbit=DAT;
ADCdata<<=1; //AD conversion
CLK=0;
// Delay_MS(5);
_nop_(); _nop_();_nop_();
}
return (ADCdata);
}
/*·························Serial port sending initialization function······················*/
void InitUART(void)
{
SCON=0x50; //Serial port working mode 1, 8-bit UART, variable baud rate
TH2=0xFF;
TL2=0xFD; //Baud rate: 115200 crystal oscillator=11.0592MHz
RCAP2H=0xFF;
RCAP2L=0xFD; //16-bit automatic reload value
TCLK=1;
RCLK=1;
C_T2=0;
EXEN2=0; //Baud rate generator working mode
/*****************/
TR2=1 ; //Timer 2 starts
ES=1;
EA=1;

}
/****************Serial port 1 sends **********************/
void UART_1SendOneByte(unsigned char c)
{
if(c=='\n') //If you encounter \n, then break the line
{
//Send CR(carriage return)
SBUF=0x0D;
while(!TI); //Wait for sending to complete
TI=0;

//Send LF(NL line feed,new line)
SBUF=0x0A;
while(!TI); //Wait for sending to complete
TI=0;
}
else
{
SBUF=c;
while(!TI); //Wait for sending to complete
TI=0;
}
}
/ *
·
...








UART_1SendOneByte(temper[0]);
UART_1SendOneByte(temper[1]);
UART_1SendOneByte(temper[2]);
UART_1SendOneByte('
);
UART_1SendOneByte(0xFF);
ES=1;
}
/*······································Main function·······················································*/
void main()
{
InitUART(); //Serial port initializationwhile
(1)
{

AD_DATA=TLC549ADC(); //Read the current voltage value A/D conversion datasend
(); //Data sendingfor

(n=10;n>0;n--) //10 seconds sending delay
{
delay(1000);
}
}
}

The following is the host program.
#include <STC89C5xRC.H>
#include <intrins.h>
#define uchar unsigned char //unsigned character macro definition variable range 0~255
#define uint unsigned int //unsigned integer macro definition variable range 0~65535


sbit E=P2^5;
sbit RW=P2^6;
sbit RS=P2^7;


sbit key1=P1^1;
sbit key2=P1^2;
sbit beep=P1^3;


uchar code table[] ="C_temper: "; //Current temperature displayuchar
code table1[]="P_temper: "; //Previous temperature displayuchar
temper[10],temper1[10]; //Temperature data display temporary storageuchar
num1=0,flag=0,dat[70]; //Count value, key flag, historical data storage arrayuint
time,AD_value,flag2,rev; //Count per minuteuint
temp1=0,temp2=0,count1=0;
uchar Receive_Buff1[12]; //Receive data cache array


void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void key_scan()
{
if(key1==0)
{
delay(1);
if(key1==0)
{
num1++;
flag=1;
while(!key1);
}
}
if(key2==0)
{
delay(1);
if(key2==0)
{
num1=0;
flag=0;
while(!key2);
}
}
if(num1>100)
num1=0;
}
void wr_com(uchar com)
{
RS=0;
RW=0;
P0=com;
delay(5);
E=1;
delay(5);
E=0;
}


void wr_dat(uchar date)
{
RS=1;
P0=date;
delay(5);
E=1;
delay(5);
E=0;
}


void init()
{
E=0;
wr_com(0x38);
wr_com(0x0c);
wr_com(0x06);
wr_com(0x01);
}


void display(unsigned char *p)//显示//
{
while(*p!='\0')
{
wr_dat(*p);
p++;
delay(1);
}
}


void init_play()//Initialize display
{
wr_com(0x80);
display(table);
wr_com(0xc0);
display(table1);
}


/*·························Serial port transmission initialization function····················*/
void InitUART(void)
{
SCON=0x50; //Serial port working mode 1, 8-bit UART, variable baud rate
TH2=0xFF;
TL2=0xFD; //Baud rate: 115200 crystal oscillator=11.0592MHz
RCAP2H=0xFF;
RCAP2L=0xFD; //16-bit automatic reload value
TCLK=1;
RCLK=1;
C_T2=0;
EXEN2=0; //Baud rate generator working mode
/****************/
TR2=1 ; //Timer 2 starts
ES=1;
EA=1;
}
void init_count()
{
TMOD=0x61;
TCON|=0X01;
TH0=(65536-9216)/256;
TL0=(65536-9216)%256;
EA=1;
ET0=1;
TR0=1;
}
void AD_to_temper()
{ uint i;

temp1=AD_value*100/25.6+32; //Convert the voltage value on the thermal resistor to the temperature value, add compensation
temper[0]=temp1/1000+0x30;
temper[1]=(temp1/100)%10+0x30;
temper[2]=(temp1%100)/10+0x30;
temper[3]='.';
temper[4]=(temp1%100)%10+0x30;
temper[5]='C';


if(flag==0)
{
temper1[0]=rev/1000+0x30;
temper1[1]=(rev/100)%10+0x30;
temper1[2]=(rev%100)/10+0x30;
temper1[3]='.';
temper1[4]=(rev%100)%10+0x30;
temper1[5]='C';
}
if(flag==1)
{
temper1[0]=dat[num1-1]/1000+0x30;
temper1[1]=(dat[num1-1]/100)%10+0x30;
temper1[2]=(dat[num1-1]%100)/10+0x30;
temper1[3]='.';
temper1[4]=(dat[num1-1]%100)%10+0x30;
temper1[5]='C';
}
for(i=0;i<6;i++)
{
wr_com(0xca+i);
wr_dat(temper1[ i]); [ i]
}

for(i=0;i<6;i++)
{
wr_com(0x8a+i);
wr_dat(temper[ i]); [ i]
temper1[ i]=temper[ i];[ i][ i]
}


}
/***************Main function********************/
void main()
{
init();
init_play();//Initialize displayInitUART
(); //Serial port initializationinit_count
();//Initialize timerwhile
(1)
{
key_scan();

AD_to_temper();
if(time>=6000)
{
beep=0;
time=0;
temp2++;
dat[temp2]=temp1;
if(temp2>70)temp2=0;
}
}
}
/************Serial port 1 interrupt processing function****************/
void UART_1Interrupt(void) interrupt 4
{
if(RI==1)
{
RI=0;
ES=0;
Receive_Buff1[count1++]=SBUF;
if(flag2==2&&SBUF==0xFF)
{
count1=0;
AD_value=Receive_Buff1[6]*100+Receive_Buff1[7]*10+Receive_Buff1[8];
rev=temp1;
}
if(SBUF=='
)
{
flag2=2;
}

ES=1;
}
}
void timer0_isr(void) interrupt 1
{
TH0=(65536-9216)/256;
TL0=(65536-9216)% 256;
time++;
}

This post is from RF/Wirelessly

Latest reply

Hello, I am very interested in the ZigBee wireless temperature transmitter you mentioned. I am in the smart home business. My company was founded not long ago and I lack talents in IoT technology. I want to ask if this wireless temperature transmitter can be changed to WiFi, so that the background can monitor the temperature in real time, and the temperature record data can be viewed through the background. If it exceeds the set value, there will be a prompt in the background? Because I don't visit this website often, if you think we can talk in more detail, please add me, Yiba Si'er Liu Si Wu Wu Lingyi. I am really interested, please.   Details Published on 2020-3-30 22:38
 

3

Posts

0

Resources
2
 

Hello, I am very interested in the ZigBee wireless temperature transmitter you mentioned. I am in the smart home business. My company was founded not long ago and I lack talents in IoT technology. I want to ask if this wireless temperature transmitter can be changed to WiFi, so that the background can monitor the temperature in real time, and the temperature record data can be viewed through the background. If it exceeds the set value, there will be a prompt in the background? Because I don’t visit this website often, if you think we can talk in more detail, please add me on WeChat. My phone number is 18842645501. I am really interested, please.

This post is from RF/Wirelessly
 
 

3

Posts

0

Resources
3
 

Hello, I am very interested in the ZigBee wireless temperature transmitter you mentioned. I am in the smart home business. My company was founded not long ago and I lack talents in IoT technology. I want to ask if this wireless temperature transmitter can be changed to WiFi, so that the background can monitor the temperature in real time, and the temperature record data can be viewed through the background. If the set value is exceeded, there will be a prompt in the background? Because I don’t visit this website often, if you think we can talk in more detail, please add me on WeChat, which is also my phone number. I am really interested, please.

This post is from RF/Wirelessly
 
 
 

3

Posts

0

Resources
4
 

Hello, I am very interested in the ZigBee wireless temperature transmitter you mentioned. I am in the smart home business. My company was founded not long ago and I lack talents in IoT technology. I want to ask if this wireless temperature transmitter can be changed to WiFi, so that the background can monitor the temperature in real time, and the temperature record data can be viewed through the background. If it exceeds the set value, there will be a prompt in the background? Because I don't visit this website often, if you think we can talk in more detail, please add me, Yiba Si'er Liu Si Wu Wu Lingyi. I am really interested, please.

This post is from RF/Wirelessly
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

快速回复 返回顶部 Return list