ESP32 version that could work
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
#include <ESP8266WiFi.h>
|
|
||||||
#include "TinyMqtt.h" // https://github.com/hsaturn/TinyMqtt
|
#include "TinyMqtt.h" // https://github.com/hsaturn/TinyMqtt
|
||||||
|
|
||||||
/** Simple Client
|
/** Simple Client
|
||||||
*
|
*
|
||||||
* This is the simplest Mqtt client configuration
|
* This is the simplest Mqtt client configuration
|
||||||
*
|
*
|
||||||
|
* 1 - edit my_credentials.h to setup wifi essid/password
|
||||||
|
* 2 - change BROKER values (or keep emqx.io test broker)
|
||||||
|
*
|
||||||
* pro - small memory footprint (both ram and flash)
|
* pro - small memory footprint (both ram and flash)
|
||||||
* - very simple to setup and use
|
* - very simple to setup and use
|
||||||
*
|
*
|
||||||
@@ -13,6 +15,9 @@
|
|||||||
* - local publishes takes more time (because they go outside)
|
* - local publishes takes more time (because they go outside)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const char* BROKER = "broker.emqx.io";
|
||||||
|
const uint16_t BROKER_PORT = 1883;
|
||||||
|
|
||||||
#include <my_credentials.h>
|
#include <my_credentials.h>
|
||||||
|
|
||||||
static float temp=19;
|
static float temp=19;
|
||||||
@@ -32,8 +37,7 @@ void setup()
|
|||||||
|
|
||||||
Serial << "Connected to " << ssid << "IP address: " << WiFi.localIP() << endl;
|
Serial << "Connected to " << ssid << "IP address: " << WiFi.localIP() << endl;
|
||||||
|
|
||||||
client.connect("192.168.1.40", 1883); // Put here your broker ip / port
|
client.connect(BROKER, BROKER_PORT); // Put here your broker ip / port
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <ESP8266WiFi.h>
|
#ifdef ESP8266
|
||||||
#include <ESPAsyncTCP.h>
|
#include <ESPAsyncTCP.h>
|
||||||
|
#elif defined(ESP32)
|
||||||
|
#include <WiFi.h>
|
||||||
|
#include <AsyncTCP.h> // https://github.com/me-no-dev/AsyncTCP
|
||||||
|
#endif
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|||||||
Reference in New Issue
Block a user