MqTT 连接问题 Uno R4 Wifi

MqTT connection issue Uno R4 Wifi

提问人:Ben Naylor 提问时间:11/13/2023 更新时间:11/13/2023 访问量:22

问:

我正在尝试制作一个带有 servon 的 Alexa 控制按钮按下器来启动按钮。我正在使用 Uno R4 Wifi,但遇到此错误:

ArduinoIoTCloudTCP::handle_ConnectMqttBroker无法连接到 mqtts-up.iot.arduino.cc:8884 ArduinoIoTCloudTCP::handle_ConnectMqttBroker 滴答时间 27850 的 1 次连接尝试

这是我的代码:

#include "thingProperties.h"
#include "WiFiS3.h"
#include "Servo.h"
#include "Arduino_WiFiConnectionHandler.h"

char ssid[] = "ASK4 Wireless";

int status = WL_IDLE_STATUS;

WiFiServer server(80);
Servo myservo;

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  delay(1500);
  myservo.attach(7);

  //initProperties();
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();

  while (!Serial) {
    ;  // wait for serial port to connect. Needed for native USB port only
  }

  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true)
      ;
  }

  String fv = WiFi.firmwareVersion();
  if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
    Serial.println("Please upgrade the firmware");
  }

  // attempt to connect to WiFi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid);

    // wait 10 seconds for connection:
    delay(10000);
  }
  server.begin();
  // you're connected now, so print out the status:
  printWifiStatus();
  
  while (ArduinoCloud.connected() == false) {
    ArduinoCloud.update();
    delay(500);
  }
}

void printWifiStatus() {
  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

void loop() {
  // put your main code here, to run repeatedly:
  //Serial.print("Test");
  ArduinoCloud.update();
  delay(2500);
}

void onFanChange()  {
  // Add your code here to act upon ExtractorFan change
  myservo.write(0);
  delay(1000);
  myservo.write(120);
}

这是我多年来的第一个正式项目,因此感谢您的任何建议。

(仅供参考,我住在一栋使用 ASK4 互联网的大楼里。对于此服务,您必须先将设备的 MAC 地址添加到您的帐户中,然后才能连接。我已经通过显示器确认它确实连接到 wifi,但这个错误也出现了。我可以将设备添加到我的 alexa 帐户,但没有任何反应。

TIA系列 :)

我试过浏览网络和各种论坛。没有任何帮助。

WiFi Alexa-Skills-kit Arduino-Uno

评论


答: 暂无答案