各位帮帮忙,看看哪里岀错?谢谢大家!!!!!-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 2409|回复: 3

[未解决] 各位帮帮忙,看看哪里岀错?谢谢大家!!!!!

[复制链接]
发表于 2021-2-6 01:29 | 显示全部楼层 |阅读模式
本帖最后由 wei8784 于 2021-2-7 02:37 编辑

/* *****************************************************************
*
* Download latest Blinker library here:
* https://github.com/blinker-iot/blinker-library/archive/master.zip
*
*
* Blinker is a cross-hardware, cross-platform solution for the IoT.
* It provides APP, device and server support,
* and uses public cloud services for data transmission and storage.
* It can be used in smart home, data monitoring and other fields
* to help users build Internet of Things projects better and faster.
*
* Make sure installed 2.7.2 or later ESP8266/Arduino package,
* if use ESP8266 with Blinker.
* https://github.com/esp8266/Arduino/releases
*
* Make sure installed 1.0.4 or later ESP32/Arduino package,
* if use ESP32 with Blinker.
* https://github.com/espressif/arduino-esp32/releases
*
* Docs: https://diandeng.tech/doc
*       https://github.com/blinker-iot/blinker-doc/wiki
*
* *****************************************************************
*
* Blinker 库下载地址:
* https://github.com/blinker-iot/blinker-library/archive/master.zip
*
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
*
* 如果使用 ESP8266 接入 Blinker,
* 请确保安装了 2.7.2 或更新的 ESP8266/Arduino 支持包。
* https://github.com/esp8266/Arduino/releases
*
* 如果使用 ESP32 接入 Blinker,
* 请确保安装了 1.0.4 或更新的 ESP32/Arduino 支持包。
* https://github.com/espressif/arduino-esp32/releases
*
* 文档: https://diandeng.tech/doc
*       https://github.com/blinker-iot/blinker-doc/wiki
*
* *****************************************************************/

#define BLINKER_WIFI
#define BLINKER_MIOT_SENSOR

#include <Blinker.h>

char auth[] = "436faf";
char ssid[] = "12346";
char pswd[] = "1369000i";

BlinkerNumber HUMI("humi");
BlinkerNumber TEMP("temp");
BlinkerNumber ADC("BatteryVolt");//kong是blinker手机APP中数据键名(可自己选定)

int V;
int Val;

// Download Adafruit DHT-sensor-library library here:
// https://github.com/adafruit/DHT-sensor-library

#include <DHT.h>

#define DHTPIN   D4

#define DHTTYPE DHT11   // DHT 11
//#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

DHT dht(DHTPIN, DHTTYPE);

uint32_t read_time = 0;

float humi_read, temp_read, volt_read;


void dataRead(const String & data)
{
    BLINKER_LOG("Blinker readString: ", data);

    Blinker.vibrate();

    uint32_t BlinkerTime = millis();

    Blinker.print("millis", BlinkerTime);
}

void heartbeat()
{
    HUMI.print(humi_read);
    TEMP.print(temp_read);
    ADC.print(volt_read);
}

void setup()
{
    Serial.begin(115200);
    BLINKER_DEBUG.stream(Serial);

    pinMode(LED_BUILTIN, OUTPUT);
    digitalWrite(LED_BUILTIN, LOW);

    Blinker.begin(auth, ssid, pswd);
    Blinker.attachData(dataRead);
    Blinker.attachHeartbeat(heartbeat);

    dht.begin();
}

void loop()
{
    Blinker.run();

    if (read_time == 0 || (millis() - read_time) >= 2000)
    {
        read_time = millis();

        float h = dht.readHumidity();
        float t = dht.readTemperature();        

        if (isnan(h) || isnan(t)) {
            BLINKER_LOG("Failed to read from DHT sensor!");
            return;
        }

        V = analogRead(A0);//读取ADC
        Val = V * 5000 / 1023 ;//换算为mV

        float hic = dht.computeHeatIndex(t, h, false);

        humi_read = h;
        temp_read = t;
        volt_read = Val;

        BLINKER_LOG("Humidity: ", h, " %");
        BLINKER_LOG("Temperature: ", t, " *C");
        BLINKER_LOG("Heat index: ", hic, " *C");
        BLINKER_LOG("Battery Volt: ", volt_read, " mV");
    }
}


用网上这个https://github.com/Listenc/DHT11withBlink刷光光合未来-知悉N1

Arduino:1.8.13 (Windows 8.1), 开发板:"Generic ESP8266 Module, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), dtr (aka nodemcu), 26 MHz, 40MHz, DIO, 1MB (FS:64KB OTA:~470KB), 2, nonos-sdk 2.2.1+100 (190703), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

DHT:68:18: error: 'D4' was not declared in this scopeF:\新建文件夹\DHT11withBlink-master\DHT11withBlink-master\DHT\DHT.ino:74:9: note: in expansion of macro 'DHTPIN'exit status 1'D4' was not declared in this scope
发表于 2021-2-6 03:48 | 显示全部楼层
'D4' was not declared in this scope
发表于 2021-2-6 13:23 | 显示全部楼层
不传你的源代码,看个啥
发表于 2021-2-13 21:15 来自手机 | 显示全部楼层
不要用 generic esp8266 model,改用 nodemcu 0.9
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-29 12:46 , Processed in 0.083000 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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