{"id":533,"date":"2026-03-09T07:04:35","date_gmt":"2026-03-09T07:04:35","guid":{"rendered":"https:\/\/iotnoob.com\/wordpress\/?p=533"},"modified":"2026-03-10T03:45:07","modified_gmt":"2026-03-10T03:45:07","slug":"esp8266-%e0%b8%81%e0%b8%b1%e0%b8%9a%e0%b8%81%e0%b8%b2%e0%b8%a3-connect-https","status":"publish","type":"post","link":"https:\/\/iotnoob.com\/wordpress\/2026\/03\/09\/esp8266-%e0%b8%81%e0%b8%b1%e0%b8%9a%e0%b8%81%e0%b8%b2%e0%b8%a3-connect-https\/","title":{"rendered":"ESP8266 \u0e01\u0e31\u0e1a\u0e01\u0e32\u0e23 connect HTTPS"},"content":{"rendered":"\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;ESP8266WiFi.h>\n#include &lt;ESP8266HTTPClient.h>\n#include &lt;DHT11.h>\n#include &lt;WiFiClientSecure.h> \/\/ \u0e15\u0e49\u0e2d\u0e07\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e15\u0e31\u0e27\u0e19\u0e35\u0e49\n\n#ifndef STASSID\n#define STASSID \"XXXXXXXXXX\"\n#define STAPSK  \"XXXXXXXXXX\"\n#endif\n\nDHT11 dht11(D2);\n\nint sensor_id = 1;\nint location_id = 1;\n\nvoid setup() {\n\n  Serial.begin(115200);\n\n  Serial.println();\n  Serial.println();\n  Serial.println();\n\n  WiFi.begin(STASSID, STAPSK);\n\n  while (WiFi.status() != WL_CONNECTED) {\n    delay(500);\n    Serial.print(\".\");\n  }\n  Serial.println(\"\");\n  Serial.print(\"Connected! IP address: \");\n  Serial.println(WiFi.localIP());\n\n}\n\nvoid loop() {\n  int temperature = 0;\n  int humidity = 0;\n\n  int result = dht11.readTemperatureHumidity(temperature, humidity);\n\n  if (result != 0) {\n    temperature = -99999;\n    humidity = 99999;\n  }\n\n  \/\/ wait for WiFi connection\n  if ((WiFi.status() == WL_CONNECTED)) {\n\n    WiFiClientSecure client;\n    HTTPClient http;\n    client.setInsecure();\n    Serial.print(\"[HTTP] begin...\\n\");\n    \/\/ configure traged server and url\n    http.begin(client, \"https:\/\/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX); \/\/HTTP\n    http.addHeader(\"Content-Type\", \"application\/json\");\n\n    Serial.print(\"[HTTP] POST...\\n\");\n    \/\/ start connection and send HTTP header and body\n    String payload = \"{\\\"sensor_t_m\\\":\\\"\" + String(temperature) + \"\\\", \\\"sensor_h_m\\\": \\\"\" + String(humidity) + \"\\\", \\\"sensor_id\\\":\\\"\" + String(sensor_id) + \"\\\", \\\"location_id\\\":\\\"\" + String(location_id) + \"\\\"}\";\n    int httpCode = http.POST(payload);\n    \/\/int httpCode = http.POST(\"{\\\"sensor_t_m\\\":\\\"\" + temperature + \"\\\", \\\"sensor_h_m\\\": \\\"\" + humidity + \"\\\"}\");\n\n    \/\/ httpCode will be negative on error\n    if (httpCode > 0) {\n      \/\/ HTTP header has been send and Server response header has been handled\n      Serial.printf(\"[HTTP] POST... code: %d\\n\", httpCode);\n\n      \/\/ file found at server\n      if (httpCode == HTTP_CODE_OK) {\n        const String&amp; payload = http.getString();\n        Serial.println(\"received payload:\\n&lt;&lt;\");\n        Serial.println(payload);\n        Serial.println(\">>\");\n      } else {\n        Serial.printf(\"[HTTP] POST... Not failed?, %s\\n\", http.errorToString(httpCode).c_str());\n      }\n    } else {\n      Serial.printf(\"[HTTP] POST... failed, error: %s\\n\", http.errorToString(httpCode).c_str());\n    }\n\n    http.end();\n  }\n\n  delay(60000);\n}\n<\/pre>\n\n\n\n<p>From GEMINI<\/p>\n\n\n\n<p>\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a <code>WiFiClient<\/code> \u0e1b\u0e01\u0e15\u0e34 <strong>\u0e44\u0e21\u0e48\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16<\/strong> \u0e40\u0e0a\u0e37\u0e48\u0e2d\u0e21\u0e15\u0e48\u0e2d\u0e01\u0e31\u0e1a <code>https<\/code> (SSL\/TLS) \u0e44\u0e14\u0e49\u0e42\u0e14\u0e22\u0e15\u0e23\u0e07\u0e04\u0e23\u0e31\u0e1a \u0e40\u0e1e\u0e23\u0e32\u0e30\u0e21\u0e31\u0e19\u0e16\u0e39\u0e01\u0e2d\u0e2d\u0e01\u0e41\u0e1a\u0e1a\u0e21\u0e32\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e2a\u0e48\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e41\u0e1a\u0e1a Plain Text (HTTP) \u0e40\u0e17\u0e48\u0e32\u0e19\u0e31\u0e49\u0e19<\/p>\n\n\n\n<p>\u0e2b\u0e32\u0e01\u0e04\u0e38\u0e13\u0e1e\u0e22\u0e32\u0e22\u0e32\u0e21\u0e43\u0e0a\u0e49\u0e42\u0e04\u0e49\u0e14\u0e17\u0e35\u0e48\u0e04\u0e38\u0e13\u0e40\u0e02\u0e35\u0e22\u0e19\u0e21\u0e32\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e15\u0e48\u0e2d\u0e40\u0e02\u0e49\u0e32\u0e01\u0e31\u0e1a URL \u0e17\u0e35\u0e48\u0e02\u0e36\u0e49\u0e19\u0e15\u0e49\u0e19\u0e14\u0e49\u0e27\u0e22 <code>https:\/\/<\/code> \u0e15\u0e31\u0e27 Library \u0e08\u0e30\u0e1f\u0e49\u0e2d\u0e07 Error \u0e2b\u0e23\u0e37\u0e2d\u0e40\u0e0a\u0e37\u0e48\u0e2d\u0e21\u0e15\u0e48\u0e2d\u0e44\u0e21\u0e48\u0e2a\u0e33\u0e40\u0e23\u0e47\u0e08\u0e04\u0e23\u0e31\u0e1a<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u0e27\u0e34\u0e18\u0e35\u0e41\u0e01\u0e49\u0e44\u0e02: \u0e15\u0e49\u0e2d\u0e07\u0e43\u0e0a\u0e49 <code>WiFiClientSecure<\/code><\/h3>\n\n\n\n<p>\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e49\u0e40\u0e0a\u0e37\u0e48\u0e2d\u0e21\u0e15\u0e48\u0e2d HTTPS \u0e44\u0e14\u0e49 \u0e04\u0e38\u0e13\u0e15\u0e49\u0e2d\u0e07\u0e40\u0e1b\u0e25\u0e35\u0e48\u0e22\u0e19\u0e08\u0e32\u0e01\u0e01\u0e32\u0e23\u0e43\u0e0a\u0e49 <code>WiFiClient<\/code> \u0e21\u0e32\u0e40\u0e1b\u0e47\u0e19 <strong><code>WiFiClientSecure<\/code><\/strong> \u0e41\u0e17\u0e19 \u0e41\u0e25\u0e30\u0e15\u0e49\u0e2d\u0e07\u0e21\u0e35\u0e01\u0e32\u0e23\u0e08\u0e31\u0e14\u0e01\u0e32\u0e23\u0e40\u0e23\u0e37\u0e48\u0e2d\u0e07\u0e04\u0e27\u0e32\u0e21\u0e1b\u0e25\u0e2d\u0e14\u0e20\u0e31\u0e22 (Certificate) \u0e40\u0e1e\u0e34\u0e48\u0e21\u0e40\u0e15\u0e34\u0e21\u0e04\u0e23\u0e31\u0e1a<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. \u0e27\u0e34\u0e18\u0e35\u0e17\u0e35\u0e48\u0e07\u0e48\u0e32\u0e22\u0e17\u0e35\u0e48\u0e2a\u0e38\u0e14 (\u0e41\u0e15\u0e48\u0e1b\u0e25\u0e2d\u0e14\u0e20\u0e31\u0e22\u0e19\u0e49\u0e2d\u0e22\u0e01\u0e27\u0e48\u0e32)<\/h4>\n\n\n\n<p>\u0e2b\u0e32\u0e01\u0e04\u0e38\u0e13\u0e41\u0e04\u0e48\u0e15\u0e49\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e14\u0e36\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e41\u0e25\u0e30\u0e44\u0e21\u0e48\u0e0b\u0e35\u0e40\u0e23\u0e35\u0e22\u0e2a\u0e40\u0e23\u0e37\u0e48\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e15\u0e31\u0e27\u0e15\u0e19\u0e02\u0e2d\u0e07 Server (\u0e1b\u0e49\u0e2d\u0e07\u0e01\u0e31\u0e19\u0e01\u0e32\u0e23\u0e42\u0e14\u0e19\u0e1b\u0e25\u0e2d\u0e21\u0e41\u0e1b\u0e25\u0e07) \u0e43\u0e2b\u0e49\u0e43\u0e0a\u0e49\u0e04\u0e33\u0e2a\u0e31\u0e48\u0e07 <code>setInsecure()<\/code> \u0e04\u0e23\u0e31\u0e1a<\/p>\n\n\n\n<p>C++<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;WiFi.h>\n#include &lt;HTTPClient.h>\n#include &lt;WiFiClientSecure.h> \/\/ \u0e15\u0e49\u0e2d\u0e07\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e15\u0e31\u0e27\u0e19\u0e35\u0e49\n\nWiFiClientSecure client; \/\/ \u0e40\u0e1b\u0e25\u0e35\u0e48\u0e22\u0e19\u0e08\u0e32\u0e01 WiFiClient \u0e40\u0e1b\u0e47\u0e19 WiFiClientSecure\nHTTPClient http;\n\nvoid setup() {\n    \/\/ ... \u0e01\u0e32\u0e23\u0e40\u0e0a\u0e37\u0e48\u0e2d\u0e21\u0e15\u0e48\u0e2d WiFi ...\n\n    \/\/ \u0e2a\u0e33\u0e04\u0e31\u0e0d: \u0e2a\u0e31\u0e48\u0e07\u0e43\u0e2b\u0e49\u0e02\u0e49\u0e32\u0e21\u0e01\u0e32\u0e23\u0e40\u0e0a\u0e47\u0e04\u0e43\u0e1a\u0e23\u0e31\u0e1a\u0e23\u0e2d\u0e07 (SSL Certificate)\n    client.setInsecure(); \n\n    Serial.print(\"[HTTPS] begin...\\n\");\n    \n    \/\/ \u0e43\u0e0a\u0e49 client \u0e15\u0e31\u0e27\u0e43\u0e2b\u0e21\u0e48\u0e43\u0e19 http.begin\n    if (http.begin(client, \"https:\/\/XXXXXXXXXXXXXXXXXXXXXXXXXXXX\")) {\n        http.addHeader(\"Content-Type\", \"application\/json\");\n        int httpCode = http.POST(\"{\\\"sensor\\\":\\\"data\\\"}\");\n        \/\/ ... \u0e08\u0e31\u0e14\u0e01\u0e32\u0e23\u0e04\u0e33\u0e15\u0e2d\u0e1a\u0e17\u0e35\u0e48\u0e44\u0e14\u0e49\u0e23\u0e31\u0e1a ...\n    }\n}\n<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">2. \u0e27\u0e34\u0e18\u0e35\u0e17\u0e35\u0e48\u0e16\u0e39\u0e01\u0e15\u0e49\u0e2d\u0e07\u0e15\u0e32\u0e21\u0e21\u0e32\u0e15\u0e23\u0e10\u0e32\u0e19 (\u0e1b\u0e25\u0e2d\u0e14\u0e20\u0e31\u0e22\u0e2a\u0e39\u0e07)<\/h4>\n\n\n\n<p>\u0e43\u0e19\u0e01\u0e23\u0e13\u0e35\u0e17\u0e35\u0e48\u0e04\u0e38\u0e13\u0e15\u0e49\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e04\u0e27\u0e32\u0e21\u0e1b\u0e25\u0e2d\u0e14\u0e20\u0e31\u0e22\u0e08\u0e23\u0e34\u0e07\u0e46 \u0e04\u0e38\u0e13\u0e15\u0e49\u0e2d\u0e07\u0e23\u0e30\u0e1a\u0e38 <strong>Root CA Certificate<\/strong> \u0e2b\u0e23\u0e37\u0e2d <strong>Fingerprint<\/strong> \u0e02\u0e2d\u0e07 Server \u0e25\u0e07\u0e44\u0e1b\u0e14\u0e49\u0e27\u0e22 \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e49 Arduino \u0e21\u0e31\u0e48\u0e19\u0e43\u0e08\u0e27\u0e48\u0e32\u0e01\u0e33\u0e25\u0e31\u0e07\u0e04\u0e38\u0e22\u0e01\u0e31\u0e1a Server \u0e15\u0e31\u0e27\u0e08\u0e23\u0e34\u0e07 \u0e44\u0e21\u0e48\u0e43\u0e0a\u0e48 Hacker \u0e17\u0e35\u0e48\u0e14\u0e31\u0e01\u0e01\u0e25\u0e32\u0e07\u0e17\u0e32\u0e07 (Man-in-the-Middle)<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u0e02\u0e49\u0e2d\u0e2a\u0e31\u0e07\u0e40\u0e01\u0e15\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e40\u0e15\u0e34\u0e21<\/h3>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>IP Address \u0e01\u0e31\u0e1a HTTPS:<\/strong> \u0e1b\u0e01\u0e15\u0e34\u0e41\u0e25\u0e49\u0e27\u0e01\u0e32\u0e23\u0e23\u0e31\u0e19 HTTPS \u0e1a\u0e19 IP \u0e15\u0e23\u0e07\u0e46 (192.168.1.166) \u0e21\u0e31\u0e01\u0e08\u0e30\u0e40\u0e08\u0e2d\u0e1b\u0e31\u0e0d\u0e2b\u0e32\u0e40\u0e23\u0e37\u0e48\u0e2d\u0e07 Self-signed Certificate \u0e2b\u0e32\u0e01\u0e04\u0e38\u0e13\u0e17\u0e33\u0e23\u0e30\u0e1a\u0e1a\u0e40\u0e2d\u0e07 \u0e2d\u0e22\u0e48\u0e32\u0e25\u0e37\u0e21\u0e43\u0e0a\u0e49 <code>client.setInsecure()<\/code> \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e49\u0e21\u0e31\u0e19\u0e22\u0e2d\u0e21\u0e23\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e40\u0e0a\u0e37\u0e48\u0e2d\u0e21\u0e15\u0e48\u0e2d\u0e04\u0e23\u0e31\u0e1a<\/li>\n\n\n\n<li><strong>RAM:<\/strong> \u0e01\u0e32\u0e23\u0e43\u0e0a\u0e49 HTTPS \u0e01\u0e34\u0e19\u0e17\u0e23\u0e31\u0e1e\u0e22\u0e32\u0e01\u0e23\u0e40\u0e04\u0e23\u0e37\u0e48\u0e2d\u0e07 (RAM) \u0e21\u0e32\u0e01\u0e01\u0e27\u0e48\u0e32 HTTP \u0e1b\u0e01\u0e15\u0e34\u0e1e\u0e2d\u0e2a\u0e21\u0e04\u0e27\u0e23 \u0e16\u0e49\u0e32\u0e04\u0e38\u0e13\u0e43\u0e0a\u0e49 ESP8266 \u0e2d\u0e32\u0e08\u0e08\u0e30\u0e15\u0e49\u0e2d\u0e07\u0e23\u0e30\u0e27\u0e31\u0e07\u0e40\u0e23\u0e37\u0e48\u0e2d\u0e07 Memory \u0e40\u0e1b\u0e47\u0e19\u0e1e\u0e34\u0e40\u0e28\u0e29 \u0e41\u0e15\u0e48\u0e16\u0e49\u0e32\u0e40\u0e1b\u0e47\u0e19 ESP32 \u0e2a\u0e1a\u0e32\u0e22\u0e21\u0e32\u0e01\u0e04\u0e23\u0e31\u0e1a<\/li>\n<\/ol>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>From GEMINI \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a WiFiClient \u0e1b\u0e01\u0e15\u0e34 \u0e44\u0e21\u0e48\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16 \u0e40\u0e0a\u0e37\u0e48\u0e2d\u0e21\u0e15\u0e48\u0e2d\u0e01\u0e31\u0e1a https (SSL\/TLS) \u0e44\u0e14\u0e49\u0e42\u0e14\u0e22\u0e15\u0e23\u0e07\u0e04\u0e23\u0e31\u0e1a \u0e40\u0e1e\u0e23\u0e32\u0e30\u0e21\u0e31\u0e19\u0e16\u0e39\u0e01\u0e2d\u0e2d\u0e01\u0e41\u0e1a\u0e1a\u0e21\u0e32\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e2a\u0e48\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e41\u0e1a\u0e1a Plain Text (HTTP) \u0e40\u0e17\u0e48\u0e32\u0e19\u0e31\u0e49\u0e19&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-533","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/posts\/533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/comments?post=533"}],"version-history":[{"count":3,"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/posts\/533\/revisions"}],"predecessor-version":[{"id":541,"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/posts\/533\/revisions\/541"}],"wp:attachment":[{"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/media?parent=533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/categories?post=533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/tags?post=533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}