{"id":835,"date":"2020-09-08T23:09:08","date_gmt":"2020-09-08T15:09:08","guid":{"rendered":"https:\/\/www.iotch.xyz\/?p=835"},"modified":"2020-09-08T23:09:08","modified_gmt":"2020-09-08T15:09:08","slug":"%e5%9c%a8%e6%a0%91%e8%8e%93%e6%b4%be%e4%b8%8a%e4%bd%bf%e7%94%a8-ssd1306-oled-%e5%b1%8f%e5%b9%95","status":"publish","type":"post","link":"https:\/\/www.iotch.xyz\/?p=835","title":{"rendered":"\u5728\u6811\u8393\u6d3e\u4e0a\u4f7f\u7528 SSD1306 OLED \u5c4f\u5e55"},"content":{"rendered":"\n<p>\u6811\u8393\u6d3e\u5728\u8bb8\u591a\u4f7f\u7528\u573a\u666f\u4e0b\u5e76\u4e0d\u9700\u8981\u63a5\u4e00\u53f0\u4e13\u7528\u663e\u793a\u5668\uff0c\u5982\u9700\u8981\u67e5\u770b\u6811\u8393\u6d3e\u4e0a\u7684\u4e00\u4e9b\u4fe1\u606f\u53ef\u4ee5\u901a\u8fc7\u624b\u673a\u3001\u7535\u8111\u767b\u5f55\u5230\u6811\u8393\u6d3e\u4e0a\u64cd\u4f5c\uff0c\u4f46\u603b\u5f52\u4e0d\u591f\u4fbf\u5229\u3002<br>\u4e0b\u9762\u4ecb\u7ecd\u4e24\u6b3e OLED \u5c0f\u5c4f\uff08\u5747\u4e3a SSD1306 \u82af\u7247\u9a71\u52a8\uff09\u53ef\u4ee5\u76f4\u63a5\u63d2\u5230\u6811\u8393\u6d3e GPIO \u4e0a\uff0c\u914d\u6709 Python \u6e90\u7801\u8ba9\u6811\u8393\u6d3e\u73a9\u5bb6\u53ef\u4ee5\u8f7b\u677e\u7528\u5b83\u6765\u663e\u793a\u4efb\u4f55\u56fe\u6587\u6216\u52a8\u753b\u5185\u5bb9\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190428230045555.jpg\" alt=\"\"\/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190428230045927.jpg\" alt=\"\"\/><\/figure><\/div>\n\n\n\n<p><strong>1\u3001Pi OLED 128\u00d732 OLED \u5c4f\u5e55\u6269\u5c55\uff08I2C\uff09<\/strong><br><br>Pi OLED \u914d\u5907 0.9 \u82f1\u5bf8\u8ff7\u4f60\u5355\u8272\u5c4f\uff0c128\u00d732 \u5206\u8fa8\u7387\uff0c\u767d\u5149\u50cf\u7d20\u70b9\u3002\u62e5\u6709\u6781\u9ad8\u7684\u5bf9\u6bd4\u5ea6\uff0c\u663e\u793a\u6e05\u6670\u6781\u6613\u8fa8\u8bc6\u3002OLED \u4ec5\u4f7f\u7528\u6811\u8393\u6d3e\u7684 I2C \u548c\u7535\u6e90\u5f15\u811a\uff0c\u65e0\u9700\u72ec\u7acb\u4f9b\u7535\uff0c\u5373\u63d2\u5373\u7528\u3002\uff08<a href=\"https:\/\/shumeipai.nxez.com\/pi-oled-128x32-i2c\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >\u67e5\u770b\u8be6\u60c5<\/a>\uff0c<a href=\"http:\/\/link.nxez.com\/rpi\/cps-products-pi-oled-128x32-i2c\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >\u8d2d\u4e70\u94fe\u63a5<\/a>\uff09<br><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190429223128797.jpg\" alt=\"\" class=\"wp-image-5800\"\/><\/figure><\/div>\n\n\n\n<p><strong>2\u3001\u201c\u590d\u53e4\u5c0f\u7535\u89c6\u201d OLED \u5c4f<\/strong><br><br>\u5e26\u6709 3D \u6253\u5370\u5916\u58f3\u7684 OLED \u5c0f\u5c4f\uff0c\u5206\u8fa8\u7387 128\u00d764\u3002\u901a\u8fc7 I2C \u8fde\u63a5\u5230\u6811\u8393\u6d3e\uff0c\u65e0\u9700\u72ec\u7acb\u4f9b\u7535\u3002\uff08<a href=\"http:\/\/link.nxez.com\/quwj\/products-timor-tv\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >\u8d2d\u4e70\u94fe\u63a5<\/a>\uff09<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e00\u3001\u542f\u7528\u6811\u8393\u6d3e\u7684I2C\u529f\u80fd<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>123<\/td><td><code>sudo<\/code> <code>apt-get <\/code><code>install<\/code> <code>-y python-smbus<\/code><code>sudo<\/code> <code>apt-get <\/code><code>install<\/code> <code>-y i2c-tools<\/code><code>sudo<\/code> <code>raspi-config<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190429203718829-0.png\" alt=\"\" class=\"wp-image-5783\"\/><\/figure><\/div>\n\n\n\n<p>\u6309\u7167\u4e0b\u9762\u7684\u6b65\u9aa4\u8bbe\u7f6e\u5f00\u542f I2C \u529f\u80fd\u3002<br><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190429203719366-0.png\" alt=\"\" class=\"wp-image-5784\"\/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190429203720724-0.png\" alt=\"\" class=\"wp-image-5785\"\/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190429203722164-0.png\" alt=\"\" class=\"wp-image-5780\"\/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190429203723525-0.png\" alt=\"\" class=\"wp-image-5787\"\/><\/figure><\/div>\n\n\n\n<p>\u91cd\u542f\u6811\u8393\u6d3e\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<\/td><td><code>sudo<\/code> <code>reboot<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e8c\u3001\u5b89\u88c5 Adafruit-SSD1306 \u5e93<\/h3>\n\n\n\n<p>Adafruit-SSD1306 \u662f\u57fa\u4e8e Python \u7684 OLED \u5e93\uff0c\u53ef\u4ee5\u7528\u4e8e 128\u00d764\u3001128\u00d732 \u50cf\u7d20 SSD1306 \u82af\u7247\u63a7\u5236\u7684\u5c4f\u5e55\u3002<br>\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u5b89\u88c5\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<\/td><td><code>sudo<\/code> <code>python -m pip <\/code><code>install<\/code> <code>--upgrade pip setuptools wheel<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190429203710274-0.png\" alt=\"\" class=\"wp-image-5792\"\/><\/figure><\/div>\n\n\n\n<p>\u6ce8\u610f\uff0c\u5982\u679c\u8fd9\u4e00\u6b65\u51fa\u73b0\u9519\u8bef\u63d0\u793a\u201cTypeError: unsupported operand type(s) for -=: \u2018Retry\u2019 and \u2018int\u2019\u201d\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u5378\u8f7d\u540e\u91cd\u65b0\u5b89\u88c5 pip \u6765\u89e3\u51b3\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190429203714285-0.png\" alt=\"\" class=\"wp-image-5788\"\/><\/figure><\/div>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>12<\/td><td><code>sudo<\/code> <code>apt-get remove python-pip python3-pip<\/code><code>sudo<\/code> <code>apt-get <\/code><code>install<\/code> <code>python-pip python3-pip<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u5b89\u88c5 PIL \u5e93\uff0c\u6709\u4e00\u4e9b\u56fe\u7247\u5904\u7406\u7684\u7a0b\u5e8f\u4f1a\u7528\u5230\u8fd9\u4e2a\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<\/td><td><code>sudo<\/code> <code>apt-get <\/code><code>install<\/code> <code>python-pil python3-pil<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u4f7f\u7528 pip \u5b89\u88c5 Adafruit-SSD1306 \u5e93\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<\/td><td><code>sudo<\/code> <code>pip <\/code><code>install<\/code> <code>Adafruit-SSD1306<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190429203716937-0.png\" alt=\"\" class=\"wp-image-5782\"\/><\/figure><\/div>\n\n\n\n<p>\u518d\u4e0b\u8f7d\u4e00\u4efd\u5305\u542b\u4ee3\u7801\u793a\u4f8b\u7684\u5e93\u540e\u9762\u8981\u7528\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>12<\/td><td><code>cd<\/code> <code>~<\/code><code>git clone https:<\/code><code>\/\/github<\/code><code>.com<\/code><code>\/adafruit\/Adafruit_Python_SSD1306<\/code><code>.git<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190429203726764-0.png\" alt=\"\" class=\"wp-image-5793\"\/><\/figure><\/div>\n\n\n\n<p>\u8fd9\u91cc\u987a\u4fbf\u63d0\u4e00\u4e0b\uff0c\u5982\u679c\u4e0a\u9762\u7684 pip \u5b89\u88c5 Adafruit-SSD1306 \u5e93\u9047\u5230\u7f51\u7edc\u95ee\u9898\uff0c\u90a3\u4e48\u4e5f\u53ef\u4ee5\u5728\u4e0b\u8f7d\u5b8c\u8fd9\u4efd\u4ee3\u7801\u4e4b\u540e\u8fd0\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u5b89\u88c5\uff08\u53ef\u9009\uff09\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>12<\/td><td><code>cd<\/code> <code>Adafruit_Python_SSD1306<\/code><code>sudo<\/code> <code>python setup.py <\/code><code>install<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u8fdb\u5230\u793a\u4f8b\u76ee\u5f55\uff0c\u53ef\u4ee5\u770b\u5230\u6709\u4e00\u4e9b\u5df2\u7ecf\u51c6\u5907\u597d\u4e86\u7684\u4ee3\u7801\uff0c\u540e\u9762\u5c06\u5c4f\u5e55\u63a5\u597d\u4e4b\u540e\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c\u770b\u6548\u679c\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<\/td><td><code>cd<\/code> <code>~<\/code><code>\/Adafruit_Python_SSD1306\/examples\/<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190429203729769-0.png\" alt=\"\" class=\"wp-image-5789\"\/><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e09\u3001\u8fde\u63a5\u5c4f\u5e55<\/h3>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190428230045743.jpg\" alt=\"\" class=\"wp-image-5771\"\/><\/figure><\/div>\n\n\n\n<p>\u5bf9\u4e8e Pi OLED \u5c4f\u5e55\u6269\u5c55\uff0c\u76f4\u63a5\u5b89\u63d2\u5728 GPIO \u5982\u56fe\u6240\u793a\u4f4d\u7f6e\uff08\u7269\u7406\u5f15\u811a\u7f16\u53f71-6\u53f7\uff09\u3002<br><br>\u5bf9\u4e8e\u201c\u5c0f\u7535\u89c6\u201d\u5c4f\u5e55\uff0c\u6839\u636e\u5c4f\u5e55 PCB \u4e0a\u5f15\u811a\u7684\u529f\u80fd\u6807\u6ce8\u63a5\u5230\u6811\u8393\u6d3e\u4e0a\u5bf9\u5e94\u7684 GPIO \u4e0a\u5373\u53ef\u3002<br>\u5c4f\u5e55 GND \u63a5\u6811\u8393\u6d3e GND<br>\u5c4f\u5e55 VCC \u63a5\u6811\u8393\u6d3e 3V3<br>\u5c4f\u5e55 SDA \u63a5\u6811\u8393\u6d3e SDA<br>\u5c4f\u5e55 SCL \u63a5\u6811\u8393\u6d3e SCL<br>\u6ce8\u610f\u4e00\u5b9a\u4e0d\u8981\u63a5\u53cd VCC \u548c GND\uff0c\u5426\u5219\u4f1a\u70e7\u574f\u5c4f\u5e55\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u901a\u8fc7\u547d\u4ee4\u68c0\u6d4b\u662f\u5426\u8bc6\u522b\u5230 I2C \u8bbe\u5907\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<\/td><td><code>sudo<\/code> <code>i2cdetect -y 1<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190429203724813-0.png\" alt=\"\" class=\"wp-image-5786\"\/><\/figure><\/div>\n\n\n\n<p>\u5c06\u663e\u793a\u5df2\u8fde\u63a5\u8bbe\u5907\u7684 I2C \u5730\u5740\uff0c\u4e0d\u540c\u7684\u5c4f\u5e55\u5730\u5740\u53ef\u80fd\u4f1a\u4e0d\u4e00\u6837\uff0c\u901a\u8fc7\u8fd9\u4e2a\u6b65\u9aa4\u53ef\u4ee5\u786e\u8ba4\u4e00\u4e0b\u3002<br>\u6ce8\u610f\uff0c\u5982\u679c\u4f60\u6b63\u5728\u4f7f\u7528\u7684\u662f\u521d\u4ee3\u6811\u8393\u6d3e\uff08256MB\u7684\u6811\u8393\u6d3e1\u4ee3B\uff09\uff0c\u90a3\u4e48\u9700\u8981\u7528\u8fd9\u4e2a\u547d\u4ee4\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<\/td><td><code>sudo<\/code> <code>i2cdetect -y 0<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u56db\u3001\u7f16\u7a0b\u548c\u8fd0\u884c<\/h3>\n\n\n\n<p>\u4e3a\u4e86\u5feb\u901f\u4e0a\u624b\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u793a\u4f8b\u4ee3\u7801\u3002\u5176\u4e2d\u6709\u4e00\u4e2a\u6587\u4ef6\u540d\u4e3a stats.py \u7684\u7a0b\u5e8f\uff0c\u7528\u6765\u663e\u793a\u6811\u8393\u6d3e\u7684 IP\u3001CPU Load\u3001\u5185\u5b58\u548c\u78c1\u76d8\u4f7f\u7528\u60c5\u51b5\u3002\u5148\u62ff\u8fd9\u4e2a\u6765\u8bd5\u8bd5\u770b\u3002<br>\u5c06\u4e4b\u524d\u4e0b\u8f7d\u7684\u6e90\u7801\u590d\u5236\u5230\u7528\u6237\u76ee\u5f55\uff0c\u7528\u7f16\u8f91\u5668\u6253\u5f00\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>123<\/td><td><code>cd<\/code> <code>~<\/code><code>sudo<\/code> <code>cp<\/code> <code>~<\/code><code>\/Adafruit_Python_SSD1306\/examples\/stats<\/code><code>.py ~\/<\/code><code>sudo<\/code> <code>nano stats.py<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190429203728928-0.png\" alt=\"\" class=\"wp-image-5781\"\/><\/figure><\/div>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\u8fd9\u4efd\u793a\u4f8b\u5df2\u7ecf\u5305\u542b\u4e86\u591a\u79cd\u5c4f\u5e55\u53c2\u6570\u7684\u521d\u59cb\u5316\u65b9\u6cd5\u3002<br><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>12345678<\/td><td><code># 128x32 display with hardware I2C:<\/code><code>disp <\/code><code>=<\/code> <code>Adafruit_SSD1306.SSD1306_128_32(rst<\/code><code>=<\/code><code>RST)<\/code>&nbsp;<code># 128x64 display with hardware I2C:<\/code><code># disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST)<\/code>&nbsp;<code># Note you can change the I2C address by passing an i2c_address parameter like:<\/code><code># disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, i2c_address=0x3C)<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u6240\u7528\u7684\u5c4f\u5e55\u6765\u4fee\u6539\u8fd9\u4e9b\u53c2\u6570\uff0c\u4f8b\u5982 SSD1306_128_32 \u4ee3\u8868 128\u00d732 \u5206\u8fa8\u7387\u5c4f\u5e55\u7684\u521d\u59cb\u5316\u65b9\u6cd5\uff0c\u9002\u7528\u4e8e\u672c\u7bc7\u4ecb\u7ecd\u7684 Pi OLED 128\u00d732 OLED \u5c4f\u5e55\u6269\u5c55\uff0cSSD1306_128_64 \u9002\u7528\u4e8e\u201c\u590d\u53e4\u5c0f\u7535\u89c6\u201d OLED \u5c4f\u3002i2c_address \u7528\u4e8e\u914d\u7f6e\u5c4f\u5e55\u7684\u5730\u5740\uff0c\u9ed8\u8ba4\u4e3a 0x3C\u3002<\/p>\n\n\n\n<p>\u8fd0\u884c\u793a\u4f8b\u4ee3\u7801\uff0c\u53ef\u770b\u5230\u8fd0\u884c\u6548\u679c\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<\/td><td><code>sudo<\/code> <code>python stats.py<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190428230045555.jpg\" alt=\"\"\/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190429203738204.jpg\" alt=\"\" class=\"wp-image-5796\"\/><\/figure><\/div>\n\n\n\n<p>\u540c\u6837\u7684\u65b9\u6cd5\u518d\u8bd5\u8bd5 image.py \u8fd9\u4e2a\u793a\u4f8b\u6548\u679c\u5982\u4e0b\u3002<br><br>\u901a\u8fc7\u4fee\u6539 image.py \u4e2d\u7684\u521d\u59cb\u5316\u53c2\u6570\uff0c\u8c03\u6574\u4e3a 128\u00d764 \u5206\u8fa8\u7387\u4e4b\u540e\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<\/td><td><code>disp <\/code><code>=<\/code> <code>Adafruit_SSD1306.SSD1306_128_64(rst<\/code><code>=<\/code><code>RST)<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190429203731901-0.png\" alt=\"\" class=\"wp-image-5791\"\/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190429203740315.jpg\" alt=\"\" class=\"wp-image-5795\"\/><\/figure><\/div>\n\n\n\n<p>\u5c4f\u5e55\u4e0a\u7684\u56fe\u7247\u3001\u5f62\u72b6\u3001\u6587\u672c\u548c\u5b57\u4f53\u90fd\u662f\u7531 PIL\uff08Python Imaging Library\uff09\u7684\u6a21\u5757 Image, ImageDraw, and ImageFont \u6765\u5b9e\u73b0\u7684\u3002\u5982\u6709\u5174\u8da3\u53ef\u4ee5\u8bd5\u8bd5\u5176\u4ed6\u4ee3\u7801\u793a\u4f8b\uff0c\u5e76\u5b66\u4e60\u81ea\u5df1\u8bbe\u8ba1\u56fe\u6587\u6765\u663e\u793a\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e94\u3001\u8bbe\u7f6e\u5f00\u673a\u8fd0\u884c<\/h3>\n\n\n\n<p>\u4e3a\u4e86\u8ba9 stats.py \u80fd\u591f\u5f00\u673a\u81ea\u52a8\u8fd0\u884c\uff0c\u6211\u4eec\u53ef\u4ee5\u505a\u4e0b\u9762\u7684\u914d\u7f6e\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u4e0d\u7528\u901a\u8fc7\u5de5\u5177\u6216\u8def\u7531\u5668\u53bb\u67e5\u627e\u6811\u8393\u6d3e\u7684 IP \u5730\u5740\u7b49\u4fe1\u606f\u4e86\u3002<br>\u4fee\u6539 \/etc\/rc.local&nbsp;\u6587\u4ef6\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<\/td><td><code>sudo<\/code> <code>nano <\/code><code>\/etc\/rc<\/code><code>.<\/code><code>local<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u5728 exit 0 \u524d\u9762\u589e\u52a0\u4e00\u884c\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<\/td><td><code>sudo<\/code> <code>python <\/code><code>\/home\/pi\/stats<\/code><code>.py &amp;<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/shumeipai.nxez.com\/wp-content\/uploads\/2019\/04\/20190429203733433-0.png\" alt=\"\" class=\"wp-image-5790\"\/><\/figure><\/div>\n\n\n\n<p><br>\u7f16\u8f91\u597d\u4e4b\u540e\u6309\u4e0b Ctrl+O \u4fdd\u5b58\uff0c\u518d\u6309\u4e0b Ctrl+X \u9000\u51fa\u3002\u91cd\u542f\u6811\u8393\u6d3e\u9a8c\u8bc1\u4e00\u4e0b\u662f\u5426\u751f\u6548\u5427\uff01<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<\/td><td><code>sudo<\/code> <code>reboot<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u516d\u3001\u63d0\u9ad8\u663e\u793a\u901f\u7387\uff08\u53ef\u9009\uff0c\u4e0d\u63a8\u8350\uff09<\/h3>\n\n\n\n<p>\u4e3a\u4e86\u66f4\u597d\u7684\u663e\u793a\u6027\u80fd\uff0c\u4f8b\u5982\u663e\u793a\u52a8\u753b\u65f6\u5982\u5bf9\u5e27\u7387\u6709\u8981\u6c42\uff0c\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u4e0b\u9762\u7684\u53c2\u6570\u5c06 I2C \u9891\u7387\u4ece\u9ed8\u8ba4\u7684 100KHz \u6216 400KHz \u63d0\u5347\u5230 1MHz\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>1<\/td><td><code>sudo<\/code> <code>nano <\/code><code>\/boot\/config<\/code><code>.txt<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u5728\u6587\u4ef6\u672b\u6dfb\u52a0\u4e00\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dtparam=i2c_baudrate=1000000<\/pre>\n\n\n\n<p>\u539f\u6587\u8fde\u63a5\uff1a<a href=\"https:\/\/shumeipai.nxez.com\/2019\/04\/29\/use-the-ssd1306-oled-display-on-the-raspberry-pi.html\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >https:\/\/shumeipai.nxez.com\/2019\/04\/29\/use-the-ssd1306-oled-display-on-the-raspberry-pi.html<\/a><\/p>\n<button class=\"simplefavorite-button\" data-postid=\"835\" data-siteid=\"1\" data-groupid=\"1\" data-favoritecount=\"0\" style=\"\">\u6536\u85cf <i class=\"sf-icon-star-empty\"><\/i><\/button>","protected":false},"excerpt":{"rendered":"<p>\u6811\u8393\u6d3e\u5728\u8bb8\u591a\u4f7f\u7528\u573a\u666f\u4e0b\u5e76\u4e0d\u9700\u8981\u63a5\u4e00\u53f0\u4e13\u7528\u663e\u793a\u5668\uff0c\u5982\u9700\u8981\u67e5\u770b\u6811\u8393\u6d3e\u4e0a\u7684\u4e00\u4e9b\u4fe1\u606f\u53ef\u4ee5\u901a\u8fc7\u624b\u673a\u3001\u7535\u8111\u767b\u5f55\u5230\u6811\u8393\u6d3e\u4e0a\u64cd\u4f5c\uff0c\u4f46\u603b\u5f52\u4e0d\u591f\u4fbf\u5229\u3002 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-835","post","type-post","status-publish","format-standard","hentry","category-10"],"_links":{"self":[{"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=\/wp\/v2\/posts\/835","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=835"}],"version-history":[{"count":0,"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=\/wp\/v2\/posts\/835\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}