# Unable to connect Argon to IBM Watson through MQTT

**URL:** <https://community.particle.io/t/unable-to-connect-argon-to-ibm-watson-through-mqtt/57668>\
**Category:** Libraries\
**Tags:** argon\
**Created:** [September 7, 2020, 7:47am UTC](https://community.particle.io/t/unable-to-connect-argon-to-ibm-watson-through-mqtt/57668 "2020-09-07T07:47:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amna1](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@Amna1](https://community.particle.io/u/Amna1)\
**Post date:** [September 7, 2020, 7:47am UTC](https://community.particle.io/t/unable-to-connect-argon-to-ibm-watson-through-mqtt/57668/1 "2020-09-07T07:47:14Z")

</div>

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

```auto
// 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");
    }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/3/2/3291e3c9351789fe8620ae5bcec8d3fec67ff221.png) [@system](https://community.particle.io/u/system)\
**Post date:** [November 6, 2020, 7:47am UTC](https://community.particle.io/t/unable-to-connect-argon-to-ibm-watson-through-mqtt/57668/2 "2020-11-06T07:47:15Z")

</div>

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