|
在網(wǎng)上找了很久,都沒有找到有關(guān)的資料。就自己改了程序庫(kù)文件什么的都在壓縮包了
#include <Arduino.h>
#include <U8g2lib.h>
#include <dht11.h>
dht11 DHT11;
#define DHT11PIN D6 //可改接口,這是我D1開發(fā)板的
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ D3, /* data=*/ D4, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C
void setup(void) {
Serial.begin(9600);
u8g2.begin();
u8g2.enableUTF8Print(); // enable UTF8 support for the Arduino print() function
}
void loop(void) {
int chk = DHT11.read(DHT11PIN);
Serial.print("Humidity (%): ");
Serial.println((float)DHT11.humidity, 2);
Serial.print("Temperature (oC): ");
Serial.println((float)DHT11.temperature, 2);
delay(2000);
u8g2.setFont(u8g2_font_unifont_t_chinese2); // use chinese2 for all the glyphs of "你好世界"
u8g2.setFontDirection(0);
u8g2.clearBuffer();
u8g2.setCursor(0, 15);
u8g2.print("Humidity (%):");
u8g2.setCursor(0, 28);
u8g2.print((float)DHT11.humidity, 2);
u8g2.setCursor(0, 40);
u8g2.print("Temperature (oC): "); // Chinese "Hello World"
u8g2.setCursor(0, 60);
u8g2.print((float)DHT11.temperature, 2); // Chinese "Hello World"
u8g2.sendBuffer();
delay(1000);
}
原理圖: 無(wú)
仿真: 無(wú)
代碼:
代碼.7z
(3.04 MB, 下載次數(shù): 46)
2024-1-17 15:16 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
評(píng)分
-
查看全部評(píng)分
|