CC3000 - Send GET request to an app on heroku I'm struggling to get the CC3000 to connect to a heroku hosted app, and other examples posted online haven't turned on the light bulb quite yet for me. 

The gist is that I collect some temperature and humidity readings, and then send those via a GET request using the CC3000. The heroku app then reads the parameters and displays them on a page. 

The CC3000 hardware is A-OK, as I've tested it using the test sketches. The sketch I've put together (on github: https://github.com/jsimms/compost_monitor) works except for the last bit where it needs to connect to the server and send the HTTP request. Which makes me wonder if this is a heroku quirk, or if I'm just screwing something up right at the finish line. 

First, I define everything 

#define WEBSITE      "myapp.herokuapp.com"
String route = "/sensor";
uint32_t ip;
int port = 80; 


Then during setup, I use getHostByName to assign the ip variable. I print it out, just to confirm it was able to snag an ip. I then close it to make sure I don't screw up anything during the loop. 

  ip = 0;
  Serial.print(WEBSITE); Serial.print(F(" -&gt; "));
  while (ip == 0) {
    if (! cc3000.getHostByName(WEBSITE, &amp;ip)) {
      Serial.println(F("Couldn't resolve!"));
    }
    delay(500);
  }

  cc3000.printIPdotsRev(ip);
  Serial.println("");

  // Close the connection
  Serial.println(F("Closing connection..."));
  cc3000.disconnect();
  Serial.println(F("Connection closed."));


During the loop, I create a String with the request, and then call a function that actually does the request. 

String request = "GET " + route + "?temp=" + temperature + "&amp;hum=" + humidity + " HTTP/1.0\r\n";
send_request(request);


Finally, the send_request function is supposed to take care of connecting via TCP and sending it.

void send_request (String request)
{
  // Connect to server 
  Serial.println("Connecting to server...");
  Adafruit_CC3000_Client www = cc3000.connectTCP(ip, port); 

  // Send the request 
  if (www.connected()) {
      www.println(request);
      www.println(F("User-agent: CompostMonitor/1.0\r\n"));      
      www.println(F("\r\n"));
      Serial.println("Connected &amp; data sent successfully...");
    } 
    else {
      Serial.println(F("Connection failed."));    
    }

    while (www.connected()) {
      while (www.available()) {

      // Read answer
      char c = www.read();
      Serial.println(c); 
      }
    }

  // Disconnect 
  Serial.println("Closing connection...");
  Serial.println(""); 
  www.close(); 
}


However, I never get anything but connection failed. 

Any insight and help would be wonderfully appreciated. :)

UPDATE: Ok. So, through the comments below, I was able to identify by telnet'ing the web app, that there was something wrong with the HTTP requests. I made a small tweak to the app, but the real issue was that I wasn't including Host: weathervane.herokuapp.com in the header. FML! I'm going to test out sending the request with the Arduino later tonight. Hopefully that puts an end to this HTTP 101 lesson I've been doing.
Have a look at this code:  https://github.com/adafruit/Adafruit_CC3000_Library/blob/master/examples/SendTweet/SendTweet.ino

There is a delay after cc3000.connectTCP to wait for connection. Your code does not wait for the connection and thus gives 'connection failed' straight away.

Serial.print(F("OK\r\nConnecting to server..."));
t = millis();
do {
    client = cc3000.connectTCP(ip, 80);
} while((!client.connected()) &amp;&amp;
    ((millis() - t) &lt; connectTimeout));

if(client.connected()) { // Success!

etc


Edit based on comment:

getHostByName returns positive value on success and negative on failure. Therefore the check should be

if (cc3000.getHostByName(WEBSITE, &amp;ip) &lt; 0)


Also try putting http:// in the website address