本帖最后由 MrBattery 于 2019-4-15 13:34 编辑
手机:苹果7,系统:IOS10.3.3
Blinker版本:2.1.5
蓝牙模块:jdy-08
开发板:mega2560
照着例程把wifi改成了蓝牙,但是么得反应
详细介绍帖子:学习记录2,Blinker读取温湿度
https://www.arduino.cn/forum.php?mod=viewthread&tid=85510&fromuid=174941
(出处: Arduino中文社区)
[mw_shl_code=arduino,true]
#define BLINKER_BLE
#include <Blinker.h>
#include <DHT.h>
BlinkerNumber HUMI("humi");
BlinkerNumber TEMP("temp");
#define DHTPIN 7
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
float humi_read = 0, temp_read = 0;
void heartbeat()
{
HUMI.print(humi_read);
TEMP.print(temp_read);
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
BLINKER_DEBUG.debugAll();
Blinker.attachHeartbeat(heartbeat);
dht.begin();
Blinker.begin(2,3,115200);
}
void loop()
{
Blinker.run();
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t))
{
BLINKER_LOG("Failed to readfrom DHT sensor!");
}
else
{
BLINKER_LOG("Humidity: ", h, " %");
BLINKER_LOG("Temperature: ", t, " ℃");
humi_read = h;
temp_read = t;
}
Blinker.delay(2000);
}[/mw_shl_code]
但是加上按键强制返回就有了
[mw_shl_code=arduino,true]void refresh_callback(const String & state){
BLINKER_LOG("get button state: ", state);
if(state=="tap"){
HUMI.print(DHT.humidity);
TEMP.print(sensors.getTempCByIndex(0));
TEXT.print("点击刷新");
Blinker.delay(500);
}[/mw_shl_code]
(上面的代码是另外一个程序里的,头文件不太一样,问题不大)
(答辩录的视频,原谅下渣画质。。。)
现在基本就是这么个情况。。。靠按键返回不用心跳包就ok,直接心跳包就没反应
|