0

I have been spending some time on this but have had no luck, it should be something simple...

I want to connect to the Watson platform and send an event (some text) from an MKR1000 Arduino.

I have fallen at the first hurdle as it is not connecting to the cloud.

The info they have online is pretty good and has kept me in reading for a day or 2 now!

If I could get a second pair of eyes it would be great.

The wifi connection itself is ok as I ran it on a different code to confirm it was ok. Also, I am receiving a "?" to the serial monitor so assume that it is the cloud connection and not the wifi.

void connect() {
    Serial.print("checking wifi...");
    while (WiFi.status() != WL_CONNECTED) {
        Serial.print("!");
        delay(1000);
    }

    Serial.print("\nconnecting...");
    while (!client.connect("d:slqo8v:Arduino:Sender01","use-token-auth","<as 
    on the hub>")) {
        Serial.print("?");
        delay(1000);
    }

    Serial.println("\nconnected!");
}

I have reduced the security settings on the cloud to TLS optional. I have triple checked the login details.

The majority of the code is as below, I loath to post it all up as it says not to paste entire code but I don't think my experience is enough that this is not something trivial like a misplaced bracket.

The example I have been shown is like

client.connect("clientID", "username", "password")
IBM Bluemix 
clientID = "d:<slqo8v>:<Arduino>:<Sender01>"
username is aways: "use-token-auth"
password is: Token auth provided by Bluemix
Example:
client.connect("d:iqwckl:arduino:oxigenarbpm","use-token-auth","90wT2?a*1WAMVJStb1")    

I have reproduced as this..

    Serial.print("\nconnecting...");
    while (!client.connect("d:slqo8v:Arduino:Sender01","use-token- 
    auth","as provided online")) {
        Serial.print("?");
        delay(1000);
    }
    Serial.println("\nconnected!");
}

void setup() {
    Serial.begin(9800);
    WiFi.begin("", "");

    client.begin("slqo8v.messaging.internetofthings.ibmcloud.com", 1883, net);

    connect();
}


void loop() {
    client.loop();

    if (!client.connected()) {
        connect();
    }
}

I have switched the code around also but haven't come up with anything workable.

Any help much appreciated.

Thanks!

Wang Liang
  • 4,244
  • 6
  • 22
  • 45
Tam
  • 105
  • 10

1 Answers1

0

Looking at the server side I can see that the lastest errors are due to a space in the client id resulting in an not authorized error. The clientid being used is d: slqo8v:Arduino:Sender01 Note the space before the slqo8v.

I can't see that space in your code example so maybe it is special character from a copy and paste? or the code has changed since this post?

whitfiea
  • 1,943
  • 10
  • 15