Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] wireless thermometer using RF Tx & Rx. help!

Status
Not open for further replies.

swtbbert

Newbie level 5
Joined
Nov 24, 2013
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
11
Activity points
54
Hi!
I've designed a thermometer using RF by pic16f877a, my problem is how con i read the value to the second pic and to display it, please some1 can help..

my codes for TX

Code:
// LCD module connections
sbit LCD_RS at RB2_bit;    // rs connection at rb2
sbit LCD_EN at RB3_bit;    // en connection at rb3
sbit LCD_D4 at RB4_bit;    // d4 connection at rb4
sbit LCD_D5 at RB5_bit;    // d5 connection at rb5
sbit LCD_D6 at RB6_bit;    // d6 connection at rb6
sbit LCD_D7 at RB7_bit;    // d7 connection at rb7


sbit LCD_RS_Direction at TRISB2_bit;    // data direction setting
sbit LCD_EN_Direction at TRISB3_bit;    // data direction setting
sbit LCD_D4_Direction at TRISB4_bit;    // data direction setting
sbit LCD_D5_Direction at TRISB5_bit;    // data direction setting
sbit LCD_D6_Direction at TRISB6_bit;    // data direction setting
sbit LCD_D7_Direction at TRISB7_bit;    // data direction setting
// End LCD module connections


float volt,temp;                  // VARIABLE FOR READING AND STORING VALUES
unsigned char   volt_char[15];    // STRING (ARRAY OF CHARACTERS) VARIABLE FOR LCD DISPLAY




void init() // initialization routine definition (register initializations are done here)

{
 adcon1=0   ;    // configure all portA and portE chanels as analog
 trisc=0x00;
 portc=0;
 trise = 0x2;
 cmcon = 7;
 lcd_init() ;    // initialize lcd connections
 lcd_cmd(_lcd_clear)     ;// clear lcd
 lcd_cmd(_lcd_cursor_off);// turne off hte cursor
}




void main() // main routine definition
{
 init();    // call the initialization routine
 lcd_out(1,3,"Temperature"); // show <voltmeter> on 3rd column of first row of lcd
 lcd_chr(2,12,223);
 lcd_out(2,13,"C");        // show <V> on 15th column of 2nd row of lcd
 uart1_Init(9600);
 delay_ms(100);

 while(1)   // step into infinite loop
   {

    volt=adc_read(2); // take the analog signal value fron analog channel 2 (latched to ra2 pin)

    volt=volt/1024;   // extracting voltage value from 10 bit resolution
    volt=volt*5000;   // extracting voltage value from 10 bit resolution
    temp=volt/10;     // CONVERTING THE VOLTAGE VALUE TO CENTIGRADE SCALE

    floattostr(temp,volt_char);// convert the voltage value to string for
                                  //showing on lcd
    lcd_out(2,4,volt_char);    // show the string (voltage value) on
                                  //lcd(2nd row,1st column)
    uart1_Write_Text(volt_char);
    UART1_Write(10);
    UART1_Write(13);
    delay_ms(200);
..........



for RX
// LCD module connections
sbit LCD_RS at RB2_bit;    // rs connection at rb2
sbit LCD_EN at RB3_bit;    // en connection at rb3
sbit LCD_D4 at RB4_bit;    // d4 connection at rb4
sbit LCD_D5 at RB5_bit;    // d5 connection at rb5
sbit LCD_D6 at RB6_bit;    // d6 connection at rb6
sbit LCD_D7 at RB7_bit;    // d7 connection at rb7


sbit LCD_RS_Direction at TRISB2_bit;    // data direction setting
sbit LCD_EN_Direction at TRISB3_bit;    // data direction setting
sbit LCD_D4_Direction at TRISB4_bit;    // data direction setting
sbit LCD_D5_Direction at TRISB5_bit;    // data direction setting
sbit LCD_D6_Direction at TRISB6_bit;    // data direction setting
sbit LCD_D7_Direction at TRISB7_bit;    // data direction setting
// End LCD module connections

unsigned char volt_char[15];
char txt;
char uart_rd;
float volt, temp;

void main() // main routine definition
{
 uart1_Init(4800);
 delay_ms(100);
 cmcon = 7;
 adcon1=0   ;    // configure all portA and portE chanels as analog
 trisc = 0x00;
 portc = 0;
 lcd_init() ;    // initialize lcd connections
 lcd_cmd(_lcd_clear)     ;// clear lcd
 lcd_cmd(_lcd_cursor_off);// turne off hte cursor
 lcd_out(1,3,"Temperature"); // show <temperature> on 3rd column of first row of
 lcd_chr(2,12,223);
 lcd_out(2,13,"C");        // show <C> on 13th column of 2nd row of lcd

do
{
if(uart1_Data_Ready()){
 uart_rd = uart1_Read();
 ByteToStr(uart_rd,volt_char);
 lcd_out(2,4,volt_char);
 uart1_Write(volt_char);
}
}while(1);
}
 
Last edited by a moderator:

Try these codes.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
//Tx Code
 
// LCD module connections
sbit LCD_RS at RB2_bit;    // rs connection at rb2
sbit LCD_EN at RB3_bit;    // en connection at rb3
sbit LCD_D4 at RB4_bit;    // d4 connection at rb4
sbit LCD_D5 at RB5_bit;    // d5 connection at rb5
sbit LCD_D6 at RB6_bit;    // d6 connection at rb6
sbit LCD_D7 at RB7_bit;    // d7 connection at rb7
 
 
sbit LCD_RS_Direction at TRISB2_bit;    // data direction setting
sbit LCD_EN_Direction at TRISB3_bit;    // data direction setting
sbit LCD_D4_Direction at TRISB4_bit;    // data direction setting
sbit LCD_D5_Direction at TRISB5_bit;    // data direction setting
sbit LCD_D6_Direction at TRISB6_bit;    // data direction setting
sbit LCD_D7_Direction at TRISB7_bit;    // data direction setting
// End LCD module connections
 
 
float volt, temp;                  
unsigned char volt_char[23];      
 
 
void Init(){
 
    TRISB = 0x00;
    PORTB = 0x00;    
    TRISC = 0x80;
    PORTC = 0x00;
    TRISE = 0x02;
    ADCON1 = 0x00;
    CMCON = 0x07;
 
    LCD_Init() ;    
    LCD_Cmd(_LCD_CLEAR);
    LCD_Cmd(_LCD_CURSOR_OFF);
    LCD_Out(1, 4, "Temperature"); 
}
 
 
void main(){
 
    unsigned char i;
 
    Init();     
            
    UART1_Init(9600);
    Delay_ms(100);
 
    while(1){   
    
            volt = ((adc_read(2) * 500) / 1023); 
            FloatToStr(volt, volt_char);
                LCD_Out(2, 4, volt_char);
            LCD_Chr(2, 12, 223);
            LCD_Out(2, 13, "C");    
                
        i = 0;
        while(volt_char[i++]);
 
            volt_char[i] = ' ';
            volt_char[i + 1] = 223;
            volt_char[i + 2] = 'C';
            volt_char[i + 3] = '\r';
            volt_char[i + 4] = '\n';
            volt_char[i + 5] = '\0';
                  
            UART1_Write_Text(volt_char);
            UART1_Write(10);
            UART1_Write(13);
 
            Delay_ms(500);
    }
}
 
 
//RX Code
 
// LCD module connections
sbit LCD_RS at RB2_bit;    // rs connection at rb2
sbit LCD_EN at RB3_bit;    // en connection at rb3
sbit LCD_D4 at RB4_bit;    // d4 connection at rb4
sbit LCD_D5 at RB5_bit;    // d5 connection at rb5
sbit LCD_D6 at RB6_bit;    // d6 connection at rb6
sbit LCD_D7 at RB7_bit;    // d7 connection at rb7
 
 
sbit LCD_RS_Direction at TRISB2_bit;    // data direction setting
sbit LCD_EN_Direction at TRISB3_bit;    // data direction setting
sbit LCD_D4_Direction at TRISB4_bit;    // data direction setting
sbit LCD_D5_Direction at TRISB5_bit;    // data direction setting
sbit LCD_D6_Direction at TRISB6_bit;    // data direction setting
sbit LCD_D7_Direction at TRISB7_bit;    // data direction setting
// End LCD module connections
 
unsigned char volt_char[23];
float volt, temp;
 
 
void Init(){
 
    TRISB = 0x00;
    PORTB = 0x00;    
    TRISC = 0x80;
    PORTC = 0x00;
    TRISE = 0x02;
    ADCON1 = 0x00;
    CMCON = 0x07;
 
    LCD_Init() ;    
    LCD_Cmd(_LCD_CLEAR);
    LCD_Cmd(_LCD_CURSOR_OFF);
 
    LCD_Out(1, 4, "Temperature");    
}
 
void main(){
 
    unsigned char i;
 
    Init();
    
    UART1_Init(9600);
    Delay_ms(100);
 
    while(1){
 
        if(UART1_Data_Ready()){
            UART1_Read_Text(volt_char, "\r\n", 17);
            UART1_Write(volt_char);
 
            i = 0;
            while(volt_char[i] != ' ');
 
            volt_char[i] = '\0';
            LCD_Out(2, 1, volt_char);
            LCD_Chr(2, 12, 223);
            LCD_Out(2, 13, "C");
        }
    }
}

 
Re: wireless thermometer using RF Tx &amp; Rx. help!

Thenx, but at receiver the value doesn't appear on lcd

- - - Updated - - -

Thenx, it work on transmitter but not on receiver...
 

Re: wireless thermometer using RF Tx &amp; Rx. help!

In receiver there was a typo. Use this in receiver code.


Code C - [expand]
1
while(volt_char[i++] != ' ');



If it still doesn't work then use these codes.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//Tx Code
 
// LCD module connections
sbit LCD_RS at RB2_bit;    // rs connection at rb2
sbit LCD_EN at RB3_bit;    // en connection at rb3
sbit LCD_D4 at RB4_bit;    // d4 connection at rb4
sbit LCD_D5 at RB5_bit;    // d5 connection at rb5
sbit LCD_D6 at RB6_bit;    // d6 connection at rb6
sbit LCD_D7 at RB7_bit;    // d7 connection at rb7
 
 
sbit LCD_RS_Direction at TRISB2_bit;    // data direction setting
sbit LCD_EN_Direction at TRISB3_bit;    // data direction setting
sbit LCD_D4_Direction at TRISB4_bit;    // data direction setting
sbit LCD_D5_Direction at TRISB5_bit;    // data direction setting
sbit LCD_D6_Direction at TRISB6_bit;    // data direction setting
sbit LCD_D7_Direction at TRISB7_bit;    // data direction setting
// End LCD module connections
 
 
float volt, temp;                  
unsigned char volt_char[23];      
 
 
void Init(){
 
    TRISB = 0x00;
    PORTB = 0x00;    
    TRISC = 0x80;
    PORTC = 0x00;
    TRISE = 0x02;
    ADCON1 = 0x00;
    CMCON = 0x07;
 
    LCD_Init() ;    
    LCD_Cmd(_LCD_CLEAR);
    LCD_Cmd(_LCD_CURSOR_OFF);
    LCD_Out(1, 4, "Temperature"); 
}
 
 
void main(){
 
    unsigned char i;
 
    Init();     
            
    UART1_Init(9600);
    Delay_ms(2000);
 
    while(1){   
    
            volt = ((adc_read(2) * 500) / 1023); 
            FloatToStr(volt, volt_char);
                LCD_Out(2, 4, volt_char);
            LCD_Chr(2, 12, 223);
            LCD_Out(2, 13, "C");    
                
        i = 0;
        while(volt_char[i++]);
 
            volt_char[i] = ' ';
            volt_char[i + 1] = 223;
            volt_char[i + 2] = 'C';
            volt_char[i + 3] = '\r';
            volt_char[i + 4] = '\n';
            volt_char[i + 5] = '\0';
                  
            UART1_Write_Text(volt_char);
            
            Delay_ms(500);
    }
}
 
 
//RX Code
 
// LCD module connections
sbit LCD_RS at RB2_bit;    // rs connection at rb2
sbit LCD_EN at RB3_bit;    // en connection at rb3
sbit LCD_D4 at RB4_bit;    // d4 connection at rb4
sbit LCD_D5 at RB5_bit;    // d5 connection at rb5
sbit LCD_D6 at RB6_bit;    // d6 connection at rb6
sbit LCD_D7 at RB7_bit;    // d7 connection at rb7
 
 
sbit LCD_RS_Direction at TRISB2_bit;    // data direction setting
sbit LCD_EN_Direction at TRISB3_bit;    // data direction setting
sbit LCD_D4_Direction at TRISB4_bit;    // data direction setting
sbit LCD_D5_Direction at TRISB5_bit;    // data direction setting
sbit LCD_D6_Direction at TRISB6_bit;    // data direction setting
sbit LCD_D7_Direction at TRISB7_bit;    // data direction setting
// End LCD module connections
 
unsigned char volt_char[23];
float volt, temp;
 
 
void Init(){
 
    TRISB = 0x00;
    PORTB = 0x00;    
    TRISC = 0x80;
    PORTC = 0x00;
    TRISE = 0x02;
    ADCON1 = 0x00;
    CMCON = 0x07;
 
    LCD_Init() ;    
    LCD_Cmd(_LCD_CLEAR);
    LCD_Cmd(_LCD_CURSOR_OFF);
 
    LCD_Out(1, 4, "Temperature");    
}
 
void main(){
 
    unsigned char i;
 
    Init();
    
    UART1_Init(9600);
    Delay_ms(100);
 
    while(1){
 
        while(!UART1_Data_Ready());
 
        UART1_Read_Text(volt_char, "\r\n", 17);
        UART1_Write(volt_char);
 
        i = 0;
        while(volt_char[i++] != ' ');
 
        volt_char[i] = '\0';
        LCD_Out(2, 1, volt_char);
        LCD_Chr(2, 12, 223);
        LCD_Out(2, 13, "C");
        
    }
}

 

Re: wireless thermometer using RF Tx &amp; Rx. help!

It still not responding, may be my circuit has problem.
Untitled.gif
 

My code works. I will test it if you zip and send me your mikroC Tx and Rx project files and Proteus .dsn file. I don't have Proteus 8 so, only Proteus 7.x file. In Proteus the LCD power pins have wrong connections. You have to connect VDD to +5V and VSS to GND but that doesn't make any difference in Proteus simulation.
 

that is my project
 

Attachments

  • Tets Temp.rar
    76.9 KB · Views: 53

You didn't attach the Proteus file.

Edit: Debug and see why UART is not displaying degree character and 'C'.
 

Attachments

  • RF.rar
    88.6 KB · Views: 54
Last edited:
thank you it is working.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top