Arduino Tutorials – Lesson 43 – Humidity Sensor on Raspberry Pi Pico

To control Humidity Sensor using Raspberry Pi Pico

Required Components

  1. Humidity Sensor (DHT11)_1 no
  2. Raspberry Pi Pico Board_1 no
  3. Connecting wires_1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the Raspberry Pi Pico board GP16th pin to the Humidity Sensor.
  3. Connect Humidity Sensor board VCC, GND to 3V3 (OUT), GND of Raspberry Pi Pico Board.
  4. Check the Electrical Cicuit.
  5. Check the Arduino program.
  6. Run the Arduino program.

Arduino Program

#include "DHT.h"
#define DHTPIN 16
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

void setup() 
{
  Serial.begin(9600);
  Serial.println("DHTxx test!");
  dht.begin();
}

void loop( )
{
  delay(2000);
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  float f = dht.readTemperature(true);
  
  if (isnan(h) || isnan(t) || isnan(f)) 
  {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }  
  Serial.print ("Humidity: ");
  Serial.print (h);
  Serial.println (" %\t");
  Serial.print ("Temperature: ");
  Serial.print (t);
  Serial.println (" *C ");
  Serial.print (f);
  Serial.println (" *F\t");
}

Leave a Reply

Your email address will not be published. Required fields are marked *