ผมลองติดตั้งwifi manager ลงในโค้ดเดิมใช้วัดอุณภูมิความชื้น ส่งไลน์ทุก1ชั่วโมง ติดตั้งเชื่อมต่ออินเตอร์เน็ตได้สำเร็จ แต่โปรแกรมทำงานไม่เหมือนเดิมครับ เช่นการcount การจับเวลา มันช้าทำงานไม่ได้ครับ ต้องแก้ส่วนไหนครับคือถ้าเราต่ออินเตอร์เน็ตได้แล้วให้ทำงานโค้ดในส่วนต่อๆไปเลยอะครับ
ปกติไม่น่าเกี่ยวกันนะครับ ต้องเอาโค้ตที่ใช้มาดูก่อน
1.โค้ตที่บอกว่าทำงานปกติ
2.โค้ตหลังจากที่ใส่แล้วมันช้า
3.มันช้าระดับไหน ต่างกัน กี่ นาที หรือ ชั่วโมง
โปรแกรมมันนับเวลา HH:MM:SS ไม่ได้เลยครับ แล้วCountไม่ได้ครับ
อันนี้โค้ดเก่า
#include <TridentTD_LineNotify.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <DallasTemperature.h>
#include <OneWire.h>
//#include <IoTtweet.h>
#include <ArduinoJson.h>
#include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
#include "SSD1306.h" // alias for `#include "SSD1306Wire.h"
//#define SSID "AAEcoppy_2.4GHz."
//#define PASSWORD "aae471020"
#define SSID "BeerZaa_2.4G"
#define PASSWORD "beer12345678"
#define LINE_TOKEN "zHxbutCEPHZvzePIvE3Hidn7NVX18d55jZHmub" //smart hospital
//#define LINE_TOKEN "uefzNa18fTGa4hgYbvFmWyvvdMuCH2Ti8nGKMTjEqr9"
//float data0, data1, data2, data3; //Your sending data variable.
//String private_tweet = "Smart Hospital"; //Your private tweet meassage to dashboard
//String public_tweet = "Data from Ds18b20 sensor"; //Your public tweet message to dashboard
//String response;
//IoTtweet myiot; //naming your devices
float t, h;
display.flipScreenVertically();
display.setFont(ArialMT_Plain_16);
display.setTextAlignment(TEXT_ALIGN_LEFT);
sensors.begin(); // initialize ds18b20
Serial.begin(115200);
Serial.println();
Serial.println(LINE.getVersion());
WiFi.begin(SSID, PASSWORD);
Serial.printf("WiFi connecting to %s\n", SSID);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(400);
}
Serial.printf("\nWiFi connected\nIP : ");
Serial.println(WiFi.localIP());
LINE.setToken(LINE_TOKEN); // กำหนด Line Token
}
{
configTime(timezone, dst, "pool.ntp.org", "time.nist.gov"); //แสดงเวลาปัจจุบัน ดึงจากServer
time_t now = time(nullptr);
struct tm* p_tm = localtime(&now);
// String now_time = "";
// Serial.print("Time : ");
// Serial.print(p_tm->tm_hour);
// Serial.print(":");
// Serial.print(p_tm->tm_min);
// Serial.print(":");
// Serial.print(p_tm->tm_sec);
// Serial.println(" ");
String now_time = "";
now_time = now_time + p_tm->tm_hour; // hour
now_time = now_time + ":"; // hour:
now_time = now_time + p_tm->tm_min; // hour:min
now_time = now_time + ":"; // hour:min:
now_time = now_time + p_tm->tm_sec; // hour:min:sec
//Serial.println(now_time); // ส่งข้อความออกทาง Serial Monitor พร้อมขึ้นบรรทัดใหม่
String now_day = "";
now_day = now_day + (p_tm->tm_year + 1900); // year
now_day = now_day + "-"; // year-
now_day = now_day + (p_tm->tm_mon + 1); // year-mon
now_day = now_day + "-"; // year-mon-
now_day = now_day + p_tm->tm_mday; // year-mon-day
//Serial.println(now_day); // ส่งข้อความออกทาง Serial Monitor พร้อมขึ้นบรรทัดใหม่
String dateTime = now_day + " "; // day-mon-year
dateTime = dateTime + now_time; // day-mon-year hour:min:sec
Serial.println(dateTime); // ส่งข้อความออกทาง Serial Monitor พร้อมขึ้นบรรทัดใหม่
Serial.print("Timer : ");
Serial.print(count_time5);
Serial.print(" ");
Serial.print("Temp: ");
Serial.println(t);
Serial.print("Humidity: ");
Serial.println(h);
Serial.println("...............................");
//delay(300);
count_time5++;
String url = "http://bziot.inwcreate.com/sensor-bziot-api.php/?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
//String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.00 && p_tm->tm_hour == 1 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://bziot.inwcreate.com/sensor-bziot-api.php/?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
//String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.00 && p_tm->tm_hour == 2 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://bziot.inwcreate.com/sensor-bziot-api.php/?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
//String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.00 && p_tm->tm_hour == 3 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
else if (t >= 2.00 && t <= 8.00 && p_tm->tm_hour == 22 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://bziot.inwcreate.com/sensor-bziot-api.php/?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
// String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.00 && p_tm->tm_hour == 23 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://bziot.inwcreate.com/sensor-bziot-api.php/?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
// String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
}
}
อันนี้ใช้ไลบารี่ wifi manager
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
//needed for library
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
#include <TridentTD_LineNotify.h>
#include <ESP8266HTTPClient.h>
#include <DallasTemperature.h>
#include <OneWire.h>
//#include <IoTtweet.h>
#include <ArduinoJson.h>
#include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
#include "SSD1306.h" // alias for `#include "SSD1306Wire.h"
#define LINE_TOKEN "zHxbutCEPHZvzePIvE3Hidn7NKSX18d55jZHmub-test"
float t, h;
int count_time5 = 0;
int timezone = 7 * 3600; //ตั้งค่า TimeZone ตามเวลาประเทศไทย
int dst = 0; //กำหนดค่า Date Swing Time
const char *device = "99999";
OneWire oneWire(2); //D4 ถ้า D2=4
DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature.
// Initialize the OLED display using Wire library
SSD1306 display(0x3c, D3, D5);
// SH1106 display(0x3c, D3, D5);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
display.init();
display.flipScreenVertically();
display.setFont(ArialMT_Plain_16);
display.setTextAlignment(TEXT_ALIGN_LEFT);
sensors.begin(); // initialize ds18b20
Serial.println();
Serial.println(LINE.getVersion());
LINE.setToken(LINE_TOKEN); // กำหนด Line Token
}
void displayTempHumid(float x, float y) {
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
// Check if any reads failed and exit early (to try again).
C");
//display.drawString(0, 32, "Temp: " + String(f) + "F");
//WiFiManager
//Local intialization. Once its business is done, there is no need to keep it around
WiFiManager wifiManager;
//reset saved settings
//wifiManager.resetSettings();
//set custom ip for portal
//wifiManager.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
//fetches ssid and pass from eeprom and tries to connect
//if it does not connect it starts an access point with the specified name
//here "AutoConnectAP"
//and goes into a blocking loop awaiting configuration
wifiManager.autoConnect("AutoConnectAP");
//or use this for auto generated name ESP + ChipID
//wifiManager.autoConnect();
//if you get here you have connected to the WiFi
Serial.println("connected...yeey :)");
}
void loop() {
// put your main code here, to run repeatedly:
sensors.requestTemperatures();
t = sensors.getTempCByIndex(0);
int adc = analogRead(A0); //ไม่แน่ใจ
if (isnan(t))
{
Serial.println("Error reading Ds18b20!");
//delay(1000);
return;
}
displayTempHumid(t, h);
display.display();
{
configTime(timezone, dst, "pool.ntp.org", "time.nist.gov"); //แสดงเวลาปัจจุบัน ดึงจากServer
time_t now = time(nullptr);
struct tm* p_tm = localtime(&now);
// String now_time = "";
// Serial.print("Time : ");
// Serial.print(p_tm->tm_hour);
// Serial.print(":");
// Serial.print(p_tm->tm_min);
// Serial.print(":");
// Serial.print(p_tm->tm_sec);
// Serial.println(" ");
String now_time = "";
now_time = now_time + p_tm->tm_hour; // hour
now_time = now_time + ":"; // hour:
now_time = now_time + p_tm->tm_min; // hour:min
now_time = now_time + ":"; // hour:min:
now_time = now_time + p_tm->tm_sec; // hour:min:sec
//Serial.println(now_time); // ส่งข้อความออกทาง Serial Monitor พร้อมขึ้นบรรทัดใหม่
String now_day = "";
now_day = now_day + (p_tm->tm_year + 1900); // year
now_day = now_day + "-"; // year-
now_day = now_day + (p_tm->tm_mon + 1); // year-mon
now_day = now_day + "-"; // year-mon-
now_day = now_day + p_tm->tm_mday; // year-mon-day
count_time5 = 0;
HTTPClient http;
String url = "http://203.157.134.42/program/bziot/sensor-bziot-api.php?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
//String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t < 2.00 && t > -50 && count_time5 >= 300) {
LINE.notify("อุณหภูมิผิดปกติ " + String(t) + " องศา" + " โปรดตรวจสอบ!");
LINE.notifySticker(2, 24);
else if (t >= 2.00 && t <= 8.01 && p_tm->tm_hour == 2 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
//String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.01 && p_tm->tm_hour == 6 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://203.157.134.42/program/bziot/sensor-bziot-api.php?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
//String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.01 && p_tm->tm_hour == 7 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://203.157.134.42/program/bziot/sensor-bziot-api.php?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
//String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.01 && p_tm->tm_hour == 8 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://203.157.134.42/program/bziot/sensor-bziot-api.php?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
//String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.01 && p_tm->tm_hour == 9 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://203.157.134.42/program/bziot/sensor-bziot-api.php?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
//String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.01 && p_tm->tm_hour == 10 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://203.157.134.42/program/bziot/sensor-bziot-api.php?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
// String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.01 && p_tm->tm_hour == 11 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://203.157.134.42/program/bziot/sensor-bziot-api.php?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
// String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.01 && p_tm->tm_hour == 12 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://203.157.134.42/program/bziot/sensor-bziot-api.php?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
// String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.01 && p_tm->tm_hour == 13 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://203.157.134.42/program/bziot/sensor-bziot-api.php?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
//String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.01 && p_tm->tm_hour == 14 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://203.157.134.42/program/bziot/sensor-bziot-api.php?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
//String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.01 && p_tm->tm_hour == 15 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://203.157.134.42/program/bziot/sensor-bziot-api.php?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
//String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.01 && p_tm->tm_hour == 16 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://203.157.134.42/program/bziot/sensor-bziot-api.php?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
//String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.01 && p_tm->tm_hour == 17 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://203.157.134.42/program/bziot/sensor-bziot-api.php?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
// String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.01 && p_tm->tm_hour == 18 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://203.157.134.42/program/bziot/sensor-bziot-api.php?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
// String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.01 && p_tm->tm_hour == 19 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
HTTPClient http;
String url = "http://203.157.134.42/program/bziot/sensor-bziot-api.php?datetime='" + String(now_day) + "%20" + String(now_time) + "'&temperature='" + String(t) + "'&humidity='" + String(h) + "'&device='" + String(device) + "'";
http.begin(url); // HTTP Initial
int httpCode = http.GET(); // ทำการ GET Request ไปยัง Server
//String response = myiot.WriteDashboard(userid, key, t, h, 0, 0, private_tweet, public_tweet);
}
else if (t >= 2.00 && t <= 8.01 && p_tm->tm_hour == 20 && p_tm->tm_min == 0 && p_tm->tm_sec == 5)
{
LINE.notify("อุณหภูมิขณะนี้ " + String(t) + " องศา");
LINE.notifySticker(1, 407);
โค้นนี้นับเวลา HH:MM:SS ได้ใช่ไหมครับ
ได้ครับ ใช้อันนี้ครับ
p_tm->tm_hour == 0 && p_tm->tm_min == 0 && p_tm->tm_sec == 5
ส่งค่าอุณภูมิ ไปฐานข้อมูลครับ
ถ้าเป็นโค้ดเก่าเวลาดูserial monitor มันจะนับเวลาเป็นวินาทีไปเรื่อยๆครับ พอใช้wifi manager มันจะนับเป็นวินาทีไม่ได้ครับ มันกระโดดข้ามไป2-5วินาทีเลยครับ เลยทำให้การส่งไลน์กับส่งค่าอุณภูมิที่ตั้งเงื่อนไขไว้ไม่ได้
ถ้าอุณภูมิเกินช่วงตัวเลขที่กำหนดให้countไปเรื่อยๆจนครบ300 หรือครบ1200 ก็จะส่งไลน์ครับ
ตรงนี้แก้เวลาในโค้ดเว็บไปแล้วครับ ถ้าจะส่งเป็นคลิปวีดีโอให้ดูได้ไหมครับ จะให้ดูตอนserial mornitorครับ
Up ลง YouTube แล้วเอาลิ้งค์มาวางเลยครับ
ขอบคุณครับเดี๋ยวคืนนี้เอาลงให้ครับ
มีภาพ HW ก็ถ่ายมีดูด้วยก็ดีครับ จะได้เห็นภาพมากขึ้น
อันนี้ก่อนจะใช้ไลบารี่wifi manager ฟังชั่นเวลา กับ count ทำงานได้ปกติไม่ค้างช้า
https://drive.google.com/file/d/1j8tBLmQQa-bsbZZPXEfYaTj2m0ldWmcP/view?usp=sharing
คลิปนี้หลังจากเพิ่มไลบารี่wifi manager ครับ มันนับเวลาช้า และtimerกระโดดไปเลยครับไม่ต่อเนื่อง เหมือนมันเช็คสถานะ ตรงwm:,ipอะครับ
https://drive.google.com/file/d/1fvTW9qgkYQdmLIe-8_e5Y-cCCrxW9NjI/view?usp=sharing
ทำตามที่ไหนมาครับมีแหล่งอ้างอิงไหม เหมือนว่ามันจำค่า ssid/pass ไม่อยู่ ได้สักพักมันหลุดแล้วต่อใหม่
ตัวwifi manager โหลดจากarduino ideมาครับ ส่วนโค้ดผมเอามาตัดปะเองครับ แล้วแบบนี้มีวิธีแก้ไม่ให้หลุดไหมครับ




