Research Station for FC

Dew Point Monitoring System for FogCatchers ----------------

Final Project: Fabduino with its sensors and actuators

 

This is the final project Fabduino, showing the connections to the input and output devices.

The Fabduino is feeded by DHT11, the temperature and humidity values, and calculate the Dew Point. Those values ares shown in the DISPLAY, and sent via wifi to the cloud. Its explained in detail in the final project.

 

The main parts of the sketcf used for Fabduino are

 

 

//.....................................lcd

// include the library code:

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins

//LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

//LiquidCrystal lcd(9, 8, 5, 4, 3, 2);

//LiquidCrystal lcd(9, 8, 5, 4, 1, 0);

LiquidCrystal lcd(8, 7, 6, 5, 4, 3);

//.....................................lcd

 

void setup() {

  Serial.begin(9600); //or use default 115200.

  Serial1.begin(115200);

  Serial1.println("AT");

 

  delay(5000);

 

  if(Serial1.find("OK")){

    //Serial.println("Serial1.find OK");

    connectWiFi();

  }

 

  //.....................................temp

  dht.begin();

  //.....................................temp

 

  //.....................................lcd

  // set up the LCD's number of columns and rows:

  lcd.begin(16, 2);

  // Print a message to the LCD.

  //lcd.print("----------------------------");

  //.....................................lcd

 

}

 

void loop() {

  // put your main code here, to run repeatedly:

 

  // -----------------------------------------t

  char buffer[10];

  delay(2000);

  // 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();

  // Read temperature as Celsius (the default)

  float t = dht.readTemperature();

  // Read temperature as Fahrenheit (isFahrenheit = true)

  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).

  float dp = dewPoint(t,h);

 

 

  Serial.print("Humidity: ");

  Serial.print(h);

  Serial.print(" %\t");

  Serial.print("Temperature: ");

  Serial.print(t);

  Serial.print(" *C ");

  Serial.print(f);

  Serial.print(" *F\t");

  Serial.print("Dew Point: ");

  Serial.print(dp);

  Serial.println(" *C ");

 

  //---------------------------------------------------------------lcd

  // set the cursor to column 0, line 1

  // (note: line 1 is the second row, since counting begins with 0):

  //lcd.setCursor(3, 1);

  lcd.setCursor(0,0);

  lcd.print("Tmp. Hmd. DewP.");

//lcd.print("012345678901234");

  lcd.setCursor(0, 1);

  lcd.print(t);

  lcd.setCursor(5, 1);

  lcd.print(h);

  lcd.setCursor(10, 1);

  lcd.print(dp);

  lcd.setCursor(4, 1);

  lcd.print(" ");

  lcd.setCursor(9, 1);

  lcd.print(" ");

  lcd.setCursor(16, 1);

  lcd.print(" ");

  //---------------------------------------------------------------lcd

 

  tempC = dtostrf(t, 4, 1, buffer);

  dpC = dtostrf(dp, 4, 1, buffer);

  hum=h;

 

  if (isnan(h) || isnan(t) || isnan(f)) {

    Serial.println("Failed to read from DHT sensor!");

    return;

  }

  // -----------------------------------------t

 

  updateTemp();

 

  delay(100);

}

 

void updateTemp(){

  //tempC="77";

  //hum=55.5;

  String cmd = "AT+CIPSTART=\"TCP\",\"";

  cmd += IP;

  cmd += "\",80";

  Serial1.println(cmd);

  delay(2000);

  if(Serial1.find("Error")){

    Serial.println("error");

    return;

  }

  cmd = msg ;

  cmd += "&field1=";     //field 1 for temperature

  cmd += tempC;

  cmd += "&field2=";  //field 2 for humidity

  cmd += String(hum);

  cmd += "&field3=";  //field 3 for dew point

  //cmd += String(dp);

  cmd += dpC;

  cmd += "\r\n";

  //Serial.print("cmd");

  //Serial.println(cmd);

  //Serial.println(cmd);

 

  Serial1.print("AT+CIPSEND=");

  Serial1.println(cmd.length());

  //Serial.print("En uptate Temp acaba de enviar el comando por Serial1....");

  //Serial.println(cmd);

 

  if(Serial1.find(">")){

    Serial1.print(cmd);

    //Serial.println("conecto");

  }

  else{

    //Serial.println("no pudo enviar");

    Serial1.println("AT+CIPCLOSE");

    //Resend...

    error=1;

  }

}

 

boolean connectWiFi(){

  Serial1.println("AT+CWMODE=1");

  delay(2000);

  String cmd="AT+CWJAP=\"";

  cmd+=SSID;

  cmd+="\",\"";

  cmd+=PASS;

  cmd+="\"";

  Serial1.println(cmd);

  delay(5000);

  if(Serial1.find("OK")){

    //Serial.println("conecto.....en Setup");

    return true;

  }else{

        //Serial.println("no conecto.....en Setup");

    return false;

  }

}

 

// dewPoint function NOAA

// reference (1) : http://wahiduddin.net/calc/density_algorithms.htm

// reference (2) : http://www.colorado.edu/geography/weather_station/Geog_site/about.htm

//

double dewPoint(double celsius, double humidity)

{

  // (1) Saturation Vapor Pressure = ESGG(T)

  double RATIO = 373.15 / (273.15 + celsius);

  double RHS = -7.90298 * (RATIO - 1);

  RHS += 5.02808 * log10(RATIO);

  RHS += -1.3816e-7 * (pow(10, (11.344 * (1 - 1/RATIO ))) - 1) ;

  RHS += 8.1328e-3 * (pow(10, (-3.49149 * (RATIO - 1))) - 1) ;

  RHS += log10(1013.246);

 

        // factor -3 is to adjust units - Vapor Pressure SVP * humidity

  double VP = pow(10, RHS - 3) * humidity;

 

        // (2) DEWPOINT = F(Vapor Pressure)

  double T = log(VP/0.61078);   // temp var

  return (241.88 * T) / (17.558 - T);

 

In this video you can see the system working