{"id":21071,"date":"2024-01-23T10:12:32","date_gmt":"2024-01-23T02:12:32","guid":{"rendered":"https:\/\/www.circuspi.com\/?p=21071"},"modified":"2024-01-23T10:12:33","modified_gmt":"2024-01-23T02:12:33","slug":"esp32-i2c-sht30-oled","status":"publish","type":"post","link":"https:\/\/www.circuspi.com\/index.php\/2024\/01\/23\/esp32-i2c-sht30-oled\/","title":{"rendered":"ESP32\u6559\u5b78\u7cfb\u5217(\u5341)\uff1aI2C\u8b80\u53d6SHT30\u6eab\u6fd5\u5ea6\u611f\u6e2c\u8207OLED\u986f\u793a"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"526\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2024\/01\/1000x526_1-3.jpg\" alt=\"\" class=\"wp-image-21237\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u524d\u8a00<\/h2>\n\n\n\n<p>I\u00b2C\u662f\u4e00\u7a2e\u76f8\u7576\u5e38\u898b\u4e14\u6709\u540d\u7684\u50b3\u8f38\u5354\u8b70\uff0c\u5b83\u88ab\u5ee3\u6cdb\u7684\u61c9\u7528\u5728\u5404\u7a2e\u611f\u6e2c\u5668\u7684\u901a\u8a0a\u754c\u9762\u4e0a\u3002\u672c\u6587\u5c07\u8aaa\u660e\u5982\u4f55\u5c07ESP32\u64cd\u4f5c\u5728Master\u4ee5\u53caSlave Mode\u4e0b\uff0c\u4e26\u4ee5<a href=\"https:\/\/www.icshop.com.tw\/products\/368112100026\" target=\"_blank\" rel=\"noreferrer noopener\">SHT3x\u6eab\u6ebc\u5ea6\u611f\u6e2c\u5668<\/a>\uff0c\u4ee5\u53ca1.3\u540bOLED\u986f\u793a\u5668\u70ba\u4f8b\uff0c\u8aaa\u660eESP32\u5982\u4f55\u5206\u5225\u4f7f\u7528\u9019\u5169\u500bI\u00b2C\u88dd\u7f6e\uff1b\u6700\u5f8c\u7d50\u5408\u5169\u8005\uff0c\u5c07\u6e2c\u91cf\u5230\u7684\u6eab\u6ebc\u5ea6\u6578\u503c\u986f\u793a\u5728OLED\u4e0a\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ec0\u9ebc\u662fI2C<\/h2>\n\n\n\n<p>I\u00b2C\uff08\u5538\u4f5cI-Square-C\uff09\uff0c\u662f Inter-Integrated Circuit \u7684\u7e2e\u5beb\uff0c\u6709\u6642\u4e5f\u6703\u5beb\u4f5cIIC\u3001I2C \u6216 I\u00b2C bus\uff0c\u65bc1980\u5e74\u4ee3\u7531Philips\u516c\u53f8\uff08\u73fe\u70baNXP\uff09\u6240\u8a2d\u8a08\u51fa\u7684\u4e00\u7a2e\u901a\u8a0a\u5354\u8b70\uff0c\u6700\u521d\u7684\u76ee\u7684\u662f\u70ba\u4e86\u8b93\u540c\u4e00\u7247\u677f\u5b50\u4e0a\u7684\u5143\u4ef6\u53ef\u4ee5\u4e92\u76f8\u901a\u8a0a\u3002<\/p>\n\n\n\n<p>I\u00b2C\u662f\u4e00\u7a2e\u5177\u6709\u540c\u6b65\u8a0a\u865f\u7684\u4e32\u5217\u901a\u8a0a\u5354\u8b70\uff0c\u652f\u63f4\u591a\u500b\u4e3b\u5f9e\u8a2d\u5099\u9032\u884c\u96d9\u5411\u901a\u8a0a\uff0c\u5b83\u5141\u8a31\u7531\u4e00\u500b\u63a7\u5236\u5668\uff08Controller\uff09\u63a7\u5236\u591a\u500b\u5468\u908a\u8a2d\u5099\uff08Peripheral\uff09\uff0c\u4e5f\u53ef\u4ee5\u7531\u591a\u500b\u63a7\u5236\u5668\u63a7\u5236\u4e00\u500b\u5468\u908a\u8a2d\u5099\uff0c\u64c1\u6709\u9748\u6d3b\u7684\u67b6\u69cb\u662f\u5b83\u7684\u512a\u9ede\u4e4b\u4e00\u3002<\/p>\n\n\n\n<p>I\u00b2C\u7684\u53e6\u4e00\u500b\u512a\u9ede\u662f\u786c\u9ad4\u63a5\u7dda\u7c21\u55ae\uff0c\u53ea\u9700\u8981\u5169\u689d\u8a0a\u865f\u7dda(Bus)\u5c31\u80fd\u8207\u5176\u5b83\u88dd\u7f6e\u901a\u8a0a\uff0c\u9019\u9ede\u8207UART\u76f8\u540c\u3002\u4e0d\u540c\u7684\u662f\uff0cI\u00b2C\u53ef\u4ee5\u9023\u63a5\u591a\u500b\u8a2d\u5099\uff0c\u4e14\u4e0d\u8ad6\u662f\u4e3b\u8a2d\u5099\u6216\u662f\u5468\u908a\u8a2d\u5099\uff0c\u6240\u6709\u8a2d\u5099\u90fd\u5171\u4eab\u5169\u689d\u76f8\u540c\u7684\u8a0a\u865f\u7dda\uff08\u7a31\u4f5cBus\uff09\uff0c\u5206\u5225\u7528\u4f86\u50b3\u8f38\u8cc7\u6599(data)\u8207\u6642\u8108\u8a0a\u865f(clock)\u3002\u63a7\u5236\u5668\u53ef\u4ee5\u4f9d\u7167\u6bcf\u500b\u5468\u908a\u8a2d\u5099\u7684\u5730\u5740\u9078\u64c7\u8981\u9032\u884c\u901a\u8a0a\u7684\u5c0d\u8c61\uff0c\u6bcf\u500b\u5468\u908a\u8a2d\u5099\u90fd\u6709\u4e0d\u91cd\u8907\u76847\u4f4d\u5143\u5730\u5740\u3002\u5728\u5d4c\u5165\u5f0f\u61c9\u7528\u4e2d\uff0c\u8a31\u591a\u77ed\u8ddd\u96e2\u50b3\u8f38\u7684\u8a2d\u5099\u4e0a\u90fd\u4f7f\u7528I\u00b2C\u50b3\u8f38\u5354\u8b70\uff0c\u50cf\u662fOLED\u986f\u793a\u5668\u3001\u6578\u4f4d\u6eab(\u6ebc)\u5ea6\u611f\u6e2c\u5668\u3001DAC\u3001MPU6050\u3001LCD\u986f\u793a\u5668\u7b49\u90fd\u662f\u5e38\u898b\u7684\u5468\u908a\u88dd\u7f6e\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">I\u00b2C\u7684\u57fa\u672c\u901a\u8a0a\u5354\u5b9a<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1600\" height=\"400\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2024\/01\/\u901a\u8a0a\u5716_\u5de5\u4f5c\u5340\u57df-1.jpg\" alt=\"\" class=\"wp-image-21173\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u5982\u4f55\u5728ESP32\u4f7f\u7528I2C<\/h2>\n\n\n\n<p>I\u00b2C\u901a\u8a0a\u6642\u53ea\u9700\u4f7f\u7528\u5169\u689dBus\uff1aSDA\uff08serial data\uff09\u8207SCL\uff08serial clock\uff09\u3002SDA\u7528\u4f86\u50b3\u8f38\u8cc7\u6599\uff0cSCL\u5247\u662f\u7528\u4f86\u540c\u6b65\u8a2d\u5099\u901a\u8a0a\u7684\u6642\u8108\u8a0a\u865f\uff0c\u9019\u5169\u689dBus\u90fd\u4f7f\u7528open-drain\uff08\u6216\u662f open-collector\uff09\u7684\u96fb\u8def\u7d50\u69cb\u9a45\u52d5\u3002\u9019\u7a2e\u96fb\u8def\u7d50\u69cb\u4f7f\u5f97I\u00b2C\u53ef\u4ee5\u53ea\u7528\u4e00\u689d\u8cc7\u6599\u7dda\u5c31\u9054\u5230\u96d9\u5411\u50b3\u8f38\u7684\u529f\u80fd\uff0c\u4f46\u540c\u6642\u9019\u4e5f\u8868\u793a\u8a2d\u5099\u6c92\u6709\u81ea\u4e3b\u8f38\u51fa\u9ad8\u96fb\u58d3\u6e96\u4f4d\u7684\u9a45\u52d5\u80fd\u529b\u3002\u70ba\u4e86\u89e3\u6c7a\u9019\u500b\u554f\u984c\uff0c\u6211\u5011\u6703\u5728open-drain\u7684\u5916\u90e8\u96fb\u8def\u9023\u63a5\u4e0a\u62c9\u96fb\u963b\uff0c\u8b93\u8cc7\u6599\u7dda\u7684\u72c0\u614b\u7dad\u6301\u5728\u9ad8\u96fb\u4f4d\uff0c\u9019\u9ebc\u4e00\u4f86\u8a2d\u5099\u5c31\u53ef\u4ee5\u6309\u7167\u5be6\u969b\u60c5\u6cc1\u9078\u64c7\u4e0b\u62c9\uff08\u4f4e\u96fb\u4f4d\uff09\u6216\u91cb\u653e\u8cc7\u6599\u7dda\uff08\u9ad8\u96fb\u4f4d\uff09\u4f86\u6539\u8b8a\u96fb\u58d3\u6e96\u4f4d\u3002<\/p>\n\n\n\n<p>\u4e0a\u62c9\u96fb\u963b\u7684\u6578\u503c\u53ef\u4ee5\u7d93\u7531\u8a08\u7b97\u5f97\u51fa\uff0c\u901a\u5e385V\u7684\u8a2d\u5099\u6703\u4f7f\u75284.7k\u03a9\uff0c3V\u7684\u8a2d\u5099\u6703\u4f7f\u75282.4k\u03a9\u3002\u4e0d\u904e\uff0c\u5927\u90e8\u5206\u7684\u6a21\u7d44\u5728\u8a2d\u8a08\u6642\u90fd\u6709\u52a0\u5165\u4e0a\u62c9\u96fb\u963b\uff0c\u4f7f\u7528\u6642\u4e0d\u9700\u8981\u518d\u53e6\u5916\u9023\u63a5\u3002\u672c\u7bc7\u6240\u4f7f\u7528\u7684\u6a21\u7d44\u90fd\u4e0d\u9700\u8981\u52a0\u4e0a\u62c9\u96fb\u963b\uff0c\u53ea\u8981\u5c07\u5c0d\u61c9\u7684\u63a5\u8173\u9023\u63a5\u5728\u4e00\u8d77\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n\n\n\n<p>\u7576\u6211\u5011\u4f7f\u7528Arduino IDE\u958b\u767c\u6642\uff0c\u9810\u8a2d\u7684SDA\u63a5\u8173\u662fGPIO 21\uff0cSDL\u63a5\u8173\u662fGPIO 22\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>I2C\u8a2d\u5099<\/th><th>ESP32<\/th><\/tr><\/thead><tbody><tr><td>VCC<\/td><td>3.3V\/5V<\/td><\/tr><tr><td>GND<\/td><td>GND<\/td><\/tr><tr><td>SDA<\/td><td>SDA (GPIO 21)<\/td><\/tr><tr><td>SCL<\/td><td>SCL (GPIO 22)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>ESP32\u7684I\u00b2C\u4ecb\u9762\u53ef\u4ee5\u505a\u70ba\u4e3b\u63a7\u7aef\uff08Master Mode\uff09\u6216\u662f\u505a\u70ba\u5468\u908a\u8a2d\u5099\uff08Slave Mode\uff09\u4f7f\u7528\u3002\u591a\u6578\u60c5\u6cc1\u4e0bESP32\u90fd\u6703\u505a\u70ba\u4e3b\u63a7\u7aef\uff0c\u642d\u914d\u5468\u908a\u611f\u6e2c\u5668\/\u6a21\u7d44\u4f7f\u7528\u3002\u82e5\u60f3\u77ad\u89e3\u5982\u4f55\u7576\u4f5c\u5468\u908a\u8a2d\u5099\u4f7f\u7528\uff0c\u53ef\u4ee5\u81ea\u884c\u53c3\u8003Arduino IDE\u4e2d\u7684\u7bc4\u4f8b\u7a0b\u5f0f (File&gt;Examples&gt;Wire&gt;WireMaster,WireSlave)\u3002\u5728\u4f7f\u7528I\u00b2C\u6a21\u7d44\u6642\uff0c\u901a\u5e38\u4e5f\u90fd\u8981\u53e6\u5916\u5b89\u88dd\u51fd\u5f0f\u5eab\uff0c\u8207I\u00b2C\u5354\u8b70\u901a\u8a0a\u904e\u7a0b\u7684\u95dc\u806f\u5ea6\u8f03\u4f4e\uff0c\u6240\u4ee5\u4e0b\u9762\u63a5\u7d39\u7d30\u7bc0\u90e8\u5206\u7684\u5167\u5bb9\u50c5\u63d0\u4f9b\u7d66\u6709\u8208\u8da3\u7684\u8b80\u8005\u53c3\u8003\u3002\u82e5\u60f3\u77ad\u89e3\u5982\u4f55\u4f7f\u7528<a href=\"https:\/\/www.icshop.com.tw\/products\/368112100026\" target=\"_blank\" rel=\"noreferrer noopener\">SHT3x\u6eab\u6ebc\u5ea6\u611f\u6e2c\u5668<\/a>\u548cOLED\uff0c\u53ef\u4ee5\u76f4\u63a5\u8df3\u5230\u7bc4\u4f8b\u90e8\u5206\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Master Mode<\/h3>\n\n\n\n<p>\u6211\u5011\u901a\u5e38\u6703\u5c07ESP32\u7576\u4f5c\u4e3b\u63a7\u7aef\u9023\u63a5\u5404\u9805\u611f\u6e2c\u5668\u6216\u63a7\u5236\u5176\u5b83\u7684\u5468\u908a\u8a2d\u5099\uff0c\u9019\u6642\u5019ESP32\u5c31\u6703\u64cd\u4f5c\u5728Master mode\u4e0b\uff0c\u53ef\u4ee5\u5c0d\u5468\u908a\u8a2d\u5099\u767c\u8d77\u3001\u7d50\u675f\u50b3\u8f38\uff0c\u6216\u662f\u8b80\u53d6\u5468\u908a\u8a2d\u5099\u56de\u50b3\u7684\u5167\u5bb9\u3002<\/p>\n\n\n\n<p><strong>\u4f7f\u7528\u7bc4\u4f8b<\/strong><\/p>\n\n\n\n<p>\u95dc\u65bcMaster Mode\u5177\u9ad4\u7684\u4f7f\u7528\u7bc4\u4f8b\u53ef\u4ee5\u5728Arduino IDE\u7684File&gt;Examples&gt;Wire&gt;WireMaster\u4e2d\u627e\u5230<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/12\/Untitled-7.png\" alt=\"\" class=\"wp-image-21072\" width=\"843\" height=\"500\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>\u4e0b\u9762\u662f\u95dc\u65bcMaster Mode \u50b3\u8f38\u76f8\u95dcAPI\u7684\u8aaa\u660e\uff1a<\/p>\n\n\n\n<ul>\n<li><strong>begin<\/strong><\/li>\n<\/ul>\n\n\n\n<p>\u4f7f\u7528\u9810\u8a2dI\u00b2C\u63a5\u8173\u7684\u8a71\uff0c\u5728setup()\u4e2d\u547c\u53ebWire.begin()\u5373\u53ef<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void setup() {\n  Wire.begin();\n}<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u8981\u4f7f\u7528\u5176\u4ed6\u63a5\u8173\uff0c\u53ef\u4ee5\u5728begin()\u524d\u52a0\u4e0asetPins()\uff0c\u4e26\u5c07\u6307\u5b9a\u7684\u63a5\u8173\u7576\u4f5c\u53c3\u6578\u50b3\u5165\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#define I2C_SDA 4\n#define I2C_SCL 5\n\nvoid setup() {\n  Wire.setPins(I2C_SDA, I2C_SCL);\n  Wire.begin();\n}<\/code><\/pre>\n\n\n\n<ul>\n<li><strong>beginTransmission<\/strong><\/li>\n<\/ul>\n\n\n\n<p><code><code><span data-token-index=\"1\" spellcheck=\"false\" class=\"notion-enable-hover\" style=\"font-family:&quot;SFMono-Regular&quot;, Menlo, Consolas, &quot;PT Mono&quot;, &quot;Liberation Mono&quot;, Courier, monospace;line-height:normal;background:rgba(135,131,120,.15);color:#EB5757;border-radius:4px;font-size:85%;padding:0.2em 0.4em\">beginTransmission<\/span><\/code><\/code>\u7528\u4f86\u5c0d\u5468\u908a\u8a2d\u5099\u767c\u8d77\u50b3\u8f38<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u51fd\u5f0f\u539f\u578b\uff1a\nvoid beginTransmission(uint16_t address)\n\n\u4f7f\u7528\u7bc4\u4f8b\uff1a\nWire.beginTransmission(0x55);<\/code><\/pre>\n\n\n\n<p>\u53c3\u6578\u8aaa\u660e\uff1a<\/p>\n\n\n\n<p>address: \u5468\u908a\u8a2d\u5099\u7684I2C\u5730\u5740<\/p>\n\n\n\n<ul>\n<li><strong>write<\/strong><\/li>\n<\/ul>\n\n\n\n<p><code><code><span data-token-index=\"1\" spellcheck=\"false\" class=\"notion-enable-hover\" style=\"font-family:&quot;SFMono-Regular&quot;, Menlo, Consolas, &quot;PT Mono&quot;, &quot;Liberation Mono&quot;, Courier, monospace;line-height:normal;background:rgba(135,131,120,.15);color:#EB5757;border-radius:4px;font-size:85%;padding:0.2em 0.4em\">write<\/span><\/code><\/code>\u53ef\u4ee5\u5c07\u8cc7\u6599\u5beb\u5165\u7de9\u885d\u5340(buffer)\uff0c\u5b83\u6703\u56de\u50b3\u5167\u6dfb\u52a0\u5230\u7de9\u885d\u5340\u7684\u8cc7\u6599\u5927\u5c0f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u51fd\u5f0f\u539f\u578b\uff1a\nsize_t write(uint8_t);\n\n\u4f7f\u7528\u7bc4\u4f8b\uff1a\nWire.write(x);<\/code><\/pre>\n\n\n\n<ul>\n<li><strong>endTransmission<\/strong><\/li>\n<\/ul>\n\n\n\n<p>\u4f7f\u7528<code><code><span data-token-index=\"1\" spellcheck=\"false\" class=\"notion-enable-hover\" style=\"font-family:&quot;SFMono-Regular&quot;, Menlo, Consolas, &quot;PT Mono&quot;, &quot;Liberation Mono&quot;, Courier, monospace;line-height:normal;background:rgba(135,131,120,.15);color:#EB5757;border-radius:4px;font-size:85%;padding:0.2em 0.4em\">endTransmission<\/span><\/code><\/code>\u5c07\u8cc7\u6599\u5f9e\u7de9\u885d\u5340\u767c\u9001\u5230\u5468\u908a\u8a2d\u5099\uff0c\u4e26\u7d50\u675f\u50b3\u8f38\u3002\u9019\u500b\u51fd\u5f0f\u6703\u56de\u50b3\u932f\u8aa4\u4ee3\u78bc(error code)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u51fd\u5f0f\u539f\u578b\uff1a\nuint8_t endTransmission(bool sendStop);\n\n\u4f7f\u7528\u7bc4\u4f8b\uff1a\nWire.endTransmission(true);<\/code><\/pre>\n\n\n\n<p>\u53c3\u6578\u8aaa\u660e\uff1a<\/p>\n\n\n\n<p>sendStop: \u555f\u7528 (true) \u6216\u505c\u7528 (false) \u505c\u6b62\u7684\u8a0a\u865f\u3002\u9810\u8a2d\u53c3\u6578\u70batrue\u3002<\/p>\n\n\n\n<p>error code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ error code\ntypedef enum {\n    I2C_ERROR_OK=0,\n    I2C_ERROR_DEV,\n    I2C_ERROR_ACK,\n    I2C_ERROR_TIMEOUT,\n    I2C_ERROR_BUS,\n    I2C_ERROR_BUSY,\n    I2C_ERROR_MEMORY,\n    I2C_ERROR_CONTINUE,\n    I2C_ERROR_NO_BEGIN\n} i2c_err_t;<\/code><\/pre>\n\n\n\n<ul>\n<li><strong>requestFrom<\/strong><\/li>\n<\/ul>\n\n\n\n<p>\u5982\u679c\u8981\u8b80\u53d6\u88dd\u7f6e\u56de\u50b3\u7684\u5167\u5bb9\uff0c\u53ef\u4ee5\u547c\u53eb<code><code><span data-token-index=\"1\" spellcheck=\"false\" class=\"notion-enable-hover\" style=\"font-family:&quot;SFMono-Regular&quot;, Menlo, Consolas, &quot;PT Mono&quot;, &quot;Liberation Mono&quot;, Courier, monospace;line-height:normal;background:rgba(135,131,120,.15);color:#EB5757;border-radius:4px;font-size:85%;padding:0.2em 0.4em\">requestFrom<\/span><\/code><\/code>\u5b83\u6703\u56de\u50b3\u8b80\u53d6\u5230\u7684\u8cc7\u6599\u5927\u5c0f(number of bytes)\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u51fd\u5f0f\u539f\u578b\uff1a\nuint8_t requestFrom(uint16_t address, uint8_t size, bool sendStop)\n\n\u4f7f\u7528\u7bc4\u4f8b\uff1a\nWire.requestFrom(0x55, 16);<\/code><\/pre>\n\n\n\n<p>\u53c3\u6578\u8aaa\u660e\uff1a<\/p>\n\n\n\n<p>address: \u5468\u908a\u8a2d\u5099\u7684I2C\u5730\u5740<\/p>\n\n\n\n<p>size: \u6240\u9700\u7684\u8a18\u61b6\u9ad4\u5927\u5c0f<\/p>\n\n\n\n<p>sendStop: \u555f\u7528 (true) \u6216\u505c\u7528 (false) \u505c\u6b62\u7684\u8a0a\u865f\u3002\u9810\u8a2d\u53c3\u6578\u70batrue<\/p>\n\n\n\n<ul>\n<li><strong>readBytes<\/strong><\/li>\n<\/ul>\n\n\n\n<p><code><code><span data-token-index=\"1\" spellcheck=\"false\" class=\"notion-enable-hover\" style=\"font-family:&quot;SFMono-Regular&quot;, Menlo, Consolas, &quot;PT Mono&quot;, &quot;Liberation Mono&quot;, Courier, monospace;line-height:normal;background:rgba(135,131,120,.15);color:#EB5757;border-radius:4px;font-size:85%;padding:0.2em 0.4em\">readBytes<\/span><\/code><\/code>\u7528\u4f86\u67e5\u770b\u8cc7\u6599<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u51fd\u5f0f\u539f\u578b\uff1a\nvirtual size_t readBytes(char *buffer, size_t length);\n\n\u4f7f\u7528\u7bc4\u4f8b\uff1a\nuint8_t bytesReceived = Wire.requestFrom(0x55, 16);\nuint8_t temp&#91;bytesReceived];\n\nWire.readBytes(temp, error);<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5982\u4f55\u6383\u63cfI2C\u8a2d\u5099\u5730\u5740<\/h2>\n\n\n\n<p>I\u00b2C bus\u4e0a\u7684\u5468\u908a\u8a2d\u5099\u90fd\u6703\u6709\u4e00\u7d44\u752816\u9032\u4f4d\u8868\u793a\u7684\u8a2d\u5099\u5730\u5740\uff0c\u901a\u5e38\u5730\u5740\u6703\u6a19\u8a3b\u5728\u6a21\u7d44\u4e0a\u3002\u5728\u4f7f\u7528\u8a2d\u5099\u524d\uff0c\u6211\u5011\u53ef\u4ee5\u5148\u6383\u63cf\u4e00\u6b21\uff0c\u4ee5\u78ba\u8a8d\u8a2d\u5099\u5be6\u969b\u7684\u5730\u5740\u3002<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/FelixLinSY\/880492e296985ccd28dcefd86c73a293.js\"><\/script>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7bc4\u4f8b1: \u4f7f\u7528SHT3x\u6e2c\u91cf\u6eab\u6fd5\u5ea6<\/h2>\n\n\n\n<p>\u9019\u500b\u7bc4\u4f8b\u6703\u4f7f\u7528<a href=\"https:\/\/www.icshop.com.tw\/products\/368112100026\" target=\"_blank\" rel=\"noreferrer noopener\">Circus SHT3x<\/a>\u5728Arduino IDE\u7684\u5e8f\u5217\u57e0\u76e3\u63a7\u8996\u7a97\u986f\u793a\u6eab\u6ebc\u5ea6\u6578\u503c\u3002<\/p>\n\n\n\n<p>\u672c\u7bc4\u4f8b\u4f7f\u7528\u7684\u662f<a href=\"https:\/\/www.icshop.com.tw\/products\/368112100026\" target=\"_blank\" rel=\"noreferrer noopener\">Circus SHT3x \u6eab\u6ebc\u5ea6\u611f\u6e2c\u5668<\/a>\u6a21\u7d44\u3002\u76f8\u8f03\u65bc\u53e6\u4e00\u6b3e\u5e38\u898b\u7684\u6eab\u6ebc\u5ea6\u611f\u6e2c\u5668DHT22\uff0c\u9019\u6b3e\u611f\u6e2c\u5668\uff08SHT30\u6676\u7247\uff09\u7684\u6eab\u5ea6\u91cf\u6e2c\u7bc4\u570d\u66f4\u5ee3\uff0c\u4e5f\u6709\u66f4\u597d\u7684\u6e2c\u91cf\u7cbe\u5ea6\uff0c\u9ad4\u7a4d\u5c0f\u3001\u50f9\u9322\u4e5f\u66f4\u4fbf\u5b9c\uff0c\u4e0d\u59a8\u53ef\u4ee5\u5c07\u5176\u4f5c\u70ba\u53d6\u4ee3DHT22\u7684\u53e6\u4e00\u9805\u9078\u64c7\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662f<a href=\"https:\/\/www.icshop.com.tw\/products\/368112100026\" target=\"_blank\" rel=\"noreferrer noopener\">SHT3x\u6a21\u7d44<\/a>\u8207DHT22\u7684\u7c21\u6613\u6bd4\u8f03\u8868\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u53c3\u6578<\/th><th>SHT3x\u6a21\u7d44<\/th><th>DHT22\u6a21\u7d44<\/th><\/tr><\/thead><tbody><tr><td>\u8f38\u5165\u96fb\u58d3 (DC)<\/td><td>3.3V ~ 5V<\/td><td>3.3V ~ 5.5V<\/td><\/tr><tr><td>\u5de5\u4f5c\u7bc4\u570d(\u6eab\u5ea6)<\/td><td>-40\u00b0C~125\u00b0C<\/td><td>-40\u00b0C ~ 80\u00b0C<\/td><\/tr><tr><td>\u5de5\u4f5c\u7bc4\u570d(\u6fd5\u5ea6)<\/td><td>0%~100% RH<\/td><td>0% ~ 99.9% RH<\/td><\/tr><tr><td>\u6e2c\u91cf\u7cbe\u5ea6 (\u6eab\u5ea6)<\/td><td>\u00b10.3\u2103<\/td><td>\u00b10.5\u2103<\/td><\/tr><tr><td>\u6e2c\u91cf\u7cbe\u5ea6 (\u6fd5\u5ea6)<\/td><td>\u00b10.3%<\/td><td>\u00b12%<\/td><\/tr><tr><td>\u63a5\u8173\u6578\u91cf<\/td><td>4<\/td><td>3<\/td><\/tr><tr><td>\u50f9\u683c (\u53c3\u8003\u81eaiCShop\u8ca9\u552e\u50f9\u683c)<\/td><td>140\u5143<\/td><td>260\u5143<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/12\/IMG_2593.jpeg\" alt=\"\" class=\"wp-image-21075\" width=\"756\" height=\"756\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u6750\u6599\u6e05\u55ae<\/h3>\n\n\n\n<ul>\n<li>ESP32\u958b\u767c\u677f x1<\/li>\n\n\n\n<li><a href=\"https:\/\/www.icshop.com.tw\/products\/368112100026\" target=\"_blank\" rel=\"noreferrer noopener\">Circus SHT3x \u6eab\u6ebc\u5ea6\u611f\u6e2c\u5668\u6a21\u7d44<\/a> x1<\/li>\n\n\n\n<li>micro USB \u50b3\u8f38\u7dda x1<\/li>\n\n\n\n<li>\u9eb5\u5305\u677f x1<\/li>\n\n\n\n<li>\u675c\u90a6\u7dda\uff08\u516c-\u516c\uff09 x3<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p>\u9023\u63a5\u793a\u610f\u5716<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>SHT3x<\/th><th>ESP32<\/th><\/tr><\/thead><tbody><tr><td>SCL<\/td><td>GPIO 22<\/td><\/tr><tr><td>SDA<\/td><td>GPIO 21<\/td><\/tr><tr><td>VCC<\/td><td>3.3V<\/td><\/tr><tr><td>GND<\/td><td>GND<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"592\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/12\/adj_IMG_2594.jpg\" alt=\"\" class=\"wp-image-21076\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b89\u88dd\u51fd\u5f0f\u5eab<\/h3>\n\n\n\n<p>\u9996\u5148\uff0c\u5230Arduino IDE\u7684Library Manager\u641c\u5c0b\u4e26\u5b89\u88ddAdafruit SHT31\u51fd\u5f0f\u5eab<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/12\/Untitled-9.png\" alt=\"\" class=\"wp-image-21077\" width=\"363\" height=\"447\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u6383\u63cf\u8a2d\u5099\u5730\u5740<\/h3>\n\n\n\n<p>\u6211\u5011\u53ef\u4ee5\u900f\u904e\u524d\u9762\u7684\u7bc4\u4f8b\u7a0b\u5f0f\u78ba\u8a8d\u8a2d\u5099\u5730\u5740\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"457\" height=\"64\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/12\/Untitled-10.png\" alt=\"\" class=\"wp-image-21078\"\/><\/figure>\n\n\n\n<p>\u9019\u7247\u6a21\u7d44\u9810\u8a2d\u7684I2C\u5730\u5740\u662f0x44\u3002\u900f\u904e\u66f4\u6539\u6a21\u7d44\u4e0a\u7684\u710a\u76e4\u9023\u63a5\uff0c\u4e5f\u53ef\u4ee5\u5c07\u5730\u5740\u6539\u62100x45\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc<\/h3>\n\n\n\n<p>\u8907\u88fd\u4e0b\u65b9\u7684\u7a0b\u5f0f\u78bc\u9032\u884c\u6e2c\u8a66<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/FelixLinSY\/2ecfeb35873adf3f12e2e7b6e1d14303.js\"><\/script>\n\n\n\n<h3 class=\"wp-block-heading\">\u7a0b\u5f0f\u78bc\u8aaa\u660e<\/h3>\n\n\n\n<p>\u4e0a\u9762\u7684\u7bc4\u4f8b\u4fee\u6539\u81ea\u51fd\u5f0f\u5eab\u7684\u7bc4\u4f8b\u6e2c\u8a66\u7a0b\u5f0f\u3002<\/p>\n\n\n\n<p>\u4e00\u958b\u59cb\u6211\u5011\u5148\u5efa\u7acb\u4e00\u500b sht3x \u7269\u4ef6\uff0c\u7531\u65bc\u4f7f\u7528\u7684\u662f\u9810\u8a2d\u63a5\u8173\uff0c\u56e0\u6b64<code>Adafruit_SHT31()<\/code>\u4e0d\u9700\u8981\u50b3\u5165\u53c3\u6578\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Adafruit_SHT31 sht3x = Adafruit_SHT31();<\/code><\/pre>\n\n\n\n<p>\u521d\u59cb\u5316\u7269\u4ef6\u6642\uff0c\u4f7f\u7528<code><code><span data-token-index=\"1\" spellcheck=\"false\" class=\"notion-enable-hover\" style=\"font-family:&quot;SFMono-Regular&quot;, Menlo, Consolas, &quot;PT Mono&quot;, &quot;Liberation Mono&quot;, Courier, monospace;line-height:normal;background:rgba(135,131,120,.15);color:#EB5757;border-radius:4px;font-size:85%;padding:0.2em 0.4em\">begin<\/span><\/code><\/code>\uff0c\u4e26\u5c07\u8a2d\u5099\u7684\u5730\u5740\u7576\u4f5c\u53c3\u6578\u50b3\u5165\u51fd\u5f0f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sht3x.begin(0x44);<\/code><\/pre>\n\n\n\n<p>\u5b8c\u6210\u521d\u59cb\u5316\u4ee5\u5f8c\u5c31\u53ef\u4ee5\u7528<code><code><span data-token-index=\"1\" spellcheck=\"false\" class=\"notion-enable-hover\" style=\"font-family:&quot;SFMono-Regular&quot;, Menlo, Consolas, &quot;PT Mono&quot;, &quot;Liberation Mono&quot;, Courier, monospace;line-height:normal;background:rgba(135,131,120,.15);color:#EB5757;border-radius:4px;font-size:85%;padding:0.2em 0.4em\">readTemperature<\/span><\/code><\/code>\u548c<code><code><span data-token-index=\"1\" spellcheck=\"false\" class=\"notion-enable-hover\" style=\"font-family:&quot;SFMono-Regular&quot;, Menlo, Consolas, &quot;PT Mono&quot;, &quot;Liberation Mono&quot;, Courier, monospace;line-height:normal;background:rgba(135,131,120,.15);color:#EB5757;border-radius:4px;font-size:85%;padding:0.2em 0.4em\">readHumidity<\/span><\/code><\/code>\u76f4\u63a5\u8b80\u53d6\u76ee\u524d\u7684\u6eab\u5ea6\u548c\u6fd5\u5ea6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sht3x.readTemperature();  \/\/ \u8b80\u53d6\u76ee\u524d\u6eab\u5ea6\nsht3x.readHumidity();     \/\/ \u8b80\u53d6\u76ee\u524d\u6fd5\u5ea6<\/code><\/pre>\n\n\n\n<p>\u7a0b\u5f0f\u6bcf\u9593\u96941\u79d2\u5c31\u6703\u8b80\u53d6\u6eab\u6ebc\u5ea6\u6578\u503c\uff0c\u4e26\u986f\u793a\u5728\u5e8f\u5217\u57e0\u76e3\u63a7\u8996\u7a97\u3002<\/p>\n\n\n\n<p>SHT3x\u7cfb\u5217\u7684\u611f\u6e2c\u5668\u5167\u90e8\u90fd\u6709\u52a0\u71b1\u5668\u529f\u80fd\uff0c\u7528\u610f\u662f\u63d0\u9ad8\u6fd5\u5ea6\u91cf\u6e2c\u6e96\u78ba\u5ea6\uff0c\u6211\u5011\u53ef\u4ee5\u900f\u904e\u8edf\u9ad4\u63a7\u5236\u52a0\u71b1\u5668\u7684\u958b\u95dc<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sht3x.heater(true);  \/\/ \u958b\u555f\u52a0\u71b1\u5668\nsht3x.heater(false); \/\/ \u95dc\u9589\u52a0\u71b1\u5668<\/code><\/pre>\n\n\n\n<p>\u4e5f\u53ef\u4ee5\u7528<code><code><span data-token-index=\"1\" spellcheck=\"false\" class=\"notion-enable-hover\" style=\"font-family:&quot;SFMono-Regular&quot;, Menlo, Consolas, &quot;PT Mono&quot;, &quot;Liberation Mono&quot;, Courier, monospace;line-height:normal;background:rgba(135,131,120,.15);color:#EB5757;border-radius:4px;font-size:85%;padding:0.2em 0.4em\">reset<\/span><\/code><\/code>\u91cd\u7f6e\u611f\u6e2c\u5668\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sht3x.heater(true);  \/\/ \u958b\u555f\u52a0\u71b1\u5668\nsht3x.heater(false); \/\/ \u95dc\u9589\u52a0\u71b1\u5668<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>\u57f7\u884c\u7d50\u679c<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"680\" height=\"540\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/12\/adj_IMG_2607.gif\" alt=\"\" class=\"wp-image-21079\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7bc4\u4f8b2: \u9a45\u52d51.3\u540bOLED<\/h2>\n\n\n\n<p>\u672c\u7bc4\u4f8b\u4f7f\u7528Circus 1.3\u540bOLED\u87a2\u5e55\u986f\u793a\u6a21\u7d44\uff0c\u5b83\u662f\u4e00\u6b3e\u7531SSD1306\u6676\u7247\u9a45\u52d5\uff0c\u89e3\u6790\u5ea6128 x 64\uff0c\u986f\u793a\u984f\u8272\u70ba\u767d\u8272\uff0c\u4f7f\u7528I2C\u901a\u8a0a\u5354\u8b70\u7684OLED\u87a2\u5e55\u3002<\/p>\n\n\n\n<p>\u9019\u500b\u7bc4\u4f8b\u6703\u793a\u7bc4\u5982\u4f55\u5728\u756b\u9762\u4e2d\u5fc3\u986f\u793acircus pi\u7684\u5716\u7247\uff0c\u4e26\u5728\u87a2\u5e55\u6700\u4e0b\u65b9\u986f\u793a1.3\u201d OLED\u7684\u6587\u5b57\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/12\/IMG_2647.jpeg\" alt=\"\" class=\"wp-image-21080\" width=\"802\" height=\"602\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u6750\u6599\u6e05\u55ae<\/h3>\n\n\n\n<ul>\n<li>ESP32\u958b\u767c\u677f x1<\/li>\n\n\n\n<li>Circus 1.3\u540bOLED\u87a2\u5e55\u986f\u793a\u6a21\u7d44 x1<\/li>\n\n\n\n<li>micro USB \u50b3\u8f38\u7dda x1<\/li>\n\n\n\n<li>\u9eb5\u5305\u677f x1<\/li>\n\n\n\n<li>\u675c\u90a6\u7dda\uff08\u516c-\u516c\uff09 x3<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u9023\u63a5\u793a\u610f\u5716<\/h3>\n\n\n\n<p>\u9023\u63a5\u65b9\u5f0f\u8207\u7bc4\u4f8b1\u76f8\u540c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b89\u88dd\u51fd\u5f0f\u5eab<\/h3>\n\n\n\n<p>\u9996\u5148\uff0c\u5230Arduino IDE\u7684Library Manager\u641c\u5c0b\u4e26\u5b89\u88ddU8g2\u51fd\u5f0f\u5eab<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/12\/u8g2lib.png\" alt=\"\" class=\"wp-image-21081\" width=\"316\" height=\"404\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u5716\u7247\u8f49\u63db<\/h3>\n\n\n\n<p>\u8207\u4e4b\u524d\u4f7f\u7528\u7684\u96fb\u5b50\u7d19\u76f8\u540c\uff0c\u8981\u5728OLED\u4e0a\u986f\u793a\u5716\u6848\u6642\u6211\u5011\u53ef\u4ee5\u7528Image2Lcd\u9019\u500b\u8edf\u9ad4\u628a\u5716\u7247\u8f49\u63db\u6210C\u8a9e\u8a00\u7684\u9663\u5217\u8cc7\u6599<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/12\/Untitled-11.png\" alt=\"\" class=\"wp-image-21082\" width=\"712\" height=\"513\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/12\/Untitled-12.png\" alt=\"\" class=\"wp-image-21083\" width=\"717\" height=\"407\"\/><\/figure>\n\n\n\n<p>\u8f49\u63db\u5b8c\u6210\u5f8c\uff0c\u5c31\u53ef\u4ee5\u5c07\u7522\u751f\u7684\u9663\u5217\u8cbc\u5230\u7a0b\u5f0f\u4e2d\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u7bc4\u4f8b\u7a0b\u5f0f\u78bc<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7a0b\u5f0f\u78bc\u8aaa\u660e<\/h3>\n\n\n\n<p>\u9996\u5148\u532f\u5165Wire\u548cU8g2\u7684\u51fd\u5f0f\u5eab\u3002\u6211\u5011\u4f7f\u7528U8g2\u51fd\u5f0f\u5eab\u4f86\u9a45\u52d5OLED\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;U8g2lib.h&gt;\n#include &lt;Wire.h&gt;<\/code><\/pre>\n\n\n\n<p>\u5b9a\u7fa9\u5716\u7247\u5927\u5c0f\u70ba56&#215;56 pixel<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#define ImgWIDTH 56\n#define ImgHEIGHt 56<\/code><\/pre>\n\n\n\n<p>\u63a5\u8457\u9078\u64c7\u9069\u5408\u7684\u5efa\u69cb\u51fd\u5f0f\u3002U8g2\u9019\u5957\u51fd\u5f0f\u5eab\u80fd\u652f\u63f4\u975e\u5e38\u591a\u7a2e\u985e\u7684\u986f\u793a\u5668\u8207\u578b\u865f\uff0c\u4ee5\u9019\u500b\u6a21\u7d44\u70ba\u4f8b\uff0c\u8981\u9078\u64c7\u7684\u5efa\u69cb\u51fd\u5f0f\u70ba\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, \/* reset=*\/ U8X8_PIN_NONE);<\/code><\/pre>\n\n\n\n<p>\u5728setup()\u51fd\u5f0f\u4e2d\uff0c\u5148\u521d\u59cb\u5316\u87a2\u5e55<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  u8g2.begin();<\/code><\/pre>\n\n\n\n<p>\u7136\u5f8c\u8a2d\u5b9a\u8981\u986f\u793a\u7684\u5b57\u578b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>u8g2.setFont(u8g2_font_luRS08_tr); \/\/ \u8a2d\u5b9a\u5b57\u578b<\/code><\/pre>\n\n\n\n<p>\u53ef\u4ee5\u5230<a href=\"https:\/\/github.com\/olikraus\/u8g2\/wiki\/fntlist8\">\u9019\u88e1<\/a>\u9078\u64c7\u652f\u63f4\u7684\u5b57\u578b\u4ee5\u53ca\u5b57\u9ad4\u5927\u5c0f\u3002\u5728\u9019\u500b\u7bc4\u4f8b\u4e2d\uff0c\u6211\u5011\u4f7f\u7528\u7684\u662f8 pixel\u5927\u5c0f\u7684\u5b57\u578b\u3002<\/p>\n\n\n\n<p>\u4f7f\u7528<code><code><span data-token-index=\"1\" spellcheck=\"false\" class=\"notion-enable-hover\" style=\"font-family:&quot;SFMono-Regular&quot;, Menlo, Consolas, &quot;PT Mono&quot;, &quot;Liberation Mono&quot;, Courier, monospace;line-height:normal;background:rgba(135,131,120,.15);color:#EB5757;border-radius:4px;font-size:85%;padding:0.2em 0.4em\">drawBMP<\/span><\/code><\/code>\u8a2d\u5b9a\u5716\u7247\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>u8g2.drawXBMP(32,0, ImgWIDTH, ImgHEIGHt, circus_logo);  \/\/ \u8a2d\u5b9a\u5716\u7247<\/code><\/pre>\n\n\n\n<p>\u53c3\u6578\u5206\u5225\u70ba\u5716\u7247\u5de6\u4e0a\u89d2\u7684xy\u4f4d\u7f6e\u3001\u5716\u7247\u7684\u5bec\u5ea6\u548c\u9ad8\u5ea6\uff0c\u4ee5\u53ca\u8981\u986f\u793a\u7684\u5716\u7247\u9663\u5217\u3002<\/p>\n\n\n\n<p>\u4f7f\u7528<code><code><code><span data-token-index=\"1\" spellcheck=\"false\" class=\"notion-enable-hover\" style=\"font-family:&quot;SFMono-Regular&quot;, Menlo, Consolas, &quot;PT Mono&quot;, &quot;Liberation Mono&quot;, Courier, monospace;line-height:normal;background:rgba(135,131,120,.15);color:#EB5757;border-radius:4px;font-size:85%;padding:0.2em 0.4em\">drawStr<\/span><\/code><\/code><\/code>\u8a2d\u5b9a\u6587\u5b57\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>u8g2.drawStr(32, 64, \"1.3\\\" OLED\");        \/\/ \u8a2d\u5b9a\u6587\u5b57<\/code><\/pre>\n\n\n\n<p>\u53c3\u6578\u5206\u5225\u70ba\u6587\u5b57\u7684xy\u4f4d\u7f6e\uff0c\u4ee5\u53ca\u8981\u986f\u793a\u7684\u6587\u5b57\u3002\u6ce8\u610fxy\u4f4d\u7f6e\u662f\u5f9e\u6587\u5b57\u7684\u5de6\u4e0b\u65b9\u958b\u59cb\u7b97\u3002<\/p>\n\n\n\n<p>\u6700\u5f8c\u4f7f<code><code><code><span data-token-index=\"1\" spellcheck=\"false\" class=\"notion-enable-hover\" style=\"font-family:&quot;SFMono-Regular&quot;, Menlo, Consolas, &quot;PT Mono&quot;, &quot;Liberation Mono&quot;, Courier, monospace;line-height:normal;background:rgba(135,131,120,.15);color:#EB5757;border-radius:4px;font-size:85%;padding:0.2em 0.4em\">sendBuffer<\/span><\/code><\/code><\/code>\u986f\u793a\u6587\u5b57\u548c\u5716\u7247\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>u8g2.sendBuffer();<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u9032\u968e\u7bc4\u4f8b: \u9023\u63a5\u591a\u500bi2c\u8a2d\u5099<\/h2>\n\n\n\n<p>\u7d93\u904e\u524d\u9762\u76842\u500b\u4f8b\u5b50\uff0c\u6211\u5011\u5df2\u7d93\u77e5\u9053\u8981\u5982\u4f55\u9a45\u52d5\u6eab\u6ebc\u5ea6\u611f\u6e2c\u5668\u8207OLED\u986f\u793a\u6a21\u7d44\u3002\u63a5\u4e0b\u4f86\u6211\u5011\u53ef\u4ee5\u5c07\u5b83\u5011\u9023\u63a5\u5728\u4e00\u8d77\uff0c\u5728OLED\u4e0a\u986f\u793a\u76ee\u524d\u7684\u6eab\u6fd5\u5ea6\u8cc7\u8a0a\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/12\/IMG_2739.jpeg\" alt=\"\" class=\"wp-image-21084\" width=\"867\" height=\"650\"\/><\/figure>\n\n\n\n<p>\u9023\u63a5\u793a\u610f\u5716<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>SHT3x<\/th><th>1.3\u201d OLED<\/th><th>ESP32<\/th><\/tr><\/thead><tbody><tr><td>SCL<\/td><td>SCL<\/td><td>GPIO 22<\/td><\/tr><tr><td>SDA<\/td><td>SDA<\/td><td>GPIO 21<\/td><\/tr><tr><td>VCC<\/td><td>VCC<\/td><td>3.3V<\/td><\/tr><tr><td>GND<\/td><td>GND<\/td><td>GND<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5716\u7247\u8f49\u63db<\/h3>\n\n\n\n<p>\u7bc4\u4f8b\u4e2d\u4f7f\u7528\u7684\u5716\u7247\u662f\u5f9eFlaticon\u9019\u500b\u7db2\u7ad9\u4e0a\u4e0b\u8f09\u7684\uff0c\u5716\u7247\u4f86\u6e90: <a href=\"https:\/\/www.flaticon.com\/free-icon\/humidity_727790?term=humidity&amp;page=1&amp;position=1&amp;origin=search&amp;related_id=727790\" target=\"_blank\" rel=\"noreferrer noopener\">\u6fd5\u5ea6<\/a> <a href=\"https:\/\/www.flaticon.com\/free-icon\/thermometer_1843544?term=temperature&amp;page=1&amp;position=1&amp;origin=search&amp;related_id=1843544\" target=\"_blank\" rel=\"noreferrer noopener\">\u6eab\u5ea6<\/a><\/p>\n\n\n\n<p>\u4e0b\u8f09\u5f8c\u5c07\u5716\u7247\u532f\u5165Image2Lcd\uff0c\u5c07\u5716\u7247\u5927\u5c0f\u8a2d\u70ba28&#215;28\uff0c\u5176\u4ed6\u9078\u9805\u90fd\u8207\u7bc4\u4f8b2\u76f8\u540c\uff0c\u4e0d\u7528\u66f4\u6539\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/12\/Untitled-13.png\" alt=\"\" class=\"wp-image-21085\" width=\"812\" height=\"587\"\/><\/figure>\n\n\n\n<p><p>\u5132\u5b58\u5f8c\uff0c\u6211\u5011\u4e00\u6a23\u5c07\u8f49\u63db\u597d\u7684\u9663\u5217\u653e\u5230\u7a0b\u5f0f\u4e2d\u3002<\/p><h3>\u7bc4\u4f8b\u7a0b\u5f0f\u78bc<\/h3> <\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/FelixLinSY\/9a093aeaedb0dc5bdb5de73f762ef06b.js\"><\/script>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7a0b\u5f0f\u8aaa\u660e<\/h3>\n\n\n\n<p>\u57fa\u672c\u4e0a\u7a0b\u5f0f\u90fd\u8207\u524d\u5169\u500b\u7bc4\u4f8b\u4e00\u6a23\uff0c\u53ea\u662f\u9019\u500b\u7bc4\u4f8b\u7684\u5beb\u6cd5\u6703\u6bd4<code>sendBuffer<\/code>\u9084\u8981\u7bc0\u7701\u8a18\u61b6\u9ad4\u7a7a\u9593\u3002print\u51fd\u5f0f\u7528\u4f86\u986f\u793a\u6578\u5b57\uff0c\u53c3\u6578\u5206\u5225\u662f\u8b8a\u6578\u540d\u7a31\uff0c\u4ee5\u53ca\u5c0f\u6578\u9ede\u4f4d\u6578\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>u8g2.print(t, 2); \/\/ \u986f\u793a\u6eab\u5ea6t \u4ee5\u53ca\u5c0f\u6578\u9ede\u5f8c\u5169\u4f4d\u7684\u6578\u503c\u3002<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>\u57f7\u884c\u7d50\u679c<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"450\" src=\"https:\/\/www.circuspi.com\/wp-content\/uploads\/2023\/12\/adj_IMG_2738.gif\" alt=\"\" class=\"wp-image-21086\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5c0f\u7d50<\/h2>\n\n\n\n<p>\u5728\u9019\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5011\u4ecb\u7d39\u4e86\u5982\u4f55\u4f7f\u7528ESP32\u7684I2C\uff0c\u4ee5\u53ca\u6383\u63cfI2C\u8a2d\u5099\u7684\u65b9\u5f0f\u3002\u4e5f\u5206\u5225\u7528\u5169\u500b\u7bc4\u4f8b\u8aaa\u660e<a href=\"https:\/\/www.icshop.com.tw\/products\/368112100026\" target=\"_blank\" rel=\"noreferrer noopener\">\u6eab\u6ebc\u5ea6\u611f\u6e2c\u5668<\/a>\u4ee5\u53caOLED\u6a21\u7d44\u7684\u4f7f\u7528\u65b9\u5f0f\uff0c\u6700\u5f8c\u8aaa\u660e\u5982\u4f55\u5728\u540c\u4e00\u689dI2C Bus\u4e0a\u4f7f\u7528\u591a\u500bI2C\u8a2d\u5099\u3002<\/p>\n\n\n\n<p>\u4e0b\u4e00\u7bc7\u6211\u5011\u6703\u4f7f\u75281.9\u540b\u7684\u6bb5\u78bc\u96fb\u5b50\u7d19\u87a2\u5e55\u642d\u914d<a href=\"https:\/\/www.icshop.com.tw\/products\/368112100026\" target=\"_blank\" rel=\"noreferrer noopener\">SHT3x<\/a>\u986f\u793a\u6eab\u6ebc\u5ea6\u6578\u503c\uff0c\u6bd4\u8f03\u4e0d\u540c\u7684\u986f\u793a\u65b9\u5f0f\u3002<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 I\u00b2C\u662f\u4e00\u7a2e\u76f8\u7576\u5e38\u898b\u4e14\u6709\u540d\u7684\u50b3\u8f38\u5354\u8b70\uff0c\u5b83\u88ab\u5ee3\u6cdb\u7684\u61c9\u7528\u5728\u5404\u7a2e\u611f\u6e2c\u5668\u7684\u901a\u8a0a\u754c\u9762\u4e0a\u3002\u672c\u6587\u5c07\u8aaa\u660e\u5982\u4f55\u5c07ESP32 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":21238,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[235,238],"tags":[],"table_tags":[],"_links":{"self":[{"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/posts\/21071"}],"collection":[{"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/comments?post=21071"}],"version-history":[{"count":6,"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/posts\/21071\/revisions"}],"predecessor-version":[{"id":21239,"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/posts\/21071\/revisions\/21239"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/media\/21238"}],"wp:attachment":[{"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/media?parent=21071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/categories?post=21071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/tags?post=21071"},{"taxonomy":"table_tags","embeddable":true,"href":"https:\/\/www.circuspi.com\/index.php\/wp-json\/wp\/v2\/table_tags?post=21071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}