SEN0539-EN DF2301Q How to send announcements.?
How can I send an announcement such as Fixed Command # 103 “Turn on the light”.?
When I use DF2301Q.playByCMDID(103);delay(300); -nothing happens.
An Error will occur with asr.playByCMDID(103); for me because ’asr' was not declared in this scope
You may not have noticed used DF2301Q instead of asr and I did declare as follows:
DFRobot_DF2301Q_UART DF2301Q(/*hardSerial =*/&Serial1, /*rx =*/3, /*tx =*/1);
When I use
DF2301Q.playByCMDID(103);
nothing happens, or if I use 104
gyrolenPls try the code.
#include "DFRobot_DF2301Q.h"
#define Led 8
#if (defined(ARDUINO_AVR_UNO) || defined(ESP8266)) // 使用软串口SoftwareSerial softSerial(/*rx =*/4, /*tx =*/5);DFRobot_DF2301Q_UART asr(/*softSerial =*/&softSerial);#elif defined(ESP32) // 使用 可重映射引脚的 硬串口 : Serial1DFRobot_DF2301Q_UART asr(/*hardSerial =*/&Serial1, /*rx =*/D3, /*tx =*/D2);#else // 使用硬串口 : Serial1DFRobot_DF2301Q_UART asr(/*hardSerial =*/&Serial1);#endif
void setup() { Serial.begin(115200);
pinMode(Led, OUTPUT); //初始化LED引脚为输出模式 digitalWrite(Led, LOW); //LED引脚低电平
while (!(asr.begin())) { Serial.println("Communication with device failed, please check connection"); delay(3000); } Serial.println("Begin ok!");
asr.settingCMD(DF2301Q_UART_MSG_CMD_SET_MUTE, 0); asr.settingCMD(DF2301Q_UART_MSG_CMD_SET_VOLUME, 7); asr.settingCMD(DF2301Q_UART_MSG_CMD_SET_WAKE_TIME, 20); asr.playByCMDID(103);
Serial.println("play done!");}
void loop() {
}
jenna