找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3962|回复: 2
打印 上一主题 下一主题
收起左侧

arduino oled+dht11显示

[复制链接]
跳转到指定楼层
楼主
ID:232530 发表于 2017-12-23 12:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
在网上找了很久,都没有找到有关的资料。就自己改了程序库文件什么的都在压缩包了
#include <Arduino.h>
#include <U8g2lib.h>
#include <dht11.h>
dht11 DHT11;
#define DHT11PIN D6  //可改接口,这是我D1开发板的
#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);  
}  

原理图: 无
仿真: 无
代码: 代码.7z (3.04 MB, 下载次数: 41)

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:1109487 发表于 2024-1-17 13:18 | 只看该作者
request for member 'read' in 'DHT11', which is of non-class type 'const uint8_t' {aka 'const unsigned char'}
回复

使用道具 举报

板凳
ID:1109487 发表于 2024-1-17 13:19 | 只看该作者
request for member 'read' in 'DHT11', which is of non-class type 'const uint8_t' {aka 'const unsigned char'}什么原因吖
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表