Member #659937

Member Since: March 11, 2015

Country: United States

  • which pins of the Arduino Uno does this shield use? I need 3 pwm pins, but it seems like there’s a problems with the ones I’m using now

  • I’m having quite a bit of trouble connecting to my house’s wifi.. It used to work really well for a while, but now it doesn’t do very well. I ran the connection test, and it worked, but when I ran the Web Client example, it stalls at the “Performing HTTP Get of: www.example.com” Must it be a problem with the WiFi? The network works pretty well on my laptop/phone. I’m ultimately using the shield to perform a post to Thingspeak. I didn’t change the code that much, but with this code, it doesn’t even connect to the WiFi as it does in the Web Client. Any help?

    My code below:

    #include <SFE_CC3000.h>
    #include <SFE_CC3000_Callbacks.h>
    #include <SFE_CC3000_Client.h>
    #include <SFE_CC3000_SPI.h>
    
    
    /****************************************************************
    WebClient.ino
    CC3000 WebClient Test
    Shawn Hymel @ SparkFun Electronics
    March 1, 2014
    https://github.com/sparkfun/SFE_CC3000_Library
    
    Manually connects to a WiFi network and performs an HTTP GET
    request on a web page. Prints the contents of the page to
    the serial console.
    
    The security mode is defined by one of the following:
    WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA, WLAN_SEC_WPA2
    
    Hardware Connections:
    
     Uno Pin    CC3000 Board    Function
    
     +5V        VCC or +5V      5V
     GND        GND             GND
     2          INT             Interrupt
     7          EN              WiFi Enable
     10         CS              SPI Chip Select
     11         MOSI            SPI MOSI
     12         MISO            SPI MISO
     13         SCK             SPI Clock
    
    Resources:
    Include SPI.h, SFE_CC3000.h, and SFE_CC3000_Client.h
    
    Development environment specifics:
    Written in Arduino 1.0.5
    Tested with Arduino UNO R3
    
    This code is beerware; if you see me (or any other SparkFun 
    employee) at the local, and you've found our code helpful, please
    buy us a round!
    
    Distributed as-is; no warranty is given.
    ****************************************************************/
    
    #include <SPI.h>
    
    
    // Pins
    #define CC3000_INT      2   // Needs to be an interrupt pin (D2/D3)
    #define CC3000_EN       7   // Can be any digital pin
    #define CC3000_CS       10  // Preferred is pin 10 on Uno
    
    // Connection info data lengths
    #define IP_ADDR_LEN     4   // Length of IP address in bytes
    
    // Constants
    char ap_ssid[] = "IFH Lounge";                  // SSID of network
    char ap_password[] = "ifhJanuary";          // Password of network
    unsigned int ap_security = WLAN_SEC_WPA2; // Security of network
    unsigned int timeout = 3000000;             // Milliseconds
    char server[] = "api.thingspeak.com";        // Remote host site
    String writeAPIKey = "4JRIMA3GJF3PIQKE";            // API Key for Thingspeak
    const int updateThingSpeakInterval = 15 * 1000; //Time Interval
    
    
    long lastConnectionTime=0;
    boolean lastConnected = false;
    int failedCounter = 0;
    int test = 0;
    
    // Global Variables
    SFE_CC3000 wifi = SFE_CC3000(CC3000_INT, CC3000_EN, CC3000_CS);
    SFE_CC3000_Client client = SFE_CC3000_Client(wifi);
    
    void setup() {
    
      ConnectionInfo connection_info;
      int i;
    
      // Initialize Serial port
      Serial.begin(115200);
      Serial.println();
      Serial.println("---------------------------");
      Serial.println("SparkFun CC3000 - Thingspeak");
      Serial.println("---------------------------");
    
      // Initialize CC3000 (configure SPI communications)
      if ( wifi.init() ) {
        Serial.println("CC3000 initialization complete");
      } else {
        Serial.println("Something went wrong during CC3000 init!");
      }
    
      // Connect using DHCP
      Serial.print("Connecting to SSID: ");
      Serial.println(ap_ssid);
      if(!wifi.connect(ap_ssid, ap_security, ap_password, timeout)) {
        Serial.println("Error: Could not connect to AP");
      }
    
    }
    
    void loop(){
      test=3;
    
      if (client.available()){
        char c = client.read();
        //Serial.print(c);
    
      }
    
      if (!client.connected() && lastConnected)
      {
        Serial.println("...disconnected");
        Serial.println();
    
        client.stop();
      }
    
      if(!client.connected() && (millis() - lastConnectionTime > updateThingSpeakInterval)){
        updateThingSpeak("field1="+ String(test,DEC));
      }
    
      if (failedCounter > 3){
        wifi.connect(ap_ssid, ap_security, ap_password, timeout);
      }
    
      lastConnected = client.connected();
    
    }
    
    void updateThingSpeak(String tsData){ //this block of lines basically accesses the Thingspeak channel in the required format
      if (client.connect(server, 80)){
        client.print("POST /update HTTP/1.1\n");
        client.print("Host: api.thingspeak.com\n");
        client.print("Connection: close\n");
        client.print("X-THINGSPEAKAPIKEY: "+writeAPIKey+ "\n");
        client.print("Content-Type: application/x-www-form-urlencoded\n");
        client.print("Content-Length: ");
        client.print(tsData.length());
        client.print("\n\n");
    
        client.print(tsData);
    
        lastConnectionTime = millis();
    
        if (client.connected()){
          Serial.println("Connected to Thingspeak...");
          Serial.println();
          failedCounter = 0;
        }
    
        else{
          failedCounter++;
    
          Serial.println("Connection to ThingSpeak failed ("+String(failedCounter, DEC)+")");
          Serial.println();
        }
       }
       else{
        failedCounter++;
    
        Serial.println("Connection to ThingSpeak failed ("+String(failedCounter, DEC)+")");
        Serial.println();
    
        lastConnectionTime = millis();
       }
      }
    
  • Thanks Shawn! Another question, I need to get a timestamp using the wifi shield. Can I use Time.h with it?

  • So I saw someone else mention in another forum that I can go to network support and have them allow the CC3000 based on the MAC address? Is that feasible? I’m not even sure I understand what the MAC address is/how to connect via that? Sorry I’m ignorant as far as the Arduino goes..

  • Hey guys, I’m trying to use this with the college wifi and the two options for connecting to the internet are: -WPA2 Enterprise (I need to enter a username and password -Open (in this one, when you sign in it opens a web page that requires you to type a username and password)

    The next closest option is: -Open (in this one, when you sign in it opens a web page that requires you to click the “connect” button)

    Is it possible for me to connect to any with this shield? If so, how would I do that? Thank you!

No public wish lists :(