GSM PHP MySQL Datatransfer - Ino
GSM PHP MySQL Datatransfer - Ino
}
}
}
void Read_sensor( ) {
float media;
for (i=0; i< NUMAMOSTRAS; i++) {
amostra[i] = analogRead(PINOTERMISTOR);
delay(10);
}
media = 0;
for (i=0; i< NUMAMOSTRAS; i++) {
media += amostra[i];
delay(1000);
}
media /= NUMAMOSTRAS;
// Convert the thermal stress value to resistance
media = 1023 / media - 1;
media = SERIESRESISTOR / media;
//Calculate temperature using the Beta Factor equation
temperature = media / TERMISTORNOMINAL;
// (R/Ro)
temperature = log(temperature); // ln(R/Ro)
temperature /= BCOEFFICIENT;
// 1/B * ln(R/Ro)
temperature += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
temperature = 1.0 / temperature;
// Invert the value
temperature -= 273.15;
// Convert it to Celsius
Serial.print("The temperature is: ");
Serial.println(temperature);
}
void Daten_senden() {
//Connect to server and pass the data to php script
Serial.println("connecting...");
// if you get a connection, report back via serial:
if (client.connect(server, port)) {
// Make a HTTP request:
client.print("GET ");
client.print(path);
client.print("?data=");
client.print(temperature);
client.print("&check=");
client.print(key);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(server);
client.println();
Serial.println("Done!");
}
else {
Serial.println("No Connetion");
}
}