20 lines
485 B
Arduino
20 lines
485 B
Arduino
|
|
#include <Arduino.h>
|
||
|
|
#include <PicoMQTT.h>
|
||
|
|
|
||
|
|
PicoMQTT::Server mqtt;
|
||
|
|
|
||
|
|
void setup() {
|
||
|
|
// Usual setup
|
||
|
|
Serial.begin(115200);
|
||
|
|
WiFi.mode(WIFI_STA);
|
||
|
|
WiFi.begin("wifiname", "password");
|
||
|
|
while (WiFi.status() != WL_CONNECTED) { delay(1000); }
|
||
|
|
Serial.printf("WiFi connected, IP: %s\n", WiFi.localIP().toString().c_str());
|
||
|
|
mqtt.begin();
|
||
|
|
}
|
||
|
|
|
||
|
|
void loop() {
|
||
|
|
// This will automatically handle client connections. By default, all clients are accepted.
|
||
|
|
mqtt.loop();
|
||
|
|
}
|