Want a cool project for your PIC microcontroller? Read on!

Requirements

 

Introduction

In this article, I'll show you one way to make a wireless thermometer using two PIC microcontrollers. One microcontroller, the PIC16F688, will measure voltage from an LM34, convert it to an ADC value, and transmit some data. The receiver will receive the data, and display a message on an LCD.

Sending data with the 433MHz transmitter is easy: in my case, I connect the PIC TX pin to the 433MHz data pin, then the transmitter sends whatever comes out the UART pin.

But receiving the data is the far more difficult part. The receiver will receive everything in its range. To sort out the data we want, we need some sort of protocol or error correction. In previous articles, I have used an Arduino with the VirtualWire library, and I have used a "synchronizing" string in another. In this article, I'm using another technique (this site inspired me). Now, I'm adding parity check to the transmitted data. The parity is being checked at the receiver end. While doing research for this article, I found a site with a VirtualWire library for PIC's. One drawback I found, however, was that this library filled almost all my PICs memory.

 

Hardware

We need 2 block diagrams, one for each circuit.

The transmitter:

I want:

  • A way to program the microcontroller -> ICSP
  • A sensor to measure temperature -> LM34
  • A microcontroller to process the data -> PIC16F688
  • A way to transmit the data -> 433MHz RF TX module

The receiver:

I want:

  • A way to program the PIC16F877A
  • A way to receive the RF signal -> 433MHz RF RX module
  • A way to process the received data -> PIC16f877A
  • A way to display a message -> 2x16 LCD

 

Schematic diagrams:

Transmitter:

 

Receiver:

 

In the pictures below, you will see a MAX232 IC. This is added for debugging.

Unused pins are not tied to GND or to a testpad. None of the schematics are for production, they are for breadboard only.

 

Parts list

 

Software

Transmitter:

When the program runs, it reads the voltage from the LM34. This voltage is converted into an ADC value. This value is then calculated to temperatures in both Fahrenheit and Celsius. According to a few if-sentences, a value is transferred to the uart_write-function. This function checks if the value is valid, and transfers it to the uarttransmit- function. This function adds parity to the data, and sends it out to the TXREG.

This type of transmitters send all the time when power is applied, which results in interference with other wireless appliances working in the same  frequency range. Garage door openers and remote controlled ceiling fans might not respond correctly when the transmitter is on. To deal with that, I turn the transmitter on when it is transmitting and off when it is not transmitting. 

Receiver:

The receiver picks up all kinds of signals and noise. The software has some debugging code and a MAX232 to see what's happening in a terminal window. When a signal is picked up, the value is checked for Framing Error bit. If the value has a framing error, the received data is set to NULL. Then the value is checked for the Overrun Error bit. If the Overrun Error bit check fails, the RCSTAbits.CREN is reset. If the received value passes those two tests, the received data is not garbage and parity is calculated. If the calculated parity is equal to the received parity, the value is valid and actions according to some if-sentences are taken.

When the received data is checked and OK, the PIC displays a message on the LCD-display. To make the LCD work with the microcontroller, I used the library files that are installed with the XC8 compiler. All the source files are added to one lcd_lib.c file. The LCD library files are included in the ZIP file below.

During development, I added a MAX232 IC to my breadboards. This was connected to my computer. That way it was easy for me to actually see what was sent out the EUSART-port on both the PICs.

 

Downloads

 

  PIC16F688 Code     PIC16F877A Code  


Conclusion

In this article I have shown you how to make a wireless thermometer with 2 PIC microcontrollers, an LM34 and an LCD. The temperature is measured with one PIC, and an ADC value is calculated. According to the calculations, the data is formatted and sent out the EUSART port. The receiver checks for errors and when all is ok, a message is displayed on the LCD.

 

Pictures and Video

 


Comments

17 Comments


  • ViktorRRS 2015-12-06

    Hello Jens,
      very neat and simple to understand and article. I just can’t understand the Transmitter Block in the Transmitter Schematic Diagram. According to the text the ‘TX-MODULE’ PIN should shut-down the RF transmitter supply power. But in this schematic it looks for me that the PIN just blinks a LED…

    • Jens Christoffersen 2015-12-22

      Hi, thanks. Above R2, there’s a wire going to JP4. The transmitter is placed in JP4. When the LED is on, the transmitter is on.

  • Rohit khamdekar 2016-01-01

    Plz can you provide me actual circuit diagram of this…..plz it will be very helpful to me for my college level project

  • munyap 2016-02-12

    can you please provide a schematic diagram of this wireless thermometer because I am failing to understand the provided diagrams since they are broken into blocks

  • mogbolahan 2016-02-17

    Can I use pickit 3 to transfer the code to the PIC? Also, I realised that the zip file for the receiver station has two programs—one for the lcd and one for the PIC. How doe that work? I mean, how do I transfer the code to the lcd?

    • munyap 2016-02-18

      how can I exclude the ICSP connections because I want to burn the program to the PICs whilst outside the circuit. can it be possible, thanks in advance

      • Jens Christoffersen 2016-02-18

        If you don’t want the ICSP header, you can skip it. The only thing that is important, is that you have a 10K resistor from MCLR to +5v.

    • Jens Christoffersen 2016-02-18

      Hi. Yes, the PICKit 3 would work great. The ZIP file on the receiver, is the MPLAB X project folder. You don’t transfer the files to the LCD, but to the PIC16F877A. It should work if you open the project in MPLAB X, and compiled the C file.

      • mogbolahan 2016-04-01

        Thanks so much for the tutorial. I have tried almost everything I know of. However, the LCD only displays black square blocks. I really know what I am doing wrong. I need your help please. I really want to get this to work

  • munyap 2016-02-19

    thanks, is it possible to use the same source cord as yours even if I am going to programme the PICs out of circuit? is there something that need to be changed on Configurations of the source cord

  • life 2016-06-15

    Pls I wish to attache a second temperature sensor, to be covered with a wet cloth so as to read wet bulb temperature such that both dry bulb and wet bulb temperature are shown on the display,can you help me on that?

  • Carlo Ferraresi 2016-12-04

    Did you measure the Power consumption? It would be great to run the thermostat by battery. I think that 433Hz transmitter is most demanding module, the micro can wait in low-power mode for next acquisition