Hello everyone,
I am trying to combine thinger.io and a mqtt-library arduino-mqtt for my new project.
I already used thinger with some neopixel and a custom android-app.
My problem: I need to initialize the mqtt client with the following command:
void begin(const char hostname[], int port, Client &client);
In my code I start the Wifi with thing.add_wifi(SSID, SSID_PASSWORD); and I don’t know how to access the Client from ThingerESP8266 so that mqtt can use the wifi connection.
The MQTT-Example uses WiFi101.h with
#include <WiFi101.h>
#include <MQTT.h>
const char ssid[] = "ssid";
const char pass[] = "pass";
WiFiClient net;
MQTTClient client;
void connect() {
client.subscribe("/hello");
// client.unsubscribe("/hello");
}
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, pass);
// You need to set the IP address directly.
client.begin("broker.shiftr.io", net);
client.onMessage(messageReceived);
connect();
}
void loop() {
client.loop();
if (!client.connected()) {
connect() }
}
Thanks for helping!
Kind regards