|
@@ -61,14 +61,44 @@ uint32_t readLuxSensor(void)
|
|
|
return lux;
|
|
|
}
|
|
|
|
|
|
-void sendToHTTPServer(uint32_t lux)
|
|
|
+void sendToCHEF_HTTPServer(uint32_t lux)
|
|
|
{
|
|
|
HTTPClient http;
|
|
|
|
|
|
- Serial.print("[HTTP] begin...\n");
|
|
|
+ Serial.print("[HTTP] begin...Chef\n");
|
|
|
// configure traged server and url
|
|
|
// The target web page is: http://chef.suka.se/nashulta/report_nashulta_temp.php?outtemp=10.3
|
|
|
- String str = "http://chef.suka.se/nashulta/report_nashulta_temp.php?outtemp=";
|
|
|
+ String str = "http://192.168.1.110/lux/report_lux.php?lux=";
|
|
|
+ str += lux;
|
|
|
+ str += "&password=";
|
|
|
+ str += LUX_PHP_PASSWORD;
|
|
|
+ http.begin(str);
|
|
|
+
|
|
|
+ Serial.print("[HTTP] GET...\n");
|
|
|
+ // start connection and send HTTP header
|
|
|
+ int httpCode = http.GET();
|
|
|
+
|
|
|
+ // httpCode will be negative on error
|
|
|
+ if(httpCode > 0) {
|
|
|
+ // HTTP header has been send and Server response header has been handled
|
|
|
+ Serial.printf("[HTTP] GET... code: %d\n", httpCode);
|
|
|
+
|
|
|
+ // file found at server
|
|
|
+ if(httpCode == HTTP_CODE_OK) {
|
|
|
+ String payload = http.getString();
|
|
|
+ Serial.println(payload);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void sendToMICKE_HTTPServer(uint32_t lux)
|
|
|
+{
|
|
|
+ HTTPClient http;
|
|
|
+
|
|
|
+ Serial.print("[HTTP] begin...Micke\n");
|
|
|
+ String str = "http://hagaholm.ddns.net/report_lux/report_lux.php?lux=";
|
|
|
str += lux;
|
|
|
http.begin(str);
|
|
|
|
|
@@ -105,8 +135,10 @@ void loop() {
|
|
|
static uint32_t totalLux = 0;
|
|
|
static uint16_t loopCnt = 0;
|
|
|
|
|
|
+ Serial.println("------------------");
|
|
|
Serial.print(millis());
|
|
|
- Serial.println(" mS ------------------");
|
|
|
+ Serial.println(" ms");
|
|
|
+
|
|
|
|
|
|
const uint32_t lux = readLuxSensor();
|
|
|
|
|
@@ -120,12 +152,14 @@ void loop() {
|
|
|
totalLux /= 6;
|
|
|
loopCnt = 0;
|
|
|
|
|
|
- sendToHTTPServer( totalLux );
|
|
|
+ sendToCHEF_HTTPServer( totalLux );
|
|
|
+ sendToMICKE_HTTPServer( totalLux );
|
|
|
}
|
|
|
|
|
|
// Reset the device once every day, as an extra precaution
|
|
|
if( millis() > (1000*60*60*24) ) {
|
|
|
Serial.println("Reseting.....");
|
|
|
+ delay(50000);
|
|
|
ESP.reset();
|
|
|
}
|
|
|
|