ESP32 + Arduino IDE 开发的 MQTT 通信程序
安装库
测试
ledoff ledon
代码
// ESP32 arduino IDE的编写MQTT代码
#include <WiFi.h>
#include <PubSubClient.h> // 需要安装PubSubClient库// WiFi配置
const char* ssid = "Redmi K70";//WiFi名修改
const char* password = "12345678a";//wifi密码修改#define LED_BUILTIN 3// MQTT配置
const char* mqtt_server = "broker.hivemq.com"; // 公共MQTT服务器,可替换为你自己的
const int mqtt_port = 188