CC3000 Shield: Works but need a little help

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
narendrab
 
Posts: 11
Joined: Thu Dec 19, 2013 4:12 pm

CC3000 Shield: Works but need a little help

Post by narendrab »

The CC3000 Shield is working flawlessly with the Uno. I am able to connect to the Carriot server and transfer data as in the tutorial.

Is there a way that I can keep connected to my wifi router all the time and only transmit to the Carriot server when needed.

I have not been able to figure this out. Any help will be greatly appreciated.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: CC3000 Shield: Works but need a little help

Post by adafruit_support_rick »

Try this:
Move the access-point connection code to setup():

Code: Select all

void setup(void)
{
  // Initialize
  Serial.begin(115200);
  
  Serial.println(F("\nInitializing..."));
  if (!cc3000.begin())
  {
    Serial.println(F("Couldn't begin()! Check your wiring?"));
    while(1);
  }
 
  // Connect to WiFi network
  cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);
  Serial.println(F("Connected!"));
  
  /* Wait for DHCP to complete */
  Serial.println(F("Request DHCP"));
  while (!cc3000.checkDHCP())
  {
    delay(100);
  }  
 
  // Get the website IP & print it
  ip = 0;
  Serial.print(WEBSITE); Serial.print(F(" -> "));
  while (ip == 0) {
    if (! cc3000.getHostByName(WEBSITE, &ip)) {
      Serial.println(F("Couldn't resolve!"));
    }
    delay(500);
  }
  cc3000.printIPdotsRev(ip);
}

void loop(void)
{
  
  // Get data & transform to integers
  soilSensor.measure(&t, &h, &dewpoint);
 
  // Convert data to String
  String temperature = doubleToString(t,2);
  String humidity = doubleToString(h,2);

 . . . etc . . .
Then, at the end of loop(), comment out the disconnect:

Code: Select all

. . . etc . . .

  Serial.println(F("-------------------------------------"));
  while (client.connected()) {
    while (client.available()) {
      char c = client.read();
      Serial.print(c);
    }
  }
  client.close();
  Serial.println(F("-------------------------------------"));
  
//  Serial.println(F("\n\nDisconnecting"));
//  cc3000.disconnect();
  
  // Wait 10 seconds until next update
  delay(10000);
   
}

User avatar
narendrab
 
Posts: 11
Joined: Thu Dec 19, 2013 4:12 pm

Re: CC3000 Shield: Works but need a little help

Post by narendrab »

I tried this but it has not worked.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: CC3000 Shield: Works but need a little help

Post by adafruit_support_rick »

narendrab wrote:I tried this but it has not worked.
What do you mean by that? I was telling you how to stop continuously disconnecting and re-connecting. That should do that. What doesn't work?

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”