Hello all!
I guess many off have all ready build your own weather station, and now it is my turn.
I did start to put together a sketch, taking a little from here and there.
I am using an UNO board for my prototyping, but I will use a NANO board later.
Reading a DHT11 #define DHTPIN 6
Serial.print: temp C, F is working, Relative Humidity Working, dew point C, F working
So the first problem:
Serial.print("C ");
Serial.print(heatIndex(tF,h));
Serial.println("F ");
// working
But I can not figure out to Serial.print in Celsius, on the same line
Second problem:
Print to the LCD display, using:
#include <LiquidCrystal.h>
LiquidCryatal lcd(12, 11, 5, 4, 3, 2);
But I can not get it to work, trying different methods, without any success.
Those are the first thing I like to get it to work, on one UNO/nano board, DHT11 sensor and a LCD.
Later I like to have wind-speed and direction, barometric pressure, using BMP085 sensor.
And them will come reading CO, CO2 using the MQ sensors. Finally , solar radiation (what sensor to use I do not know),
and lightning detection using a AS3935 module.
But first ting first
Can someone kindly help me figure out some of those thing, first the DHT11 sensor Seriel.print and LCD print.
Will be much appreciated.
Will be much appreciated,
Thank You.
Joe in the Phills
Here is my sketch:
#include <DHT.h>
#include <LiquidCrystal.h>
// what pin DHT11 is connected to.
#define DHTPIN 6
// initialize the library with the numbers of the interface pins
//LiquidCrystal lcd(5, 4, 23, 22, 21, 20);
LiquidCryatal lcd(12, 11, 5, 4, 3, 2);
// Uncomment for the type we’re using
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from
// pin 2 (data) to pin 1 (power) of the sensor
DHT dht(DHTPIN, DHTTYPE);
float tF;
float dP;
float dPF;
void setup() {
Serial.begin(9600);
Serial.println(“Serial reading DHT11 Sensor using Digital pin 6”);
// Serial.println(“by Joe Fox”);
dht.begin();
}
void loop() {
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds ‘old’
// its a very slow sensor
float h = dht.readHumidity();
float t = dht.readTemperature();
// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h)) {
Serial.println(“Failed to read from DHT”);
} else {
Serial.print("Relative Humidity: ");
Serial.print(h);
Serial.print(“%\t”);
Serial.print("Temperature: ");
Serial.print(t);
Serial.print("C ");
tF=((t*9)/5)+32;
Serial.print(tF);
Serial.print("F ");
Serial.print(" \t");
Serial.print("Dew Point: ");
Serial.print(dewPointFast(t, h));
Serial.print("C ");
dP=(dewPointFast(t, h));
dPF=((dP*9)/5)+32;
Serial.print(dPF);
Serial.print(“F”);
Serial.print(" \t");
Serial.print("Heat Index: ");
// Serial.print{“heatIndex”); // print serial Heat Index C
Serial.print("C ");
Serial.print(heatIndex(tF,h));
Serial.println("F ");
///////////////////////// do not work
{
lcd.setCursor(0, 0);
lcd.print(“Temp”);
}
////////////////////////
}
}
// delta max = 0.6544 wrt dewPoint()
// 6.9 x 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*0.01);
double Td = (b * temp) / (a - temp);
return Td;
}
double heatIndex(double tempF, double humidity)
{
double c1 = -42.38, c2 = 2.049, c3 = 10.14, c4 = -0.2248, c5= -6.838e-3, c6=-5.482e-2, c7=1.228e-3, c8=8.528e-4, c9=-1.99e-6 ;
double T = tempF;
double R = humidity;
double A = (( c5 * T) + c2) * T + c1;
double B = ((c7 * T) + c4) * T + c3;
double C = ((c9 * T) + c8) * T + c6;
double rv = (C * R + B) * R + A;
return rv;
}