Interfacing Raspberry Pi Pico With 0.96″ IPS Display And DHT22 Using Arduino IDE

Introduction

In this tutorial today, we shall see how to interface the Raspberry Pi Pico with 0.96″ IPS display and dht22 sensor using the Arduino ide.

Video

Hardware Preparation

For this tutorial we will need the following components

3
DCIM\101MEDIA\DJI_0277.JPG

Building The Circuit

The connection between the Raspberry Pi Pico, 0.96″ IPS display and DHT22 are as shown below.

pipico dht11 st7735 bb

Please do note that the Arduino shown in the image above is the classic Arduino Nano. I have this, because there is no library for Maker Nano RP2040 yet inside the Fritzing.

Code

Below is the complete code that we have used in this tutorial

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>
#include "DHT.h"

#define DHTPIN 2
#define DHTTYPE DHT22   
 
#define TFT_CS     10
#define TFT_RST    7
#define TFT_DC     9
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

DHT dht(DHTPIN, DHTTYPE);
 
void setup(void) {
  tft.initR(INITR_MINI160x80); //Initializes ST7735.
  //Please note that use of 'MINI160x80' displays cyan instead of yellow and vice versa.
  dht.begin();
  
  tft.setRotation(3);
  tft.fillScreen(ST7735_BLACK);
 
  tft.setCursor(5, 5);
  tft.setTextColor(ST7735_RED); 
  tft.setTextSize(2);
  tft.println("   Pi Pico   ");
  tft.setCursor(5, 25);
  tft.setTextColor(ST7735_GREEN);
  tft.setTextSize(2);
  tft.println("   DHT22   ");
  tft.setCursor(5, 45);
  tft.setTextColor(ST7735_BLUE);
  tft.setTextSize(2);
  tft.print("0.96 Display");

  delay(2000);
 
}
 
void loop()
{

  delay(200);
  tft.fillScreen(ST7735_BLACK);

   float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true);

  Serial.print(F("Humidity: "));
  Serial.print(h);
  Serial.print(F("%  Temperature: "));
  Serial.print(t);
  Serial.print(F("°C "));
  
  tft.setCursor(5, 20);
  tft.setTextColor(ST7735_RED); 
  tft.setTextSize(2);
  tft.print("Temp:");
  tft.print(t);
  tft.print("C");


  tft.setCursor(5, 40);
  tft.setTextColor(ST7735_GREEN);
  tft.setTextSize(2);
  tft.print("Humid:");
  tft.print(h);

  
}

Thank You

Thanks for reading this tutorial. If you have any technical inquiries, please post at Cytron Technical Forum.

Please be reminded, this tutorial is prepared for you to try and learn.
You are encouraged to improve the code for a better application.

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

Detect RGB Color With Raspberry Pi Pico
Build an IoT Project Using LoRaWAN Network with Cytron LoRa-RFM Shield and Helium Console
Measure Soil Moisture Sensor Using Raspberry Pi Pico And Maker Soil Moisture Sensor
Getting Started Raspberry Pi Compute Module 4 Lite And Mini Base (A) Board (CM4-IO-BASE-A)
Measure The Ambient Temperature With Raspberry Pi Pico And Grove Temperature Sensor Using Arduino IDE
Tutorials of Cytron Technologies Scroll to Top