{"id":389236,"date":"2024-06-29T08:27:56","date_gmt":"2024-06-29T08:27:56","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=389236"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=389236","title":{"rendered":"<span>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c \u0447\u0435\u0440\u0435\u0437 telegram-\u0431\u043e\u0442 \u0441 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u044c\u044e<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0417\u0430\u0434\u0430\u0447\u0430<\/h2>\n<p>\u041d\u0443\u0436\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438: \u0441\u0432\u0435\u0442, \u0432\u0435\u043d\u0442\u0438\u043b\u044f\u0446\u0438\u044f, \u043f\u043e\u043b\u0438\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430.<br \/>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043b\u044f \u0443\u0447\u0435\u0431\u043d\u043e-\u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0438\u043b\u0438 DIY-\u0437\u0430\u0434\u0430\u0447 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0443\u0436 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u043d\u0435 \u043e\u043f\u043b\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 IP-\u0430\u0434\u0440\u0435\u0441.<\/p>\n<h2>\u0418\u0434\u0435\u044f<\/h2>\n<p>\u041e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0432\u044b\u0445\u043e\u0434 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u0441 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0434\u0432\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430: \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f \u043f\u0440\u0438\u0435\u043c\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0442 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0438 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442 \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c.<\/p>\n<p>\u0412\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 Flask \u0438 \u0431\u043e\u0442\u0430 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u043d\u0430 ReplIt. \u041a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e \u0441 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 24\/7 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/habr.com\/ru\/post\/709314\/\" rel=\"noopener noreferrer nofollow\">\u041a\u0430\u043a \u0445\u043e\u0441\u0442\u0438\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u0430<\/a>.<\/p>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0431\u044b\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Arduino + Ethernet-\u043c\u043e\u0434\u0443\u043b\u044c W5500, \u044d\u0442\u0430 \u0441\u0432\u044f\u0437\u043a\u0430 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0438 \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u043b\u0430\u0441\u044c \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0435 \u043d\u0430 ReplIt, \u0442.\u043a. \u0441\u0441\u044b\u043b\u043a\u0430 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 https, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 Arduino \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442.<\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u0448\u043b\u043e\u0441\u044c \u0432 \u0432\u0438\u0434\u0435 \u043f\u043b\u0430\u0442\u044b NodeMCU v3 \u0441 \u043c\u043e\u0434\u0443\u043b\u0435\u043c Wi-Fi:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2e2\/521\/53d\/2e252153d178676649912c5d5371d13b.png\" alt=\"NodeMCU v3 \u0441 WiFi-\u043c\u043e\u0434\u0443\u043b\u0435\u043c  \" title=\"NodeMCU v3 \u0441 WiFi-\u043c\u043e\u0434\u0443\u043b\u0435\u043c  \" width=\"902\" height=\"563\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2e2\/521\/53d\/2e252153d178676649912c5d5371d13b.png\"\/><figcaption>NodeMCU v3 \u0441 WiFi-\u043c\u043e\u0434\u0443\u043b\u0435\u043c  <\/figcaption><\/figure>\n<p>\u042d\u0442\u0430 \u043f\u043b\u0430\u0442\u0430, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 ESP8266, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u0440\u0435\u0434\u0443 Arduino IDE \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u043e\u0439.<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f &#8212; \u0448\u0430\u0433 0 &#8212; \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c IDE<\/h2>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0434\u043b\u044f \u0432\u0435\u0440\u0441\u0438\u0438 Arduino IDE 2.0.3, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043d\u0430 <a href=\"https:\/\/www.arduino.cc\/en\/software\" rel=\"noopener noreferrer nofollow\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435. <\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d90\/c15\/c92\/d90c15c92a5035f93236c224b13fe619.png\" width=\"1298\" height=\"848\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d90\/c15\/c92\/d90c15c92a5035f93236c224b13fe619.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 IDE \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0435\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 ESP8266.<br \/>\u041d\u0443\u0436\u043d\u043e \u0437\u0430\u0439\u0442\u0438 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 File\u2192Preference:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/01d\/b04\/a14\/01db04a1462f6ed012ce1543b5f953b7.png\" width=\"246\" height=\"352\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/01d\/b04\/a14\/01db04a1462f6ed012ce1543b5f953b7.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 \u0434\u043b\u044f \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0430\u0445:<br \/><code>http:\/\/arduino.esp8266.com\/stable\/package_esp8266com_index.json<br \/>https:\/\/dl.espressif.com\/dl\/package_esp32_index.json<\/code><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c0e\/9b5\/929\/c0e9b59297d1a8364f2ad558084e2f55.png\" width=\"779\" height=\"505\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c0e\/9b5\/929\/c0e9b59297d1a8364f2ad558084e2f55.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432 \u043b\u0435\u0432\u043e\u043c \u043c\u0435\u043d\u044e BOARDS MANAGER \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 ESP8266:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cbe\/0b3\/e1d\/cbe0b3e1db0a2e7ea67fb7aed0fb2642.png\" width=\"266\" height=\"810\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cbe\/0b3\/e1d\/cbe0b3e1db0a2e7ea67fb7aed0fb2642.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e IDE \u0433\u043e\u0442\u043e\u0432\u0430 \u043a \u0440\u0430\u0431\u043e\u0442\u0435. \u041d\u043e \u043f\u0440\u0435\u0436\u0434\u0435, \u0447\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043a\u043e\u0434 \u0432 ESP, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0432\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043d\u0430 Python \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f &#8212; \u0448\u0430\u0433 1 &#8212; \u041f\u0438\u0448\u0435\u043c \u043a\u043e\u0434 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u0430 \u0438 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 Flask<\/h2>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0442 ESP \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e &#171;\u0443\u0441\u043b\u043e\u0432\u043d\u0430\u044f \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430&#187; (\u0443\u0441\u043b\u043e\u0432\u043d\u0430\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u0430\u044f \u0438\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439) \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u0432 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430.<\/p>\n<p>\u041e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0438 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 ReplIt, \u0432 \u043d\u0435\u043c \u0434\u0435\u043b\u0430\u0435\u043c \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 main.py (\u0432 \u043d\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442) \u0438 background.py (\u0432 \u043d\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440). \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/habr.com\/ru\/post\/709314\/\" rel=\"noopener noreferrer nofollow\">\u041a\u0430\u043a \u0445\u043e\u0441\u0442\u0438\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u0430<\/a>.<\/p>\n<h3>Telegram-\u0431\u043e\u0442<\/h3>\n<p>\u0420\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u043c \u0432 \u0444\u0430\u0439\u043b\u0435 main.py.<\/p>\n<p>\u041c\u043e\u043c\u0435\u043d\u0442\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: <\/p>\n<ul>\n<li>\n<p><code>import pip   pip.main(['install', 'pytelegrambotapi'])<\/code> &#8212; \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u043d\u0430\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p><code>f.write(str(call.from_user.id))<\/code> &#8212; \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c id \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043e\u0431\u0449\u0430\u0435\u043c\u0441\u044f. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c, \u0447\u0442\u043e \u0441 \u0431\u043e\u0442\u043e\u043c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a. <\/p>\n<\/li>\n<li>\n<p><code>bot.send_message(call.from_user.id,\"\u0421\u0432\u0435\u0442 \u0441\u043a\u043e\u0440\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f\")<\/code> &#8212; \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u0447\u0442\u043e &#171;\u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u0440\u0438\u043d\u044f\u0442\u0430&#187;. \u0427\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435, \u043a\u043e\u0433\u0434\u0430 \u043e\u0442 ESP \u043f\u0440\u0438\u0434\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u0447\u0442\u043e \u0441\u0432\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d, \u043c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435. \u0418\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c <strong>user_id.<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0422\u043e\u043a\u0435\u043d \u043e\u0442 \u0431\u043e\u0442\u0430 \u043f\u0440\u044f\u0447\u0435\u043c \u0432 SECRETS, \u0442.\u043a. \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u043e\u0442\u043a\u0440\u044b\u0442 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0434\u043b\u044f \u0432\u0441\u0435\u0445. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u0432 <a href=\"https:\/\/docs.replit.com\/programming-ide\/storing-sensitive-information-environment-variables\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">import os from background import keep_alive import pip pip.main(['install', 'pytelegrambotapi']) import telebot import time  #\u043e\u0447\u0438\u0449\u0430\u0435\u043c \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b \u0438\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u044b\u0435 with open('messages.txt','w') as f:       f.write(\"\") with open('user_id.txt','w') as f:       f.write(\"\") with open('from_esp.txt','w') as f:       f.write(\"\") with open('from_tg.txt','w') as f:       f.write(\"\")  def get_last_update(now,last):   # \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430   diff = now-last   if diff&lt;60:     return f\"{int(diff)} \u0441\u0435\u043a \u043d\u0430\u0437\u0430\u0434\"   elif diff&lt;60*60:     return f\"{int(diff\/60)} \u043c\u0438\u043d \u043d\u0430\u0437\u0430\u0434\"   elif diff&lt;60*60*24:     return f\"{int(diff\/60\/24)} \u0447 \u043d\u0430\u0437\u0430\u0434\"     else:     return \"\u0411\u043e\u043b\u0435\u0435 \u0434\u043d\u044f \u043d\u0430\u0437\u0430\u0434\"   bot = telebot.TeleBot(os.environ['TOKEN'])# \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u043e\u0442  # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440, \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u043a\u043e\u043c\u043c\u0443\u043d\u0438\u043a\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c start_keyboard = telebot.types.InlineKeyboardMarkup() start_keyboard.add(     telebot.types.InlineKeyboardButton('\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e', callback_data='info'),     telebot.types.InlineKeyboardButton('\u0423\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c', callback_data='control') )  control_keyboard = telebot.types.InlineKeyboardMarkup() control_keyboard.add(     telebot.types.InlineKeyboardButton('\u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c', callback_data='on'),     telebot.types.InlineKeyboardButton('\u0412\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c', callback_data='off') ) # \u041a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u044b \u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c \u0431\u043e\u0442\u0430  # \u041d\u0430 \u043b\u044e\u0431\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0435\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 # \u041a\u0430\u043a \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \/start \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f @bot.message_handler(content_types=['text']) def get_text_message(message):   bot.send_message(message.from_user.id,\"\u0427\u0442\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c?\",reply_markup=start_keyboard)  #\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043d\u0430\u0436\u0430\u0442\u0438\u0439 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0438  @bot.callback_query_handler(func=lambda call: True) def func(call):   bot.answer_callback_query(call.id) # \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u043c \u0431\u043e\u0442\u0443, \u0447\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u043e \u043a\u043d\u043e\u043f\u043a\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e   with open('user_id.txt','w') as f:       f.write(str(call.from_user.id)) # \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u0444\u0430\u0439\u043b user_id. \u041e\u043d \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439   if call.data=='info':#\u043d\u0430\u0436\u0430\u0442\u0430 \u043a\u043d\u043e\u043f\u043a\u0430 \u0441 callback_data='info', \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u0437 \u0444\u0430\u0439\u043b\u0430     with open(\"from_esp.txt\",\"r\") as f:# \u0447\u0438\u0442\u0430\u0435\u043c \u0444\u0430\u0439\u043b       temp,light,time_last = f.readlines()[0].split(';')#\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445       last_update = get_last_update(time.time(),float(time_last))# \u0438 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445     #\u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e     bot.send_message(call.from_user.id,f\"\u0412\u0441\u0435 \u0445\u043e\u0440\u043e\u0448\u043e, \\n\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430: {temp} \\n\u041e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0435: {'\u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e' if light=='1' else '\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043e'}\\n\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043e: {last_update}\", reply_markup=start_keyboard)   if call.data=='control':#\u043d\u0430\u0436\u0430\u0442\u0430 \u043a\u043d\u043e\u043f\u043a\u0430 \u0441 callback_data='control'     bot.send_message(call.from_user.id,\"\u0412\u043e\u0442 \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c:\",reply_markup=control_keyboard)   if call.data=='on':#\u043d\u0430\u0436\u0430\u0442\u0430 \u043a\u043d\u043e\u043f\u043a\u0430 \u0441 callback_data='on'     bot.send_message(call.from_user.id,\"\u0421\u0432\u0435\u0442 \u0441\u043a\u043e\u0440\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f\")#\u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e     with open('from_tg.txt','w') as f:#\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u0444\u0430\u0439\u043b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0445\u043e\u0442\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c       f.write('1')#\u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0432\u0435\u0442   if call.data=='off':     bot.send_message(call.from_user.id,\"\u0421\u0432\u0435\u0442 \u0441\u043a\u043e\u0440\u043e \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f\")     with open('from_tg.txt','w') as f:       f.write('0')#\u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0432\u0435\u0442    keep_alive()# \u0437\u0430\u043f\u0443\u0441\u043a \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 background.py bot.polling(non_stop=True, interval=0)# \u0437\u0430\u043f\u0443\u0441\u043a \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u0430<\/code><\/pre>\n<h3>\u0412\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 Flask<\/h3>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Flask \u0438 \u043a\u0430\u043a \u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u0415\u0441\u0442\u044c \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u0438\u043b\u0438 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c \u043e\u0431 \u044d\u0442\u043e\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c<a href=\"https:\/\/docs-python.ru\/packages\/veb-frejmvork-flask-python\/\" rel=\"noopener noreferrer nofollow\"> \u0432\u043e\u0442 \u044d\u0442\u0443<\/a>.<\/p>\n<p>\u0420\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u043c \u043a\u043e\u0434 \u0432 \u0444\u0430\u0439\u043b\u0435 background.py<br \/>\u042d\u0442\u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 2 \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<ul>\n<li>\n<p>\u041e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c \u0447\u0435\u0440\u0435\u0437 GET-\u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/uptimerobot.com\/index\" rel=\"noopener noreferrer nofollow\">UpTimeRobot<\/a>. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0432\u0441\u0435 \u0432 \u0442\u043e\u0439 \u0436\u0435 <a href=\"https:\/\/habr.com\/ru\/post\/709314\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a>.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">from flask import Flask from flask import request from threading import Thread import time import requests  app = Flask('')  @app.route('\/')#\u0421\u043e\u0437\u0434\u0430\u0435\u043c \"\u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443\" \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u0442 \u043f\u0438\u043d\u0433\u043e\u0432\u0430\u0442\u044c UpTimeRobot def home():   return \"I'm alive\"  @app.route('\/iot', methods=['GET'])#\u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \/iot \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b  def iot():   temp = request.args.get('temp') #\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438\u0437 GET-\u0437\u0430\u043f\u0440\u043e\u0441\u0430   light = request.args.get('light')   with open('from_esp.txt', 'r') as f:#\u0447\u0438\u0442\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 ESP \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437     old_temp,old_light,time_last = f.readlines()[0].split(';')     if old_light==\"0\" and light==\"1\":# \u0438 \u0435\u0441\u043b\u0438 \u0441\u0442\u0430\u0440\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u044b\u043a\u043b, \u0430 \u043d\u043e\u0432\u043e\u0435 \u0432\u043a\u043b       with open('messages.txt', 'w') as f_m:# \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u0444\u0430\u0439\u043b messages \u0442\u0435\u043a\u0441\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f         f_m.write(\"\u0421\u0432\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0438\u043b\u0441\u044f\")     if old_light==\"1\" and light==\"0\":       with open('messages.txt', 'w') as f_m:         f_m.write(\"\u0421\u0432\u0435\u0442 \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u043b\u0441\u044f\")   with open('from_esp.txt', 'w') as f:#\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u0444\u0430\u0439\u043b \u043d\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f     f.write(f\"{temp};{light};{time.time()}\")        with open('from_tg.txt', 'r') as f:# \u0447\u0438\u0442\u0430\u0435\u043c \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0432 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0435     new_state = f.read(1) #\u0442.\u043a. \u0443 \u043d\u0430\u0441 \u0442\u043e\u043b\u044c\u043a\u043e 1 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c\/\u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0432\u0435\u0442, \u0447\u0438\u0442\u0430\u0435\u043c 1 \u0441\u0438\u043c\u0432\u043e\u043b   return new_state #\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 #\u0414\u043b\u044f Flask-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u043d\u0430 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 https:\/\/\u0441\u0430\u0439\u0442\/iot   def run(): #\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 flask-\u0441\u0435\u0440\u0432\u0435\u0440\u0430   app.run(host='0.0.0.0', port=80)  def reminder():   while True:     with open('user_id.txt','r') as f:#\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c user_id. \u041d\u043e\u043c\u0435\u0440 \u0447\u0430\u0442\u0430 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c       lines = f.readlines()       if len(lines)>0:         chat_id = lines[0]       else:         chat_id = None     with open('messages.txt','r') as f:# \u0447\u0438\u0442\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c       lines = f.readlines()       if len(lines)>0 and chat_id is not None:#\u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c user_id \u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435         text = lines[0]         token = os.environ['TOKEN']            requests.get(r\"https:\/\/api.telegram.org\/bot\"                          +token                          +r\"\/sendMessage?chat_id=\"+chat_id                          +r\"&amp;text=\"+text)         #\u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u043e\u043a\u0435\u043d\u0430     with open('messages.txt','w') as f:       f.write(\"\")#\u043e\u0447\u0438\u0449\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438     time.sleep(0.3)  def keep_alive():# \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c flask \u0438 reminder \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445   t = Thread(target=run)   t.start()   tr = Thread(target=reminder)   tr.start() <\/code><\/pre>\n<p>\u041f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e! \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u043e\u0441\u044c, \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0438 \u043a\u043b\u044e\u0447 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 https.<\/p>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f &#8212; \u0448\u0430\u0433 2 &#8212; \u043a\u043e\u0434 \u0434\u043b\u044f ESP8266<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u043f\u0440\u0430\u0432\u043e\u043c \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0443\u0433\u043b\u0443 \u044d\u043a\u0440\u0430\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0430. \u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0435\u0435 \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0ce\/65b\/495\/0ce65b495044ace18f4ca9aae1f0defe.png\" width=\"756\" height=\"888\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0ce\/65b\/495\/0ce65b495044ace18f4ca9aae1f0defe.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 \u0438\u043a\u043e\u043d\u043a\u0443 \u0437\u0430\u043c\u043a\u0430 \u0440\u044f\u0434\u043e\u043c \u0441 \u0430\u0434\u0440\u0435\u0441\u043e\u043c \u0441\u0430\u0439\u0442\u0430:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/11a\/61b\/890\/11a61b890246c2d2db2295a35e785faa.png\" width=\"472\" height=\"205\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/11a\/61b\/890\/11a61b890246c2d2db2295a35e785faa.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0438 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442. \u0422\u0435\u043a\u0441\u0442 \u043c\u0435\u043d\u044e \u043c\u043e\u0436\u0435\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u0445, \u043d\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u0442 \u0436\u0435.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/384\/65b\/16b\/38465b16b001a4eed769391155e507fe.png\" width=\"411\" height=\"230\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/384\/65b\/16b\/38465b16b001a4eed769391155e507fe.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c &#171;\u043e\u0442\u043f\u0435\u0447\u0430\u0442\u043e\u043a SHA-1&#187;:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/482\/669\/0d9\/4826690d9cf65d94eb538196197d7e6c.png\" width=\"447\" height=\"510\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/482\/669\/0d9\/4826690d9cf65d94eb538196197d7e6c.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u0434 \u0432 Arduino IDE. \u041c\u0435\u043d\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a Wi-Fi, \u0430\u0434\u0440\u0435\u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 <em>(\u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 https) <\/em>\u0438 \u043e\u0442\u043f\u0435\u0447\u0430\u0442\u043e\u043a SHA-1:<\/p>\n<pre><code class=\"cpp\">#include &lt;ESP8266WiFi.h> #include &lt;WiFiClientSecure.h>  #include &lt;ESP8266WebServer.h> #include &lt;ESP8266HTTPClient.h>  #define LED 2   const char *ssid = \"\u0418\u041c\u042f_WiFi_\u0441\u0435\u0442\u0438\";  const char *password = \"\u041f\u041f\u0410\u0420\u041e\u041b\u042c_WiFi_\u0441\u0435\u0442\u0438\";  const char *host = \"test.username.repl.co\";\/\/\u0430\u0434\u0440\u0435\u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u0435\u0437 https:\/\/ const int httpsPort = 443;  \/\/\u043e\u0442\u043f\u0435\u0447\u0430\u0442\u043e\u043a SHA-1, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0440\u0430\u043d\u044c\u0448\u0435 const char fingerprint[] PROGMEM = \"AA BB CC DD EE FF 00 11 22 33 44 55 66\";  void setup() {   pinMode(LED, OUTPUT);   digitalWrite(LED, HIGH);   delay(1000);   Serial.begin(115200);   WiFi.mode(WIFI_OFF);   delay(1000);   WiFi.mode(WIFI_STA);      WiFi.begin(ssid, password);\/\/\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u0441\u0435\u0442\u0438   Serial.println(\"\");    Serial.print(\"Connecting\");    while (WiFi.status() != WL_CONNECTED) {     delay(500);     Serial.print(\".\");   }     Serial.println(\"\");   Serial.print(\"Connected to \");   Serial.println(ssid);   Serial.print(\"IP address: \");   Serial.println(WiFi.localIP());  }   void loop() {   WiFiClientSecure httpsClient;     Serial.println(host);    Serial.printf(\"Using fingerprint '%s'\\n\", fingerprint);   httpsClient.setFingerprint(fingerprint);   httpsClient.setTimeout(500);    delay(1000);   \/\/\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443   Serial.print(\"HTTPS Connecting\");   int r=0;    while((!httpsClient.connect(host, httpsPort)) &amp;&amp; (r &lt; 30)){       delay(100);       Serial.print(\".\");       r++;   }   if(r==30) {     Serial.println(\"Connection failed\");   }   else {     Serial.println(\"Connected to web\");   }      String ADCData, getData, Link;  \/\/\u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440   int temp = 15;\/\/\u0443\u0441\u043b\u043e\u0432\u043d\u0430\u044f \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441 \u0434\u0430\u0442\u0447\u0438\u043a\u0430   int light = !digitalRead(LED);\/\/\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b \u0438 \u0435\u0441\u0442\u044c \u0421\u0412\u0415\u0422 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435   Link = \"\/iot?temp=\"+String(temp)+\"&amp;light=\"+String(light);\/\/\u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432    Serial.print(\"requesting URL: \");   Serial.println(host+Link); \/\/ \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043f\u043e \u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435   httpsClient.print(String(\"GET \") + Link + \" HTTP\/1.1\\r\\n\" +                \"Host: \" + host + \"\\r\\n\" +                               \"Connection: close\\r\\n\\r\\n\");    Serial.println(\"request sent\");                      while (httpsClient.connected()) {     String line = httpsClient.readStringUntil('\\n');     if (line == \"\\r\") {       Serial.println(\"headers received\");       break;     }   }    Serial.print(\"reply:\"); \/\/\u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e line \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 0 \u0438\u043b\u0438 1, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043e\u0442 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u0430      String line;   while(httpsClient.available()){             line = httpsClient.readStringUntil('\\n');     Serial.println(line);     if (line==\"0\") {\/\/\u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0438\u043b\u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0432\u0435\u0442       digitalWrite(LED, HIGH);     }     if (line==\"1\") {       digitalWrite(LED, LOW);     }   }    Serial.println(\"closing connection\");        delay(500);\/\/\u0436\u0434\u0435\u043c 0.5\u0441 \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c }<\/code><\/pre>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043a\u043e\u0434 \u0432 ESP \u0438 \u043d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0435\u043c\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u043c \u0448\u0430\u0433\u043e\u043c \u043a \u0443\u043c\u043d\u043e\u043c\u0443 \u0434\u043e\u043c\u0443, \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u043e\u043c\u0443 \u0441\u0432\u043e\u0438\u043c\u0438 \u0440\u0443\u043a\u0430\u043c\u0438.<\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043f\u043e\u043b\u0435\u0442 \u0444\u0430\u043d\u0442\u0430\u0437\u0438\u0438 \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d!<\/p>\n<p>\u0422\u0430\u043a\u0438\u0435 \u0434\u0435\u043b\u0430! \u0423\u0441\u043f\u0435\u0445\u043e\u0432!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/710173\/\"> https:\/\/habr.com\/ru\/articles\/710173\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0417\u0430\u0434\u0430\u0447\u0430<\/h2>\n<p>\u041d\u0443\u0436\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438: \u0441\u0432\u0435\u0442, \u0432\u0435\u043d\u0442\u0438\u043b\u044f\u0446\u0438\u044f, \u043f\u043e\u043b\u0438\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430.<br \/>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043b\u044f \u0443\u0447\u0435\u0431\u043d\u043e-\u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0438\u043b\u0438 DIY-\u0437\u0430\u0434\u0430\u0447 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0443\u0436 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u043d\u0435 \u043e\u043f\u043b\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 IP-\u0430\u0434\u0440\u0435\u0441.<\/p>\n<h2>\u0418\u0434\u0435\u044f<\/h2>\n<p>\u041e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0432\u044b\u0445\u043e\u0434 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u0441 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0434\u0432\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430: \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f \u043f\u0440\u0438\u0435\u043c\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0442 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0438 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442 \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c.<\/p>\n<p>\u0412\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 Flask \u0438 \u0431\u043e\u0442\u0430 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u043d\u0430 ReplIt. \u041a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e \u0441 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 24\/7 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/habr.com\/ru\/post\/709314\/\" rel=\"noopener noreferrer nofollow\">\u041a\u0430\u043a \u0445\u043e\u0441\u0442\u0438\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u0430<\/a>.<\/p>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0431\u044b\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Arduino + Ethernet-\u043c\u043e\u0434\u0443\u043b\u044c W5500, \u044d\u0442\u0430 \u0441\u0432\u044f\u0437\u043a\u0430 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u0438 \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u043b\u0430\u0441\u044c \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0435 \u043d\u0430 ReplIt, \u0442.\u043a. \u0441\u0441\u044b\u043b\u043a\u0430 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 https, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 Arduino \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442.<\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u0448\u043b\u043e\u0441\u044c \u0432 \u0432\u0438\u0434\u0435 \u043f\u043b\u0430\u0442\u044b NodeMCU v3 \u0441 \u043c\u043e\u0434\u0443\u043b\u0435\u043c Wi-Fi:<\/p>\n<figure class=\"full-width\"><figcaption>NodeMCU v3 \u0441 WiFi-\u043c\u043e\u0434\u0443\u043b\u0435\u043c  <\/figcaption><\/figure>\n<p>\u042d\u0442\u0430 \u043f\u043b\u0430\u0442\u0430, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 ESP8266, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u0440\u0435\u0434\u0443 Arduino IDE \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u043e\u0439.<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f &#8212; \u0448\u0430\u0433 0 &#8212; \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c IDE<\/h2>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0434\u043b\u044f \u0432\u0435\u0440\u0441\u0438\u0438 Arduino IDE 2.0.3, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043d\u0430 <a href=\"https:\/\/www.arduino.cc\/en\/software\" rel=\"noopener noreferrer nofollow\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435. <\/a><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 IDE \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0435\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 ESP8266.<br \/>\u041d\u0443\u0436\u043d\u043e \u0437\u0430\u0439\u0442\u0438 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 File\u2192Preference:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 \u0434\u043b\u044f \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0430\u0445:<br \/><code>http:\/\/arduino.esp8266.com\/stable\/package_esp8266com_index.json<br \/>https:\/\/dl.espressif.com\/dl\/package_esp32_index.json<\/code><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432 \u043b\u0435\u0432\u043e\u043c \u043c\u0435\u043d\u044e BOARDS MANAGER \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u0430\u043a\u0435\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 ESP8266:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e IDE \u0433\u043e\u0442\u043e\u0432\u0430 \u043a \u0440\u0430\u0431\u043e\u0442\u0435. \u041d\u043e \u043f\u0440\u0435\u0436\u0434\u0435, \u0447\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043a\u043e\u0434 \u0432 ESP, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0432\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043d\u0430 Python \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f &#8212; \u0448\u0430\u0433 1 &#8212; \u041f\u0438\u0448\u0435\u043c \u043a\u043e\u0434 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u0430 \u0438 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 Flask<\/h2>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0442 ESP \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e &#171;\u0443\u0441\u043b\u043e\u0432\u043d\u0430\u044f \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430&#187; (\u0443\u0441\u043b\u043e\u0432\u043d\u0430\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u0430\u044f \u0438\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439) \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u0432 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430.<\/p>\n<p>\u041e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0438 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 ReplIt, \u0432 \u043d\u0435\u043c \u0434\u0435\u043b\u0430\u0435\u043c \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 main.py (\u0432 \u043d\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442) \u0438 background.py (\u0432 \u043d\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440). \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/habr.com\/ru\/post\/709314\/\" rel=\"noopener noreferrer nofollow\">\u041a\u0430\u043a \u0445\u043e\u0441\u0442\u0438\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u0430<\/a>.<\/p>\n<h3>Telegram-\u0431\u043e\u0442<\/h3>\n<p>\u0420\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u043c \u0432 \u0444\u0430\u0439\u043b\u0435 main.py.<\/p>\n<p>\u041c\u043e\u043c\u0435\u043d\u0442\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: <\/p>\n<ul>\n<li>\n<p><code>import pip   pip.main(['install', 'pytelegrambotapi'])<\/code> &#8212; \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u043d\u0430\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p><code>f.write(str(call.from_user.id))<\/code> &#8212; \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c id \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043e\u0431\u0449\u0430\u0435\u043c\u0441\u044f. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c, \u0447\u0442\u043e \u0441 \u0431\u043e\u0442\u043e\u043c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a. <\/p>\n<\/li>\n<li>\n<p><code>bot.send_message(call.from_user.id,\"\u0421\u0432\u0435\u0442 \u0441\u043a\u043e\u0440\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f\")<\/code> &#8212; \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u0447\u0442\u043e &#171;\u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u0440\u0438\u043d\u044f\u0442\u0430&#187;. \u0427\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435, \u043a\u043e\u0433\u0434\u0430 \u043e\u0442 ESP \u043f\u0440\u0438\u0434\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u0447\u0442\u043e \u0441\u0432\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d, \u043c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435. \u0418\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c <strong>user_id.<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0422\u043e\u043a\u0435\u043d \u043e\u0442 \u0431\u043e\u0442\u0430 \u043f\u0440\u044f\u0447\u0435\u043c \u0432 SECRETS, \u0442.\u043a. \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u043e\u0442\u043a\u0440\u044b\u0442 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0434\u043b\u044f \u0432\u0441\u0435\u0445. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u0432 <a href=\"https:\/\/docs.replit.com\/programming-ide\/storing-sensitive-information-environment-variables\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">import os from background import keep_alive import pip pip.main(['install', 'pytelegrambotapi']) import telebot import time  #\u043e\u0447\u0438\u0449\u0430\u0435\u043c \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b \u0438\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u044b\u0435 with open('messages.txt','w') as f:       f.write(\"\") with open('user_id.txt','w') as f:       f.write(\"\") with open('from_esp.txt','w') as f:       f.write(\"\") with open('from_tg.txt','w') as f:       f.write(\"\")  def get_last_update(now,last):   # \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430   diff = now-last   if diff&lt;60:     return f\"{int(diff)} \u0441\u0435\u043a \u043d\u0430\u0437\u0430\u0434\"   elif diff&lt;60*60:     return f\"{int(diff\/60)} \u043c\u0438\u043d \u043d\u0430\u0437\u0430\u0434\"   elif diff&lt;60*60*24:     return f\"{int(diff\/60\/24)} \u0447 \u043d\u0430\u0437\u0430\u0434\"     else:     return \"\u0411\u043e\u043b\u0435\u0435 \u0434\u043d\u044f \u043d\u0430\u0437\u0430\u0434\"   bot = telebot.TeleBot(os.environ['TOKEN'])# \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u043e\u0442  # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440, \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u043a\u043e\u043c\u043c\u0443\u043d\u0438\u043a\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c start_keyboard = telebot.types.InlineKeyboardMarkup() start_keyboard.add(     telebot.types.InlineKeyboardButton('\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e', callback_data='info'),     telebot.types.InlineKeyboardButton('\u0423\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c', callback_data='control') )  control_keyboard = telebot.types.InlineKeyboardMarkup() control_keyboard.add(     telebot.types.InlineKeyboardButton('\u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c', callback_data='on'),     telebot.types.InlineKeyboardButton('\u0412\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c', callback_data='off') ) # \u041a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u044b \u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c \u0431\u043e\u0442\u0430  # \u041d\u0430 \u043b\u044e\u0431\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0435\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 # \u041a\u0430\u043a \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \/start \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f @bot.message_handler(content_types=['text']) def get_text_message(message):   bot.send_message(message.from_user.id,\"\u0427\u0442\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c?\",reply_markup=start_keyboard)  #\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043d\u0430\u0436\u0430\u0442\u0438\u0439 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0438  @bot.callback_query_handler(func=lambda call: True) def func(call):   bot.answer_callback_query(call.id) # \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u043c \u0431\u043e\u0442\u0443, \u0447\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u043e \u043a\u043d\u043e\u043f\u043a\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e   with open('user_id.txt','w') as f:       f.write(str(call.from_user.id)) # \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u0444\u0430\u0439\u043b user_id. \u041e\u043d \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439   if call.data=='info':#\u043d\u0430\u0436\u0430\u0442\u0430 \u043a\u043d\u043e\u043f\u043a\u0430 \u0441 callback_data='info', \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u0437 \u0444\u0430\u0439\u043b\u0430     with open(\"from_esp.txt\",\"r\") as f:# \u0447\u0438\u0442\u0430\u0435\u043c \u0444\u0430\u0439\u043b       temp,light,time_last = f.readlines()[0].split(';')#\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445       last_update = get_last_update(time.time(),float(time_last))# \u0438 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445     #\u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e     bot.send_message(call.from_user.id,f\"\u0412\u0441\u0435 \u0445\u043e\u0440\u043e\u0448\u043e, \\n\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430: {temp} \\n\u041e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0435: {'\u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e' if light=='1' else '\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043e'}\\n\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043e: {last_update}\", reply_markup=start_keyboard)   if call.data=='control':#\u043d\u0430\u0436\u0430\u0442\u0430 \u043a\u043d\u043e\u043f\u043a\u0430 \u0441 callback_data='control'     bot.send_message(call.from_user.id,\"\u0412\u043e\u0442 \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c:\",reply_markup=control_keyboard)   if call.data=='on':#\u043d\u0430\u0436\u0430\u0442\u0430 \u043a\u043d\u043e\u043f\u043a\u0430 \u0441 callback_data='on'     bot.send_message(call.from_user.id,\"\u0421\u0432\u0435\u0442 \u0441\u043a\u043e\u0440\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f\")#\u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e     with open('from_tg.txt','w') as f:#\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u0444\u0430\u0439\u043b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0445\u043e\u0442\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c       f.write('1')#\u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0432\u0435\u0442   if call.data=='off':     bot.send_message(call.from_user.id,\"\u0421\u0432\u0435\u0442 \u0441\u043a\u043e\u0440\u043e \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f\")     with open('from_tg.txt','w') as f:       f.write('0')#\u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0432\u0435\u0442    keep_alive()# \u0437\u0430\u043f\u0443\u0441\u043a \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 background.py bot.polling(non_stop=True, interval=0)# \u0437\u0430\u043f\u0443\u0441\u043a \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u0430<\/code><\/pre>\n<h3>\u0412\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 Flask<\/h3>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Flask \u0438 \u043a\u0430\u043a \u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u0415\u0441\u0442\u044c \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u0438\u043b\u0438 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c \u043e\u0431 \u044d\u0442\u043e\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c<a href=\"https:\/\/docs-python.ru\/packages\/veb-frejmvork-flask-python\/\" rel=\"noopener noreferrer nofollow\"> \u0432\u043e\u0442 \u044d\u0442\u0443<\/a>.<\/p>\n<p>\u0420\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u043c \u043a\u043e\u0434 \u0432 \u0444\u0430\u0439\u043b\u0435 background.py<br \/>\u042d\u0442\u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 2 \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<ul>\n<li>\n<p>\u041e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0441 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c \u0447\u0435\u0440\u0435\u0437 GET-\u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/uptimerobot.com\/index\" rel=\"noopener noreferrer nofollow\">UpTimeRobot<\/a>. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0432\u0441\u0435 \u0432 \u0442\u043e\u0439 \u0436\u0435 <a href=\"https:\/\/habr.com\/ru\/post\/709314\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a>.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">from flask import Flask from flask import request from threading import Thread import time import requests  app = Flask('')  @app.route('\/')#\u0421\u043e\u0437\u0434\u0430\u0435\u043c \"\u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443\" \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u0442 \u043f\u0438\u043d\u0433\u043e\u0432\u0430\u0442\u044c UpTimeRobot def home():   return \"I'm alive\"  @app.route('\/iot', methods=['GET'])#\u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \/iot \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b  def iot():   temp = request.args.get('temp') #\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438\u0437 GET-\u0437\u0430\u043f\u0440\u043e\u0441\u0430   light = request.args.get('light')   with open('from_esp.txt', 'r') as f:#\u0447\u0438\u0442\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 ESP \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437     old_temp,old_light,time_last = f.readlines()[0].split(';')     if old_light==\"0\" and light==\"1\":# \u0438 \u0435\u0441\u043b\u0438 \u0441\u0442\u0430\u0440\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u044b\u043a\u043b, \u0430 \u043d\u043e\u0432\u043e\u0435 \u0432\u043a\u043b       with open('messages.txt', 'w') as f_m:# \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u0444\u0430\u0439\u043b messages \u0442\u0435\u043a\u0441\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f         f_m.write(\"\u0421\u0432\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0438\u043b\u0441\u044f\")     if old_light==\"1\" and light==\"0\":       with open('messages.txt', 'w') as f_m:         f_m.write(\"\u0421\u0432\u0435\u0442 \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u043b\u0441\u044f\")   with open('from_esp.txt', 'w') as f:#\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u0444\u0430\u0439\u043b \u043d\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f     f.write(f\"{temp};{light};{time.time()}\")        with open('from_tg.txt', 'r') as f:# \u0447\u0438\u0442\u0430\u0435\u043c \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0432 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u0435     new_state = f.read(1) #\u0442.\u043a. \u0443 \u043d\u0430\u0441 \u0442\u043e\u043b\u044c\u043a\u043e 1 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c\/\u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0432\u0435\u0442, \u0447\u0438\u0442\u0430\u0435\u043c 1 \u0441\u0438\u043c\u0432\u043e\u043b   return new_state #\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 #\u0414\u043b\u044f Flask-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u043d\u0430 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 https:\/\/\u0441\u0430\u0439\u0442\/iot   def run(): #\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 flask-\u0441\u0435\u0440\u0432\u0435\u0440\u0430   app.run(host='0.0.0.0', port=80)  def reminder():   while True:     with open('user_id.txt','r') as f:#\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c user_id. \u041d\u043e\u043c\u0435\u0440 \u0447\u0430\u0442\u0430 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c       lines = f.readlines()       if len(lines)>0:         chat_id = lines[0]       else:         chat_id = None     with open('messages.txt','r') as f:# \u0447\u0438\u0442\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c       lines = f.readlines()       if len(lines)>0 and chat_id is not None:#\u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c user_id \u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435         text = lines[0]         token = os.environ['TOKEN']            requests.get(r\"https:\/\/api.telegram.org\/bot\"                          +token                          +r\"\/sendMessage?chat_id=\"+chat_id                          +r\"&amp;text=\"+text)         #\u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u043e\u043a\u0435\u043d\u0430     with open('messages.txt','w') as f:       f.write(\"\")#\u043e\u0447\u0438\u0449\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438     time.sleep(0.3)  def keep_alive():# \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c flask \u0438 reminder \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445   t = Thread(target=run)   t.start()   tr = Thread(target=reminder)   tr.start() <\/code><\/pre>\n<p>\u041f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e! \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u043e\u0441\u044c, \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0438 \u043a\u043b\u044e\u0447 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 https.<\/p>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f &#8212; \u0448\u0430\u0433 2 &#8212; \u043a\u043e\u0434 \u0434\u043b\u044f ESP8266<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u043f\u0440\u0430\u0432\u043e\u043c \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0443\u0433\u043b\u0443 \u044d\u043a\u0440\u0430\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0430. \u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0435\u0435 \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 \u0438\u043a\u043e\u043d\u043a\u0443 \u0437\u0430\u043c\u043a\u0430 \u0440\u044f\u0434\u043e\u043c \u0441 \u0430\u0434\u0440\u0435\u0441\u043e\u043c \u0441\u0430\u0439\u0442\u0430:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0438 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442. \u0422\u0435\u043a\u0441\u0442 \u043c\u0435\u043d\u044e \u043c\u043e\u0436\u0435\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u0445, \u043d\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u0442 \u0436\u0435.<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c &#171;\u043e\u0442\u043f\u0435\u0447\u0430\u0442\u043e\u043a SHA-1&#187;:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u0434 \u0432 Arduino IDE. \u041c\u0435\u043d\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a Wi-Fi, \u0430\u0434\u0440\u0435\u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 <em>(\u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 https) <\/em>\u0438 \u043e\u0442\u043f\u0435\u0447\u0430\u0442\u043e\u043a SHA-1:<\/p>\n<pre><code class=\"cpp\">#include &lt;ESP8266WiFi.h> #include &lt;WiFiClientSecure.h>  #include &lt;ESP8266WebServer.h> #include &lt;ESP8266HTTPClient.h<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-389236","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/389236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=389236"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/389236\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=389236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=389236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=389236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}