Go Down

Topic: Sketch to MQTT Broker (Read 225 times) previous topic - next topic

serweryn

Hello,

I can connect to my MQTT Broker from Yun ssh console but my sketch can't connect.

My sketch:
#include <SPI.h>
#include <YunClient.h>
#include <PubSubClient.h>

// Update these with values suitable for your network.
byte server[] = { 192, 168, 1, 128 };

void callback(char* topic, byte* payload, unsigned int length) {
// handle message arrived
}

YunClient yun;
PubSubClient mqtt(server, 1883, callback, yun);

void setup()
{
Bridge.begin();
if (mqtt.connect("arduinoClient")) {
mqtt.publish("outTopic","hello world");
mqtt.subscribe("inTopic");
}
}

void loop()
{
mqtt.loop();
}

I would like to use Yun in OpenHab

Regards,
Sew

Go Up