PIC16F877A With DHT11 sensor and ST7735 TFT – CCS C

Interfacing PIC16F877A with DHT11 sensor and ST7735R SPI color TFT display
PIC16F877A ST7735 TFT DHT11 sensor hardware circuit

This post shows how to interface PIC16F877A microcontroller with DHT11 relative humidity and temperature sensor and 1.8″ ST7735R SPI TFT display.
DHT11 sensor is a digital device used to sense relative humidity and temperature and convert that data into digital signals. For more details about this type of sensors and how to interface it with PIC16F877A microcontroller see the following two topics:
Interfacing PIC16F877A with DHT11 (RHT01) sensor Proteus simulation
Interfacing DHT11 relative humidity and temperature sensor with PIC16F877A

And to see how to interface PIC16F877A with ST7735 SPI TFT display read the following topic:
ST7735 1.8″ TFT display with PIC16F877A example

Components List:

  • PIC16F877A Microcontroller
  • ST7735R SPI TFT Display
  • DHT11 (RHT01) Sensor
  • 8MHz Crystal oscillator
  • 2 x 22pF Capacitors
  • 10K Resistor
  • 4.7K Resistor
  • 5 x 1K Resistors
  • +5V Power Supply Source
  • Breadboard
  • Jumper Wires

PIC16F877A With DHT11 sensor and ST7735 SPI TFT circuit:

PIC16F877A ST7735 TFT DHT11 sensor interfacing circuit

PIC16F877A With DHT11 sensor and ST7735 SPI TFT CCS C code:
PIC16F877A hardware SPI module is used in this project..
ST7735 SPI TFT driver is required to compile this code, download link in this topic:
ST7735 SPI TFT Display Driver for CCS PIC C compiler
The code is has been tested with versions 4.068 and 5.051.

PIC16F877A With DHT11 sensor and ST7735 SPI TFT video:
This video shows a simple hardware circuit of this project.

6 comments

  1. I have made an automation home system which a pic16f877a works as a master that collect data and send them to a pic16876a(works as a slave) that excecute commands. Now i want to put temperature sensors on each room, but i dont want to use 16×2/ 20×4 LCD screen (with HD44780 controller) because of too many cables. Is it possible to add a ST7735 TFT as a slave?

    1. Yes of course, instead of the 20×4 or 16×2 LCD you could use other ones such as the ST7735 color TFT or SSD1306 OLED monochrome display which uses I2C protocol (2 lines only + reset line between the MCU and the display).

  2. Sorry i forgot to say that pic877a and pic 876a communicate to each other with spi protocoll.

    #define SPI_MODE_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H)
    #define SPI_MODE_1 (SPI_L_TO_H)
    #define SPI_MODE_2 (SPI_H_TO_L)
    #define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H)

    setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_16);

    setup_spi(SPI_SLAVE | SPI_MODE_0);

    According to ST7735 color TFT driver do i have to change from SPI_CLK_DIV_16 to SPI_CLK_DIV_4
    and SPI_MODE from 0 to 3?

    1. i mean in my system i use for mster’s program the following command
      setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_XMIT_L_TO_0 | SPI_CLK_DIV_16);
      and for the slave’s program i use this command
      setup_spi(SPI_SLAVE | SPI_L_TO_H | SPI_XMIT_L_TO_H);

      If i want to add the ST7735 color TFT intomy system do i have to change these commnds?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.