查看: 251|回复: 6

[已解答] 远程开机,编译时出错,求大神看看

[复制链接]

该用户从未签到

发表于 2021-6-5 15:09 | 显示全部楼层 |阅读模式
本帖最后由 youdongkiang 于 2021-6-5 15:11 编辑


错误

错误






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

D:\程序\_______\_______.ino: In function 'void miotPowerState(const String&)':

_______:21:12: error: 'D2' was not declared in this scope

D:\程序\_______\_______.ino:30:18: note: in expansion of macro 'PW'

_______:35:5: error: 'BlinkerAliGenie' was not declared in this scope

_______:21:12: error: 'D2' was not declared in this scope

D:\程序\_______\_______.ino:41:18: note: in expansion of macro 'PW'

_______:46:5: error: 'BlinkerAliGenie' was not declared in this scope

D:\程序\_______\_______.ino: In function 'void miotQuery(int32_t)':

_______:22:12: error: 'D5' was not declared in this scope

D:\程序\_______\_______.ino:58:19: note: in expansion of macro 'PM'

_______:59:5: error: 'BlinkerAliGenie' was not declared in this scope

_______:63:5: error: 'BlinkerAliGenie' was not declared in this scope

_______:66:3: error: 'BlinkerAliGenie' was not declared in this scope

D:\程序\_______\_______.ino: In function 'void button1_callback(const String&)':

_______:21:12: error: 'D2' was not declared in this scope

D:\程序\_______\_______.ino:85:16: note: in expansion of macro 'PW'

D:\程序\_______\_______.ino: In function 'void heartbeat()':

_______:22:12: error: 'D5' was not declared in this scope

D:\程序\_______\_______.ino:91:19: note: in expansion of macro 'PM'

D:\程序\_______\_______.ino: In function 'void setup()':

_______:22:12: error: 'D5' was not declared in this scope

D:\程序\_______\_______.ino:104:11: note: in expansion of macro 'PM'

_______:21:12: error: 'D2' was not declared in this scope

D:\程序\_______\_______.ino:110:11: note: in expansion of macro 'PW'

D:\程序\_______\_______.ino: In function 'void loop()':

_______:22:12: error: 'D5' was not declared in this scope

D:\程序\_______\_______.ino:126:23: note: in expansion of macro 'PM'

exit status 1
'D2' was not declared in this scope

在文件 -> 首选项开启
“编译过程中显示详细输出”选项
这份报告会包含更多信息。


大神们怎么解决啊,在线等
#define BLINKER_PRINT Serial
#define BLINKER_WIFI
#define BLINKER_MIOT_OUTLET   //小爱同学


#include <Blinker.h>


char auth[] = "ea47b142001c";
char ssid[] = "TP-LINK_776E";
char pswd[] = "123456789";
BlinkerButton Button1("btn-abc");     //定义按钮数据键值
BlinkerText Text1("TextKey");        //文件显示键值


bool oState = false;


bool power;
bool lastpower;


int counter = 0;
String pState;  //存储检测到的电源状态


#define PW D2    //继电器控制管脚
#define PM D5    //电源检测管脚




void miotPowerState(const String & state)
{
  BLINKER_LOG("need set power state: ", state);


  if (state == BLINKER_CMD_ON) {
    digitalWrite(PW, HIGH);
    delay(200);
    digitalWrite(PW, LOW);
    Serial.println("开了");


    BlinkerAliGenie.powerState("on");
    BlinkerAliGenie.print();


    oState = true;
  }
  else if (state == BLINKER_CMD_OFF) {
    digitalWrite(PW, HIGH);
    delay(200);
    digitalWrite(PW, LOW);
    Serial.println("关了");


    BlinkerAliGenie.powerState("off");
    BlinkerAliGenie.print();


    oState = false;
  }
}




void miotQuery(int32_t queryCode)
{
  BLINKER_LOG("AliGenie Query codes: ", queryCode);


  if (digitalRead(PM) == true) {
    BlinkerAliGenie.powerState("on");
    BlinkerAliGenie.powerState("on");
  }
  else {
    BlinkerAliGenie.powerState("off");
    BlinkerAliGenie.powerState("off");
  }
  BlinkerAliGenie.print();


}


void dataRead(const String & data)      // 如果未绑定的组件被触发,则会执行其中内容
{
  BLINKER_LOG("Blinker readString: ", data);


  Blinker.vibrate();


  uint32_t BlinkerTime = millis();


  Blinker.print("millis", BlinkerTime);


}


void button1_callback(const String & state)     //点灯app内控制按键触发
{
  BLINKER_LOG("get button state: ", state);
  digitalWrite(PW, HIGH);
  delay(200);
  digitalWrite(PW, LOW);
}


void heartbeat() {
  if (digitalRead(PM) == true) {
    pState = "开机";
  }
  else {
    pState = "关机";
  }


  Text1.print(pState, "电源状态反馈");
  Serial.println("心跳反馈");
}


void setup()
{
  pinMode(PM, INPUT);
  Serial.begin(115200);
#if defined(BLINKER_PRINT)
  BLINKER_DEBUG.stream(BLINKER_PRINT);
#endif


  pinMode(PW, OUTPUT);              //定义io口为输出
  digitalWrite(PW, LOW);           //定义io默认为高电平


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


  BlinkerMIOT.attachPowerState(miotPowerState);
  BlinkerMIOT.attachQuery(miotQuery);
  Button1.attach(button1_callback);
  Blinker.attachHeartbeat(heartbeat);


}


void loop()
{
  Blinker.run();
  power = digitalRead(PM);
  if (power != lastpower) {
    if (digitalRead(PM) == true) {
      pState = "开机";
    }
    else {
      pState = "关机";
    }
    Text1.print(pState, "电源状态反馈");
    Serial.println("反馈");
  }
  lastpower = power;



}


签到天数: 86 天

[LV.6]常住居民II

发表于 2021-6-5 18:09 | 显示全部楼层
检查一下  ESP8266 引脚编号  显示 D2 D3 有问题

签到天数: 4 天

[LV.2]偶尔看看I

发表于 2021-6-5 21:14 | 显示全部楼层
开发版选择 NodeMCU1.0  ESP12E

签到天数: 1 天

[LV.1]初来乍到

发表于 2021-6-6 00:28 | 显示全部楼层
IDE中选择您实际使用的开发板,或者将D2改成实际使用的GPIO编号

签到天数: 116 天

[LV.6]常住居民II

发表于 2021-6-6 00:34 | 显示全部楼层
#define PW 2    //继电器控制管脚
#define PM 5    //电源检测管脚

签到天数: 1 天

[LV.1]初来乍到

发表于 2021-6-8 11:47 | 显示全部楼层
感觉像是说D2定义有问题吧。该成数字引脚编号或者   char xxx = 'D2';   应该可以解决
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

热门推荐

【Arduino】108种传感器模块系列实验(52)---Micro SD卡读写模块
【Arduino】108种传感器模
37款传感器与模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是
DIY炫彩灯带,竟如此简单,更有硬件开发工具免费领!
DIY炫彩灯带,竟如此简单
什么是涂鸦Arduino SDK? Arduino 是全球最流行的开源硬件平台,涂鸦官方推出的 Ardui
步进电机播放音乐
步进电机播放音乐
硬件:使用arduino uno板子与步进电机驱动器TB6600实物图 因为我这里用的是方波,才
esp32控制ws2812灯条会有闪烁
esp32控制ws2812灯条会有
把亮度调为0后第一个灯会一直亮其余一些会闪烁,把亮度调高以后就不会闪烁。之前用esp
想在原有的项目上加上一个呼吸灯怎么做才不影响原程序
想在原有的项目上加上一个
如题,想在原来的程序上加上一个呼吸灯,但是程序中的delay会影响到程序的其他部分,
Copyright   ©2015-2016  Arduino中文社区  Powered by©Discuz!   
快速回复 返回顶部 返回列表