本帖最后由 血洗无涯 于 2017-9-14 19:31 编辑
不知道怎么回事,图片上传不了。
参考帖:http://www.geek-workshop.com/thread-28380-1-1.html
[kenrobot_code]#include <U8glib.h>
#include <dht11.h>
dht11 DHT11;
#define DHT11PIN 2
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);
char str[0];
void setup()
{
Serial.begin(115200);
}
void loop() {
DHT11.read(DHT11PIN);
float h = DHT11.humidity;
float t = DHT11.temperature;
u8g.firstPage(); //OLED左上角为0,0 ;字符定位为 左下角 firstPage标志图像循环开始
do {
u8g.setFont(u8g_font_helvB18);
u8g.drawStr( 0, 63, "H="); //显示 H=
u8g.drawStr( 40, 63, dtostrf(h, 5, 2, str));
u8g.drawStr( 105, 63, "%"); //显示 %
u8g.drawStr( 0, 32, "T="); //显示 T=
u8g.drawStr( 37, 32, dtostrf(t, 5, 2, str));
u8g.drawStr( 100, 32, "\260C"); //显示 度C
} while( u8g.nextPage() );//nextPage标志图像循环结束
delay(500); //repeat
}
[/kenrobot_code] |