結果はOMG! 何を測っているのか分からなーい! 断熱テープで太陽光を遮っても、容器内に暖められた空気がこもり、この温度を測ってしまっていますね。 太陽電池に太陽光を当てて、且つ周りの雰囲気温度を計測するのは思ったより難しそうです。
今度は、100均で台所で使う少し大きめの網目のPP籠で実験してみることにします。 雨が当たらないように、配置を考える必要があります。
電子的にはあまり問題はありませんが、筐体には結構頭を使わないといけませんね。これは難しい。
結果はOMG! 何を測っているのか分からなーい! 断熱テープで太陽光を遮っても、容器内に暖められた空気がこもり、この温度を測ってしまっていますね。
「ツール」->「ボード」で、LOLIN WeMosがらみの物を指定すると、ちゃんと表示されるようになりました(もっとも、最初に表示されるゴミは相変わらずですが、、、。中国語のバナーかなんかかな?)。
====== Sketch =======
/*
This sketch establishes a TCP connection to a "quote of the day" service.
It sends a "hello" message, and then prints received data.
*/
#include
#include
#ifndef STASSID
#define STASSID "XXXXXXXX"
#define STAPSK "YYYYYYYYYYYYY"
#define IDENTIFIER "Garden Center"
//#define IDENTIFIER "Garden East"
//#define IDENTIFIER "Garden West"
#endif
#define DHTPIN 14
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
const char* ssid = STASSID;
const char* password = STAPSK;
const char* Identifier = IDENTIFIER;
const char* host = "192.168.1.3";
const uint16_t port = 80;
void setup() {
Serial.begin(115200);
// We start by connecting to a WiFi network
/* Explicitly set the ESP8266 to be a WiFi-client, otherwise, it by default,
would try to act as both a client and an access-point and could cause
network-issues with your other WiFi-devices on your WiFi-network. */
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
// dht to start
dht.begin();
}
void loop() {
// Serial.print("connecting to ");
// Serial.print(host);
// Serial.print(':');
// Serial.println(port);
// Use WiFiClient class to create TCP connections
WiFiClient client;
if (!client.connect(host, port)) {
Serial.println("connection failed");
delay(5000);
return;
}
// 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).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
delay(100);
return;
}
// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" *C\t");
//Serial.print(f);
//Serial.print(" *F\t");
Serial.print("; Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Heat index: ");
Serial.print(hic);
Serial.print(" *C ");
// Serial.print(hif);
// Serial.println(" *F");
// WEB serverにデータをアップロードする。
String url = "/weather/weather_log.php";
url += "?location=" + String(Identifier); // ID to identify location
url += "&temperature="+String(t);
url += "&humidity=" +String(h);
Serial.print("Requesting URL: ");
Serial.println("GET "+url);
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
delay(50);
// Read all the lines of the reply from server and print them to Serial
Serial.println("Returned message from server: ");
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
}
client.stop();
// 30分deepsleepする。
ESP.deepSleep(30*60*1000*1000, WAKE_RF_DEFAULT); // 60*1000*1000 = 1min, 30 min
delay(1000); // execute once every 5 minutes, don't flood remote service
}
手元に秋月で買ったDHT11があったので早速動かしてみることにした。 DHT11を使ったモニターはArduinoIDEのスケッチのサンプルにDHTtesterというのがあるので、それを使いました。 全く問題なく動くことを確認したので、これにWiFiClient機能を追加しました。 サーバーにLoggerを立てていないので、実際に接続しての動作は確認していませんが、文字列として確かに送信されているので、動作しているようです。 deep sleepを60分にして、シリアルモニターで動作確認を実施中。 これがうまくゆけば、取りあえず庭で使う温湿度計として筐体を含めて検討することにします。 (サーバープログラムはphpでもデータを取得時間とともにファイルに書き込むだけなので省略)3バンドダイポールのトラップCに同軸ケーブルを使っていますが、時々この同軸Cが放電して壊れることがあり、「トラップで発生する電圧ってそんな高いの?」 と思っていましたが、実際の電圧については?? (計算する方法ご存じの方教えてください)。 左から8D,8D,10D,左だけ通常の防...