How to Get Humidity from a Grove Temperature & Humidity Sensor in Arduino

1) Connect the module to the D2 port.

2) Run the following code:

#include <DHT.h>

DHT dht(2, DHT11);

void setup() {
  dht.begin();

  Serial.begin(9600); 

  Serial.println(dht.readHumidity());
}

void loop() {
}
Advertisements

How to Get Temperature from a Grove Temperature & Humidity Sensor in Arduino

1) Connect the module to the D2 port.

2) Run the following code:

#include <DHT.h>

DHT dht(2, DHT11);

void setup() {
  dht.begin();

  Serial.begin(9600); 

  Serial.println(dht.readTemperature());
}

void loop() {
}

How to Get Temperature from a Grove Temperature Sensor in Arduino

1) Connect the module to the A0 port.

2) Run the following code:

#include <math.h>

const int B = 4275; // for v1.1 module

void setup() {
  int v = analogRead(0);

  float r = (float)(1023 - v) * 10000 / v;
  float t = 1 / (log(r / 10000) / B + 1 / 298.15) - 273.15;

  Serial.begin(9600);

  Serial.println(t);
}

void loop() {
}