![img_0478f2751c4108d8eef16c5f150ee17c.jpe](https://yqfile.alicdn.com/img_0478f2751c4108d8eef16c5f150ee17c.jpeg?x-oss-process=image/resize,w_1400/format,webp)
0.准备
零件 | 数量 |
---|---|
ESP-01 | x1 |
DHT11 | x1 |
128x64 OLED I2C | x1 |
AMS1117-3.3V电源模块 | - |
导线 | - |
万能板 | - |
其他.. | - |
2.写入micropython固件
如果你想修改esp-01flash大小可参考文章:esp8266-01 替换4M Flash(搬运)
固件写入教程可以参考文章:ESP8266 ESP-01 制作路由中继(信号放大装置)
2.焊接
![img_d21ee5518e911cd19d5c5bbf2f2a93fb.png](https://yqfile.alicdn.com/img_d21ee5518e911cd19d5c5bbf2f2a93fb.png?x-oss-process=image/resize,w_1400/format,webp)
电路
![img_7bb2ff0c88d47bb7fceb43288848482d.jpe](https://yqfile.alicdn.com/img_7bb2ff0c88d47bb7fceb43288848482d.jpeg?x-oss-process=image/resize,w_1400/format,webp)
焊接示例
3.程序:
oled驱动使用的库是Adafruit_SSD1306
oled使用相关教程可以参考文章:micropython esp8266+ssd1306(OLED) 显示中文(示例)
代码:
from machine import reset
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
import dht
import time
import sys
import os
i2c = I2C(scl=Pin(0), sda=Pin( 2))
oled = SSD1306_I2C(128, 64, i2c)
d = dht.DHT11(Pin( 2)) # 声明用到类库中的函数,并设置参数
while True:
d.measure() # 调用DHT类库中测量数据的函数
temp_ = str(d.temperature())#读取measure()函数中的温度数据
hum_ = str(d.humidity()) # 读取measure()函数中的湿度数据
'''print('temp:'+ temp_+"C", 0, 0)
print('hum:'+ hum_+"%", 0, 8) '''
oled.fill(0)
oled.text('temp:'+ temp_+"C", 0, 0)
oled.text('hum:'+ hum_+"%", 0, 8)
oled.show()
time.sleep(1)
![img_976dda75b6bf78c84e62cd86bbdaa792.png](https://yqfile.alicdn.com/img_976dda75b6bf78c84e62cd86bbdaa792.png?x-oss-process=image/resize,w_1400/format,webp)
效果示例
大家自由发挥吧!!!
![img_af07566ea6e68af75107fe4855a6dcee.jpe](https://yqfile.alicdn.com/img_af07566ea6e68af75107fe4855a6dcee.jpeg?x-oss-process=image/resize,w_1400/format,webp)