Unable to connect Arduino to IBM internet of things Foundation.

Hi all,

I have registered my Arduino Ethernet in IBM Internet of Things Foundation, but I am unable to connect to IoTF when I am trying to connect it from my office.

IoTF is detecting my Arduino when I am connecting Arduino to internet from my home, even quickstart is working fine.

Arduino is not connecting to IoFT/Quickstart when I am connecting arduino to my office LAN, which uses proxy to connect to internet. Is the proxy causing the problem ?

Both quick start and IoFT dashboard will be waiting for my device to connect, whenever I connect Arduino to office LAN.

I do not know why my Arduino is not recognized by IoFT when I am connecting arduino to my office LAN, though I am using same code.

Someone please help me to resolve the issue. I am beginner in Arduino, so please elaborate.

Thanks and Regards

If it works at home but not in the office this does not sound like a programming problem. Networking, Protocols, and Devices - I2C, SPI, XBee, GPS, etc. would seem to be a more appropriate place to ask about networking problems

Hi,

When I am trying to connect to Google using the Webclient sample code, that comes along with Arduino IDE, I am getting output that I have attached. Please let me know whether it is the expected output.

The output should be something like

connecting...
connected
HTTP/1.1 302 Found
Location: http://www.google.co.uk/search?q=arduino&gws_rd=cr&ei=s6DUVI7iNsOuaduJgIgL
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Set-Cookie: PREF=ID=06e7350782248d8f:FF=0:TM=1423220915:LM=1423220915:S=M5tA5yV6BAJ1xaZ8; expires=Sun, 05-Feb-2017 11:08:35 GMT; path=/; domain=.google.com
Set-Cookie: NID=67=nsAdtRRly0NZ-mjtogHV7Tt7P3V0Xa25eozEk7AFbRYYzF2K4lfK6tnCTtMDCm3cefCu9GsnV-6j-VZhxrugSuFo_hSbMsV2oEnT29SvXtns4INihEP8heEKZWjnn7IE; expires=Sat, 08-Aug-2015 11:08:35 GMT; path=/; domain=.google.com; HttpOnly
P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
Date: Fri, 06 Feb 2015 11:08:35 GMT
Server: gws
Content-Length: 279
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Alternate-Protocol: 80:quic,p=0.02
Connection: close

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.co.uk/search?q=arduino&amp;gws_rd=cr&amp;ei=s6DUVI7iNsOuaduJgIgL">here</A>.
</BODY></HTML>

disconnecting.

If you are using a domain name for the server as in the WebClient example (www.google.com), and the dns server (or the dns server IP in your Ethernet.begin call is not a dns server) was unable to resolve the domain, that would be the correct response.

Your client.connect call is not evaluating the return value correctly. The only success return value is 1. If you evaluate for true/false as in the example, a negative return value would evaluate to true, even though all negative return values are a fail. So...

// change this
  if(client.connect(server,80)) {
// to this
  if(client.connect(server,80) == 1) {

http://arduino.cc/en/Reference/ClientConnect And besides the return values listed there, the return value could also be one of these: 0 = unable to connect to the server's IP -5 = domain not found.

HI SuferTim,

Now,after changing the code, it is showing connection failed. Kindly let me know how to establish the connection.

Thanks and Regards

You are probably having trouble with your DNS server. It appears it is not resolving the domain name.

Try to connect using this.

int rtnVal = client.connect(server,80);

if(rtnVal == 1) {
  Serial.println(F("connected"));
} 
else {
  Serial.print(F("failed error "));
  Serial.println(rtnVal);
}

What error number does it display?

Simple client test code you can try unmodified to see if you can make a connection with the server.

//zoomkat 3-1-13
//simple client checkip test
//for use with IDE 1.0.1 or later
//with DNS, DHCP, and Host
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address

char serverName[] = "checkip.dyndns.com"; // test web page server
EthernetClient client;

//////////////////////

void setup(){

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }

  Serial.begin(9600); 
  Serial.println("Better client ip test 3/1/13"); // so I can keep track of what is loaded
  Serial.println("Send an e in serial monitor to test"); // what to do to test
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    if(inChar == 'e') // checks to see byte is an e
    {
      sendGET(); // call sendGET function below when byte is an e
    }
  }  
} 

//////////////////////////

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET / HTTP/1.0"); //download text
    client.println("Host: checkip.dyndns.com");
    client.println(); //end of get request
  } 
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor 
  }

  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop(); //stop client

}