Hi
I( am traying to connect my Yun with DHT11 to MYSQL but the values I get from Temeperature and humidity are transfered to MYsql with “0” values even in Screen the values are showed correctly.
If I write this
client.get("http://wi-sen.esy.es/dht11/sensorarduino.php?temperature=t&humidity=h");
The values loaded in MYSQL are “0”
But instead this I write directly a value for temperature and a value for humidity like this
client.get("http://wi-sen.esy.es/dht11/sensorarduino.php?temperature=5&humidity=6");
Then these values are correctly storage in MySQL "5" temperature and HUmidity "6"
This is the code: I will thanks any help!.
#include <Bridge.h>
#include <HttpClient.h>
#include <YunClient.h>
#include <YunServer.h>
#include <DHT.h>
#define DHTPIN 2 // pin de salida
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Bridge.begin();
Serial.begin(9600);
Serial.println("DHT11 test!");
dht.begin();
while(!Serial);
}
void loop() {
// Initialize the client library
HttpClient client;
int h = dht.readHumidity();
int t = dht.readTemperature();
// Make a HTTP request:
client.get("http://wi-sen.esy.es/dht11/sensorarduino.php?temperature=t&humidity=h");
if (isnan(t) || isnan(h)) {
Serial.println("Failed to read from DHT");
} else {
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C");
}
delay(10000);
Serial.flush();
}
Regards
Óscar