|
为什么binker存储数据 代码编译错误
这是报错:class BlinkerESPMQTT' has no member named 'attachDataStorage
这是代码:
#define BLINKER_WIFI
#define BLINKER_ALIGENIE_SENSOR
#include <Blinker.h>
#include <modules/dht/DHT.h>
char auth[] = "de1d2652e54c";
char ssid[] = "smp";
char pswd[] = "12345679";
BlinkerNumber HUMI("humi");
BlinkerNumber TEMP("temp");
BlinkerNumber SMS ("SMS");
#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);
float humi_read = 0, temp_read = 0,SMS_read;
void heartbeat()
{
SMS.print(SMS_read);
HUMI.print(humi_read);
TEMP.print(temp_read);
}
void dataStorage()
{
Blinker.dataStorage("temp", temp_read);
Blinker.dataStorage("humi", humi_read);
Blinker.dataStorage("SMS", SMS_read);
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
BLINKER_DEBUG.debugAll();
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
Blinker.begin(auth, ssid, pswd);
Blinker.attachHeartbeat(heartbeat);
Blinker.attachDataStorage(dataStorage);
dht.begin();
}
void loop()
{
Blinker.run();
float SMS =analogRead(0);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t))
{
BLINKER_LOG("Failed to read from DHT sensor!");
}
else
{
BLINKER_LOG("soil moisture",SMS,"%");
BLINKER_LOG("Humidity: ", h, " %");
BLINKER_LOG("Temperature: ", t, " *C");
humi_read = h;
temp_read = t;
SMS_read=SMS;
}
Blinker.delay(2000);
} |
-
|