{"id":1030,"date":"2022-10-18T22:24:43","date_gmt":"2022-10-18T14:24:43","guid":{"rendered":"https:\/\/xujiwei.com\/blog\/?p=1030"},"modified":"2022-10-18T22:47:01","modified_gmt":"2022-10-18T14:47:01","slug":"build-power-meter-with-esphome-and-ina219","status":"publish","type":"post","link":"https:\/\/xujiwei.com\/blog\/2022\/10\/build-power-meter-with-esphome-and-ina219\/","title":{"rendered":"\u4f7f\u7528 ESPHome + INA219 \u6a21\u5757\u6784\u5efa\u4e00\u4e2a\u7b80\u6613\u529f\u7387\u8ba1"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_65 ez-toc-wrap-right counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<p class=\"ez-toc-title\">\u6587\u7ae0\u76ee\u5f55<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69e4035b99a60\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69e4035b99a60\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/xujiwei.com\/blog\/2022\/10\/build-power-meter-with-esphome-and-ina219\/#ESPHome\" title=\"ESPHome\">ESPHome<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/xujiwei.com\/blog\/2022\/10\/build-power-meter-with-esphome-and-ina219\/#INA219\" title=\"INA219\">INA219<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/xujiwei.com\/blog\/2022\/10\/build-power-meter-with-esphome-and-ina219\/#%E6%95%B0%E6%8D%AE%E7%9B%91%E6%B5%8B\" title=\"\u6570\u636e\u76d1\u6d4b\">\u6570\u636e\u76d1\u6d4b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/xujiwei.com\/blog\/2022\/10\/build-power-meter-with-esphome-and-ina219\/#%E9%A1%B9%E7%9B%AE%E4%BB%A3%E7%A0%81\" title=\"\u9879\u76ee\u4ee3\u7801\">\u9879\u76ee\u4ee3\u7801<\/a><\/li><\/ul><\/nav><\/div>\n<p>\u6700\u8fd1\u5728\u4f7f\u7528 ESP32 \u505a\u4e00\u4e9b\u5c0f\u4e1c\u897f\uff0c\u5176\u4e2d\u4e00\u4e2a\u8bbe\u5907\u662f\u4f7f\u7528\u7535\u6c60\u4f9b\u7535\uff0c\u56e0\u6b64\u5bf9\u4f7f\u7528\u7535\u6c60\u65f6\u7684\u7eed\u822a\u6bd4\u8f83\u5173\u5fc3\uff0c\u4f46\u662f\u624b\u5934\u5e76\u6ca1\u6709\u5408\u9002\u7684\u7535\u5b50\u8d1f\u8f7d\u4eea\uff0c\u5728\u7ffb\u6a21\u5757\u5e93\u5b58\u7684\u65f6\u5019\uff0c\u521a\u597d\u53d1\u73b0\u6709\u4e00\u4e2a INA219 \u6a21\u5757\uff0c\u5c31\u76f4\u63a5\u62ff\u5b83\u73b0\u505a\u4e00\u4e2a\u529f\u7387\u8ba1\u4e86\u3002<\/p>\n<p>\u518d\u914d\u4e0a\u4e00\u4e2a 12864 OLED \u5c4f\u5e55\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5b9e\u65f6\u53bb\u89c2\u6d4b\u5355\u7247\u673a\u8bbe\u5907\u7684\u5b9e\u65f6\u529f\u7387\u4ee5\u53ca\u529f\u8017\u4e86\uff1a<\/p>\n<p><img src=\"https:\/\/xujiwei.com\/blog\/wp-content\/uploads\/2022\/10\/easypower_demo.jpg\" alt=\"EasyPower Demo\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"ESPHome\"><\/span>ESPHome<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><a href=\"https:\/\/esphome.io\/\">ESPHome<\/a> \u662f\u4e00\u4e2a\u914d\u7f6e\u5316\u751f\u6210 ESP32\/ESP8266 \u667a\u80fd\u5bb6\u5c45\u56fa\u4ef6\u7684\u7cfb\u7edf\uff0c\u4e00\u822c\u90fd\u4f1a\u7528\u5b83\u6765\u4f5c\u4e3a\u667a\u80fd\u5bb6\u5c45\u8282\u70b9\u4e2d\u7684\u7cfb\u7edf\u6765\u4f7f\u7528\uff0c\u914d\u5408\u5f88\u4fbf\u5b9c\u7684 ESP32\/ESP8266 \u6a21\u5757\uff0c\u4f7f\u7528\u8d77\u6765\u5f88\u662f\u65b9\u4fbf\u3002<\/p>\n<p>\u5728\u67e5\u9605\u5b83\u6240\u652f\u6301\u7684\u6a21\u5757\u65f6\uff0c\u53d1\u73b0 INA219 \u4e5f\u5728\u5176\u4e2d\uff0c\u5e76\u4e14 ESPHome \u672c\u8eab\u5bf9 12864 OLED \u4e5f\u6709\u826f\u597d\u7684\u652f\u6301\uff0c\u56e0\u6b64\u6700\u7ec8\u5c31\u76f4\u63a5\u9009\u62e9\u4e86 ESPHome \u6765\u4f5c\u4e3a\u529f\u7387\u8ba1\u7684\u57fa\u7840\u7cfb\u7edf\uff0c\u8fd9\u6837\u53ef\u4ee5\u7701\u53bb\u7f16\u5199\u5f88\u591a\u57fa\u7840\u4ee3\u7801\uff0c\u4f8b\u5982\u4efb\u52a1\u8bbe\u8ba1\u3001\u5c4f\u5e55\u7ed8\u5236\u3001I2C \u603b\u7ebf\u8bfb\u5199\u7b49\uff0c\u53ea\u9700\u8981\u5173\u6ce8\u529f\u7387\u8ba1\u6838\u5fc3\u7684\u529f\u80fd\u5373\u53ef\u3002<\/p>\n<p>\u6700\u8fd1\u4e5f\u4f7f\u7528 ESPHome \u6bd4\u8f83\u597d\uff0c\u53d1\u73b0\u5b83\u8fd8\u662f\u6709\u5f88\u591a\u4f18\u70b9\u7684\uff0c\u57fa\u672c\u53ef\u4ee5\u4f5c\u4e3a\u4e00\u4e2a Arduino \u9879\u76ee\u7684\u57fa\u7840\u5e94\u7528\u6846\u67b6\u6765\u4f7f\u7528\uff1a<\/p>\n<ul>\n<li>\u914d\u7f6e\u5316\u751f\u6210\u4ee3\u7801\uff0c\u65e0\u9700\u7ba1\u7406\u590d\u6742\u7684\u5e93\u4f9d\u8d56<\/li>\n<li>\u4e30\u5bcc\u7684\u6a21\u7ec4\u5e93\u652f\u6301\uff0c\u5bf9\u4e8e\u5f00\u53d1\u5355\u7247\u673a\u5e94\u7528\u6765\u8bf4\uff0c\u5e38\u89c1\u7684\u8f93\u5165\u8f93\u51fa\u6a21\u5757\u90fd\u5185\u7f6e\u652f\u6301<\/li>\n<li>\u5b8c\u6574\u7684\u8fd0\u884c\u6846\u67b6\uff0c\u5f00\u53d1\u8005\u53ea\u9700\u8981\u5173\u6ce8\u4e1a\u52a1\u672c\u8eab\uff0c\u5176\u4ed6\u76f8\u5173\u5185\u5bb9\u90fd\u5185\u7f6e\u4e86\uff0c\u4f8b\u5982 MQTT\u3001OTA \u7b49\u529f\u80fd<\/li>\n<li>\u7075\u6d3b\u7684 Lambda \u652f\u6301\uff0c\u5b83\u7684 Lambda \u5c31\u662f C++ \u7684 Lambda\uff0c\u56e0\u6b64\u5bf9\u4e8e\u6709\u80fd\u529b\u7684\u5f00\u53d1\u8005\u6765\u8bf4\uff0c\u53ef\u4ee5\u76f4\u63a5\u5199\u4ee3\u7801<\/li>\n<\/ul>\n<p>\u603b\u7684\u6765\u8bf4\uff0c\u5bf9\u4e8e\u4e00\u822c DIY \u9879\u76ee\u6765\u8bf4\uff0cESPHome \u8db3\u591f\u5f3a\u5927\u3001\u8db3\u591f\u7075\u6d3b\u6765\u5904\u7406\u5927\u90e8\u5206\u9700\u6c42\u4e86\u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"INA219\"><\/span>INA219<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>INA219 \u662f\u5fb7\u5dde\u4eea\u5668\u51fa\u54c1\u7684\u4e00\u6b3e\u529f\u7387\u76d1\u6d4b\u82af\u7247\u3002<\/p>\n<blockquote>\n<p>INA219 \u662f\u4e00\u6b3e\u5177\u5907I2C \u6216SMBUS \u517c\u5bb9\u63a5\u53e3\u7684\u5206\u6d41\u5668\u548c\u529f\u7387\u76d1\u6d4b\u8ba1\u3002 \u8be5\u5668\u4ef6\u76d1\u6d4b\u5206\u6d41\u5668\u7535\u538b\u964d\u548c\u603b\u7ebf\u7535\u6e90\u7535\u538b\uff0c\u8f6c\u6362\u6b21\u6570\u548c\u6ee4\u6ce2\u9009\u9879\u53ef\u901a\u8fc7\u7f16\u7a0b\u8bbe\u5b9a\u3002 \u53ef\u7f16\u7a0b\u6821\u51c6\u503c\u4e0e\u5185\u90e8\u4e58\u6cd5\u5668\u76f8\u7ed3\u5408\uff0c\u652f\u6301\u76f4\u63a5\u8bfb\u53d6\u7535\u6d41\u503c\uff08\u5355\u4f4d\uff1a\u5b89\u57f9\uff09\u3002 \u901a\u8fc7\u9644\u52a0\u4e58\u6cd5\u5bc4\u5b58\u5668\u53ef\u8ba1\u7b97\u529f\u7387\uff08\u5355\u4f4d\uff1a\u74e6\uff09\u3002<\/p>\n<\/blockquote>\n<p>INA219 \u7684\u7279\u6027\uff1a<\/p>\n<ul>\n<li>\u611f\u6d4b\u7684\u603b\u7ebf\u7535\u538b\u8303\u56f4\uff1a0V \u81f3 26V<\/li>\n<li>\u62a5\u544a\u7535\u6d41\u3001\u7535\u538b\u3001\u548c\u529f\u7387<\/li>\n<li>16 \u4e2a\u53ef\u7f16\u7a0b\u5730\u5740<\/li>\n<li>\u9ad8\u7cbe\u5ea6\uff1a\u6574\u4e2a\u6e29\u5ea6\u8303\u56f4\u5185\u7684\u7cbe\u5ea6\u4e3a 0.5%\uff08\u6700\u5927\u503c\uff09(INA219B)<\/li>\n<\/ul>\n<p>\u4e00\u822c\u5355\u7247\u673a\u5f00\u53d1\uff0c\u4f9b\u7535\u90fd\u662f 5V \u6216\u8005 3.3V\uff0c\u9502\u7535\u6c60\u4f9b\u7535\u7684\u8303\u56f4\u4e5f\u5728 3V~4.2V\uff0c\u56e0\u6b64 INA219 \u7684\u6d4b\u91cf\u8303\u56f4\u8db3\u591f\u4f7f\u7528\u4e86\uff0c\u800c\u4e14 0.5% \u7684\u7cbe\u5ea6\u5728\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u4e5f\u8db3\u591f\u6d4b\u91cf\u51fa\u9884\u671f\u8303\u56f4\u5185\u7684\u6570\u636e\u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E6%95%B0%E6%8D%AE%E7%9B%91%E6%B5%8B\"><\/span>\u6570\u636e\u76d1\u6d4b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u5bf9\u4e8e\u5982\u4f55\u76d1\u6d4b\u6570\u636e\uff0c\u6211\u76f4\u63a5\u5728 App Store \u4e0a\u627e\u5230\u4e00\u4e2a App <a href=\"https:\/\/apps.apple.com\/us\/app\/mqtt-explorer\/id1455214828\">MQTT Explorer<\/a>\uff0c\u5b83\u53ef\u4ee5\u5c06 MQTT Topic \u6d88\u606f\u4e2d\u7684\u6570\u503c\u76f4\u63a5\u663e\u793a\u4e3a\u56fe\u8868\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u53bb\u89c2\u6d4b\u6574\u4e2a\u8bbe\u5907\u5728\u8fd0\u884c\u671f\u95f4\u7684\u529f\u7387\u3001\u8017\u7535\u91cf\u53d8\u5316\u3002<\/p>\n<p><img src=\"https:\/\/xujiwei.com\/blog\/wp-content\/uploads\/2022\/10\/easypower_monitor-scaled.jpg\" alt=\"EasyPower Data Monitor\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E9%A1%B9%E7%9B%AE%E4%BB%A3%E7%A0%81\"><\/span>\u9879\u76ee\u4ee3\u7801<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u8fd9\u4e2a\u529f\u7387\u8ba1\u6bd4\u8f83\u7b80\u5355\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 ESP8266 + INA219 \u6a21\u5757 + 12864 OLED \u5728\u6d1e\u6d1e\u677f\u4e0a\u98de\u7ebf\u8fde\u63a5\u8d77\u6765\uff0c\u63d2\u4e0a USB \u5c31\u76f4\u63a5\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528\u4e86\u3002<\/p>\n<p>\u6211\u5df2\u7ecf\u6574\u7406\u597d\u4e86\u9879\u76ee\u7684\u4ee3\u7801\uff0c\u653e\u5728\u4e86 GitHub \u4e0a\u3002<\/p>\n<p>\u5177\u4f53\u7684\u4ee3\u7801\u8bf7\u524d\u5f80 GitHub\uff1a<a href=\"https:\/\/github.com\/ohdarling\/EasyPower\">ohdarling\/EasyPower<\/a><\/p>\n<p>--- EOF ---<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u5728\u4f7f\u7528 ESP32 \u505a\u4e00\u4e9b\u5c0f\u4e1c\u897f\uff0c\u5176\u4e2d\u4e00\u4e2a\u8bbe\u5907\u662f\u4f7f\u7528\u7535\u6c60\u4f9b\u7535\uff0c\u56e0\u6b64\u5bf9\u4f7f\u7528\u7535\u6c60 &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/xujiwei.com\/blog\/2022\/10\/build-power-meter-with-esphome-and-ina219\/\">\u7ee7\u7eed\u9605\u8bfb &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":1032,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[167],"tags":[262,328,327,329,252],"_links":{"self":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/posts\/1030"}],"collection":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/comments?post=1030"}],"version-history":[{"count":0,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/posts\/1030\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/media\/1032"}],"wp:attachment":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/media?parent=1030"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/categories?post=1030"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/tags?post=1030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}