How cold? (temperature and humidity with Arduino)

I got the Arduino out to do a few temperature readings this week.

I chose a day when the sun was shining and exterior temperature was around the 8 celsius mark.

This is the arduino set up. It uses an Arduino Uno,  a DHT11 (temperature and humidy sensor) and a  YWRobot I2C LCD Screen.

DHT11_I2C_LCD_bb

 

 

 

 

 

 

 

The image is made using http://fritzing.org

So, inside in the room I used to sleep in, the temperature at 11am was 6 degrees. In the attic I insulated and boarded out, and where I now sleep, the temperature was 10 degrees (without a fire on downstairs). That is definitely progress, considering that there is still a section of attic roof and wall to insulate, and that the temperature rises in the attic to 13 or 14 degrees with the fire on.

In the kitchen, the temperature hovered around 8 or 9 degrees. That won’t improve until the new back door arrives… I only ordered it in November, so I’m not holding my breath…

The greenhouse is a great success, though! In full sun it was reading 20 degrees. Give it a couple of weeks and I should be able to plant my tomato seeds, which need 23 degrees to germinate well.

20140303_112218 20140303_112737

 

Here’s the code. It is hacked together from a variety of sources, which I have lost – if you recognise your own code, pease accept my thanks and let me know in the comments so that I can link to you!

/* DHT11 Humidity and Temperature Sensor with LCD ywrobot Display*/

/*—–( Import needed libraries )—–*/
#include <Firmata.h>
#include <dht11.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

/*—–( Declare objects )—–*/
dht11 DHT11;

/*—–( Declare Constants, Pin Numbers )—–*/
#define DHT11PIN 2
#define I2C_ADDR 0x27 // <<—– Add your address here. Find it from I2C Scanner
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

int n = 1;
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup() /*—-( SETUP: RUNS ONCE )—-*/
{
Serial.begin(9600);
Serial.println(“DHT11 TEST PROGRAM “);
Serial.print(“LIBRARY VERSION: “);
Serial.println(DHT11LIB_VERSION);
Serial.println();
lcd.begin (16,2); // <<—– My LCD was 16×2
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home (); // go home
}/*–(end setup )—*/

void loop() /*—-( LOOP: RUNS CONSTANTLY )—-*/
{
Serial.println(“n”);

lcd.setBacklight(HIGH); // Backlight on
delay(3000);

int chk = DHT11.read(DHT11PIN);

Serial.print(“Read sensor: “);
switch (chk)
{
case 0: Serial.println(“OK”); break;
case -1: Serial.println(“Checksum error”); break;
case -2: Serial.println(“Time out error”); break;
default: Serial.println(“Unknown error”); break;
}

lcd.print(“Humidity (%): “);
lcd.println((float)DHT11.humidity, 2);
lcd.setCursor (0,1); // go to start of 2nd line
lcd.print(“Temp (oC): “);
lcd.println((float)DHT11.temperature, 2);

Serial.print(“Humidity (%): “);
Serial.println((float)DHT11.humidity, 2);

Serial.print(“Temp (oC): “);
Serial.println((float)DHT11.temperature, 2);

delay(5000);
}/* –(end main loop )– */

/*—–( Declare User-written Functions )—–*/
//
//Celsius to Fahrenheit conversion
double Fahrenheit(double celsius)
{
return 1.8 * celsius + 32;
}

//Celsius to Kelvin conversion
double Kelvin(double celsius)
{
return celsius + 273.15;
}

// dewPoint function NOAA
// reference: http://wahiduddin.net/calc/density_algorithms.htm
double dewPoint(double celsius, double humidity)
{
double A0= 373.15/(273.15 + celsius);
double SUM = -7.90298 * (A0-1);
SUM += 5.02808 * log10(A0);
SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;
SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;
SUM += log10(1013.246);
double VP = pow(10, SUM-3) * humidity;
double T = log(VP/0.61078); // temp var
return (241.88 * T) / (17.558-T);
}

// delta max = 0.6544 wrt dewPoint()
// 5x faster than dewPoint()
// reference: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity)
{
double a = 17.271;
double b = 237.7;
double temp = (a * celsius) / (b + celsius) + log(humidity/100);
double Td = (b * temp) / (a – temp);
return Td;
}

/* ( THE END ) */

 

3 thoughts on “How cold? (temperature and humidity with Arduino)

  • 16th March 2014 at 1:54 am
    Permalink

    I am glad I found this. This is exactly what I have been trying to do for days.
    My programming skill are non-existent and I am having trouble with your code….errors?!?!

    I’ll keep working on it and let you know!

    Thank You!

    Reply
    • 18th March 2014 at 9:38 am
      Permalink

      Hey there! It might be the libraries – I downloaded every one I could find relating to the DHT11 and the LCD until I found the right ones! Also worth checki you are using the same output/input pins on the arduino as in the code. Good luck!

      Reply

Leave a Reply

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

?php do_action( 'freedom_before_footer' ); ?>