Humidity sensor Schematics Photo Sample code 01
02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 // where is the humidity sensor connected to? int humPin = 0; void setup() { // initialise the serial output Serial.begin(115200); } void loop() { // fix temperature (if you can get it from a temperatur sensor, please do so!) double temperatureC = 20; // read the value from the pin int humReading = analogRead(humPin); // convert it into voltage (Vcc = 5V) double volt = humReading / 1023.0 * 5; // calculate the sensor humitidy double sensorRH = 161.*volt/5 - 25.8; // adapt this for the given temperature double trueRH = sensorRH / (1.0546 - 0.0026*temperatureC); // print it to the serial output Serial.println(trueRH); // wait a second delay(1000); } Links |