To control Humidity Sensor using Raspberry Pi Pico
Required Components
- Humidity Sensor (DHT11)_1 no
- Raspberry Pi Pico Board_1 no
- Connecting wires_1 set
Circuit
Steps
- Make sure the components are working properly.
- Connect the Raspberry Pi Pico board GP16th pin to the Humidity Sensor.
- Connect Humidity Sensor board VCC, GND to 3V3 (OUT), GND of Raspberry Pi Pico Board.
- Check the Electrical Cicuit.
- Check the Arduino program.
- 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");
}