I have an Arduino Mega 2560 with a cc3000 Wifi shield that is sending messages to dweet.io. Here is the relevant portion of my code:

// Post data to dweetio
    char data[125];
    sprintf(data, "?t1=%i&t2=%i&t3=%i&t4=%i&t5=%i&t6=%i&t7=%i&t8=%i&t9=%i&t10=%i&t11=%i&t12=%i&t13=%i&p=%i", 
    Adafruit_CC3000_Client client = cc3000.connectTCP(dweetioIp, 80);
    if (client.connected()) {
      client.fastrprint(F("GET "));
      client.fastrprint(F(" HTTP/1.1\r\n"));
      client.fastrprint(F("Host: https://www.dweet.io\r\n"));
      // client.println();
      // Serial.println(F("Sent dweet\n"));
    } else {
      Serial.println(F("Sending dweet failed"));

/* Read data until either the connection is closed, or the idle timeout is reached. */ 
long lastRead = millis();
while (client.connected() && (millis() - lastRead < 1000)) {
  while (client.available()) {
    char c = client.read();
    lastRead = millis();

// Serial.println("Connection to dweet.io closed");

In addition to this code, the loop does about two seconds of data collection and setting outputs.

This works most of the time when I connect to a typical wireless router. However, I want to deploy it away from my wifi source so I got a T-Mobile hotspot. When I use the identical code with the hotspot, it only successfully sends the message about one out of ten tries (sporadically though, not on even intervals).

The code doesn't report any errors. Anyone have any suggestions on how to debug this?

  • Have you been able to verify that the hotspot is reliable in the location with a laptop or something? The other thing that would be worth trying is bumping your timeout to 5000 or so. Cellular data connections can be kind of slow, resulting in longer timeouts.
    – Butters
    Jul 7 '15 at 14:52
  • @Butters I checked the connection speed. My router does 15ms ping, 4.7Mbps download, 8.2Mbps upload and the hotspot does 35ms ping, 4.2 download, 2.2 upload. I don't have a good reference- is that a big enough difference to cause the problem? As for the timeout, I only really care about the upload so that timeout shouldn't be a big deal, right?
    – ericksonla
    Jul 7 '15 at 19:40
  • Ya, you're probably correct, and your speeds should be fine. So you don't get any errors at all in the code, or you don't get any compile errors? Do you see the Sending dweet failed in your serial monitor?
    – Butters
    Jul 7 '15 at 22:19
  • Code-wise, it appears to run fine. It reports that it sent the information.
    – ericksonla
    Jul 8 '15 at 2:11
  • Interesting. You might have to run [Wireshark](www.wireshark.org) to inspect the traffic on the network and see what is actually going on. Good luck!
    – Butters
    Jul 9 '15 at 2:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.