Unable to connect Argon to IBM Watson through MQTT

I am new to Particle devices and I’m facing a problem to connect the Argon to IBM Watson IOT platform. I am using MQTT.h library to connect to IBM Watson. When i verify the code it displays “Code verfied. Great work” and when i flash the code it displays in Particle IDE “Flash successful. updating device firmware” and then Argon blinks magenta, then green and after a few seconds it starts breathing cyan. After it keeps breathing cyan, I cannot see my Argon connected to IBM cloud.
I am not sure whether the issue is with the code or MQTT library. I also tried using MQTT-TLS library to check if it works with my code but i get errors when i verify the code.
The code is given below. Please help me out

// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_DHT.h>

// This #include statement was automatically added by the Particle IDE.
#include <OneWire.h>

// This #include statement was automatically added by the Particle IDE.
#include <MQTT.h>



#include "DS18.h"
#include "MQTT.h"
#include "Adafruit_DHT.h"


#define DHTPIN 2     // what pin we're connected to
#define DHTTYPE DHT11    // DHT 11

char *IOT_CLIENT = "d:ts200f:Argon:WebVisions";
char *IOT_HOST = "ts200f.messaging.internetofthings.ibmcloud.com";
char *IOT_PASSWORD = "_device_token_here_";
char *IOT_PUBLISH = "iot-2/evt/sensor_data/fmt/json";
char *IOT_USERNAME = "use-token-auth";

// MQTT callback
void callback(char* topic, byte* payload, unsigned int length);    

DS18 sensor(5);
// MQTT client
MQTT client(IOT_HOST, 1883 , callback);
DHT dht(DHTPIN, DHTTYPE);

char* string2char(String command){
    if(command.length()!=0){
        char *p = const_cast<char*>(command.c_str());
        return p;
    }
}

// recieve message
void callback(char* topic, byte* payload, unsigned int length) {
    delay(1000);
}


void setup() {
    dht.begin();
    delay(5000);

    // connect to the server
   
  client.connect( IOT_CLIENT, IOT_USERNAME,  IOT_PASSWORD );

    // publish/subscribe
    if (client.isConnected()) {
        client.publish(IOT_PUBLISH,"hello world");
        //client.subscribe("inTopic/message");
    }
}

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.