Microcontrollers Projects

wireless thermometer using a PIC microcontroller

In this tutorial, we will show you a way to make a wireless thermometer using two PIC microcontrollers. One of the microcontrollers (PIC16F688) measures the voltage from the LM34 and converts it into an ADC value which is then sent out. The receiver will receive the data and then display the message on the LCD.

Sending data using the 433MHz transmitter is simple: in this case we connect the TX pin of the PIC microcontroller to the data pin of the 433MHz module, and the transmitter will then send whatever signal is generated by the UART pin.

But the receiving data part is the harder part. The receiver will receive everything within its range. To sort out the data we want, we need some kind of protocol or error correction mechanism. In a previous article, I used a VirtualWire library for Arduino. In this article, I will use another technique. Now, add parity to the transmitted data at the sending end, and then check the parity at the receiving end. While writing this article, I found a website that has a VirtualWire library for PIC . However, one disadvantage of this library is that it almost fills up the memory of the PIC.

Required Materials

●    MPLAB X IDE integrated development environment

● PIC16F688 microcontroller

● LM34 sensor

● PIC16F877A microcontroller

● LCD1602 liquid crystal display

● 433MHz RF module (transmitter and receiver)

● Breadboard

Hardware Block Diagram

Below is the functional block diagram of the sending and receiving parts.

Transmitter part :

wireless thermometer using a PIC microcontroller

Functions implemented:

● Methods for programming microcontrollers -> ICSP

● Sensor to measure temperature -> LM34

● Microcontroller for processing data -> PIC16F688

● Method of sending data – > 433MHz RF TX module

Receiving part:

wireless thermometer using a PIC microcontroller

Functions implemented:

● Programming microcontrollers -> ICSP

● Display message-> LCD1602 liquid crystal display

● Microcontroller for processing data -> PIC16f877A

● Receive RF signal -> 433MHz RF RX module

Circuit diagram:

Transmitter part:

wireless thermometer using a PIC microcontroller

Receiving part:

wireless thermometer using a PIC microcontroller

Unused pins are not connected to GND or test points. All schematics are not for production, they are for breadboard only.

How the software works

Transmitter part:

When the program runs, it reads the voltage from the LM34. This voltage is converted to an ADC value. This value is then calculated as Fahrenheit and Celsius. Depending on some if-sentences, the value is passed to the uart_write function. This function checks if the value is valid and transfers it to the uarttransmit -function. This function adds a parity check to the data and then sends it to the TXREG.

This type of transmitter always sends data when powered on, which can interfere with other wireless devices operating in the same frequency range. Garage door keys and remote ceiling fans may not respond correctly when the transmitter is on. To solve this problem, we will turn on the RF transmitter only when data needs to be sent and turn it off when data is not needed.

Receiving part:

The receive section picks up various signals and noise. The software has some debugging code and a MAX232 for seeing what is happening in a terminal window. When a signal is picked up, the Frame Error bits for that frame are checked. If the value has a Frame Error, the received data is set to NULL. The value is then checked for the Overrun Error bit. If the Overrun Error bit check fails, RCSTAbits.CREN is reset. If the received value passes both of these tests, the received data is not garbage, and then the parity is calculated. If the calculated parity is equal to the received parity, the value is valid, and then actions are taken based on some if statements.

After checking the received data and confirming it, the PIC displays a message on the LCD display. To make the LCD work with the microcontroller, I have used the library files installed with the XC8 compiler. All the source files are added in one lcd_lib.c file.

During development I added a MAX232 to a breadboard and connected it to my computer. This way I could easily see what was being sent by the EUSART ports on both PICs.

wireless thermometer using a PIC microcontroller

Summarize

In this project, we have shown you how to make a wireless thermometer using 2 PIC microcontrollers, LM34 sensor and LCD1602. The temperature is measured using a PIC microcontroller and the ADC value is calculated. Based on the calculation, the data is formatted and sent to the USART port. The receiver checks for errors and when it is found, a message is displayed on the LCD1602.

Back to top button
error: Content is protected !!