Estação meteorológica com Itead GBoard

Esta aplicação, como todas as outras baseadas na Gboard, permite construir uma pequena Estação Meteorológica remota.

 

VERSÃO TEMPERATURA e UMIDADE

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;
}

#include <dht11.h>
dht11 DHT11;
#define DHT11PIN A2

#include “SIM900.h”
#include <SoftwareSerial.h>
//We don’t need the http functions. So we can disable the next line.
//#include “inetGSM.h”
#include “sms.h”
#include “call.h”

//To change pins for Software Serial, use the two lines in GSM.cpp.

//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.

//Simple sketch to check if an incoming call is from an authorized
//number and in this case, send to this number an SMS with the value
//of a digital input.

//We have to create the classes for SMSs and calls.
CallGSM call;
SMSGSM sms;

char number[20];
byte stat=0;
int value;
int pin=1;
char value_str[43];
int chk;

String umi=” Umidade relativa= “;
String temper=”Temperatura= “;
String texto=”      “;

void setup()
{
pinMode(pin,INPUT);
//Serial connection.
Serial.begin(9600);
Serial.println(“DHT11 TEST PROGRAM “);
Serial.print(“LIBRARY VERSION: “);
Serial.println(DHT11LIB_VERSION);
//int chk = DHT11.read(DHT11PIN);
Serial.print(“Read sensor: “);

Serial.println(“GSM Shield testing.”);
//Start configuration of shield with baudrate.
//For http uses is raccomanded to use 4800 or slower.
if (gsm.begin(2400))
Serial.println(“\nstatus=READY”);
else Serial.println(“\nstatus=IDLE”);
}

void loop()
{
//Chekcs status of call
stat=call.CallStatusWithAuth(number,0,0);
//If the incoming call is from an authorized number
//saved on SIM in the positions range from 1 to 3. If not put 0,0.

chk = DHT11.read(DHT11PIN);
//Check the value of the input.
value=DHT11.temperature;
temper+=value;
delay(50);
value = DHT11.humidity;
umi+=value;
texto=temper+umi;
texto.toCharArray(value_str, 43);
if(stat==CALL_INCOM_VOICE_AUTH){
//Hang up the call.
call.HangUp();
delay(2000);

//Send an SMS to the previous number with
//the value read previously and conveniently converted from int to string and so to char array.
if(sms.SendSMS(number,value_str)) //”Perimeter Warning System: alarm ativated”);//(number,value_str);
{
Serial.print(“SMS sent to  :”);
Serial.println(number);

}

delay(500);
}
umi=” Umidade relativa= “;
temper=”Temperatura= “;
texto=””;
texto.toCharArray(value_str, 43);
}

Deixe um comentário