本帖最后由 凤凰de星空 于 2020-4-10 20:56 编辑
之前写一个小度灯的代码,现在想改成湿度传感器,blinker app没问题,但是小度app还是同步为原来的灯设备,重新同步还不是传感器,这是什么情况?
论坛扩展里面的 Markdown 有问题,没有识别
[mw_shl_code=arduino,true]#define BLINKER_WIFI
#define BLINKER_DUEROS_SENSOR
#include <Blinker.h>
const char auth[] = "";
const char ssid[] = "";
const char pswd[] = "";
int humi_read = 0;
bool oState = false;
BlinkerNumber HUMI("humi");
BlinkerButton Button1("btn"); // 按钮
void duerQuery(int32_t queryCode)
{
BLINKER_LOG("DuerOS Query humi");
BlinkerDuerOS.time(millis());
BlinkerDuerOS.humi(humi_read);
BlinkerDuerOS.print();
}
void heartbeat()
{
HUMI.print(humi_read);
}
void button1_callback(const String & state)
{
HUMI.print(humi_read);
}
void setup() {
Serial.begin(115200);
pinMode(A0, INPUT);
BLINKER_DEBUG.stream(Serial);
BLINKER_DEBUG.debugAll();
Blinker.begin(auth, ssid, pswd);
Blinker.attachHeartbeat(heartbeat);
Button1.attach(button1_callback);
BlinkerDuerOS.attachQuery(duerQuery);
}
void loop() {
Blinker.run();
int h = analogRead(A0);
if (isnan(h))
{
BLINKER_LOG("Failed to read from DHT sensor!");
}
else
{
BLINKER_LOG("Humidity: ", h, " %");
humi_read = h;
}
Blinker.delay(2000);
}[/mw_shl_code]
|