极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9545|回复: 4

温湿度程序编译出错

[复制链接]
发表于 2015-4-1 12:11:30 | 显示全部楼层 |阅读模式
/*
OpenJumper Examples
DHT11 Moudle
www.openjumper.com
*/
#include <dht11.h>

dht11 DHT11;

#define DHT11PIN 2

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  Serial.println("\n");
  // 读取传感器数据
  int chk = DHT11.read(DHT11PIN);
  Serial.print("Read sensor: ");
  // 检测数据是否正常接收
  switch (chk)
  {
    case DHTLIB_OK:
                Serial.println("OK");
                break;
    case DHTLIB_ERROR_CHECHSUM:
                Serial.println("Checksum error");
                break;
    case DHTLIB_ERROR_TIMEOUT:
                Serial.println("Time out error");
                break;
    default:
                Serial.println("Unknown error");
                break;
  }
  // 输出湿度与温度信息
Serial.print("Humidity (%): ");
  Serial.println(DHT11.humidity);
  Serial.print("Temperature (oC): ");
  Serial.println(DHT11.temperature);

  delay(1000);
}
编译报错:
Arduino: 1.6.1 (Windows 7), Board: "Arduino Uno"

temperature_and_Humidity_check1.ino: In function 'void loop()':

temperature_and_Humidity_check1.ino:29:10: error: 'DHTLIB_ERROR_CHECHSUM' was not declared in this scope

Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
这是我按《arduino 程序设计基础第二版》的案例敲进去的,卟知道怎么改,能帮看看吗?
回复

使用道具 举报

发表于 2015-4-1 12:47:19 | 显示全部楼层
呃 建议你先用 1.0.5 的编译器

1.6 太新了,一些库有兼容问题
回复 支持 反对

使用道具 举报

发表于 2015-4-1 14:23:54 | 显示全部楼层
本帖最后由 Super169 于 2015-4-1 16:24 编辑

應該不是版本的問題, 看似是某些常數輸入錯誤了.  CHECHSUM <- 明顯是串錯字了.
回复 支持 反对

使用道具 举报

发表于 2015-4-1 21:43:18 | 显示全部楼层
DHTLIB_ERROR_CHECHSUM' was not declared
先定义
回复 支持 反对

使用道具 举报

 楼主| 发表于 2015-4-2 16:24:49 | 显示全部楼层
以解决,谢谢各位的指点,果然是串字错了,“CHECHSUM”应该是"CHECKSUM"
回复 支持 反对

使用道具 举报

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

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-25 09:30 , Processed in 0.040006 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

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