Pages: [1]   Go Down
Author Topic: Help- How to connect Gizduino CC3000 Wifi Shield to Wireless Router  (Read 755 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Help- How to connect CC3000 Wifi Shield to Wireless Router

I am Using Gizduino+ ATMega 644 and Gizduino CC3000 Wifi Shield but it seems I can't connect to a wireless router?  smiley-confuse


Gizduino+ ATMega 644


Gizduino CC3000 Wifi Shield

The code I uploaded is this:

Code:

/*
WirelessControllerWifi is one of the applicatioin of CC3000 Wifi Module
                  - This sample application code simply turns on and off
                   an LED remotely via Wifi.
                  - It is suggested to use Atmega644 to avoid further
                    RAM issues.
                  - The IP address given to CC3000 by the Access Point
                    is static. Therefore, it is advisable to make sure
                    that the IP address entered to the browser is correct.
                  
Execution:
  1. Once uploaded to the microcontroller, open the serial.
  2. Wait for successful connection.
  3. When DHCP request is successful, Copy the IPaddress given to your device.
  4. Enter the IPaddress to your browser.
  5. The small Wireless Controller webpage will then be loaded.
  6. Click ON button to turn on the LED and OFF button to turn it off.

Wiring Connection:
  1. Connect +pin of LED(series with current limiting resistor if needed) to pin 14(A0).
             -pin to GND. This will be the LED to be controlled.
  2. Connect +pin of LED(series with current limiting resistor if needed) to pin 9.
             -pin to GND. This will be the wifi connection indicator.          
            
Notes:
  Reserved pins for CC3000 and SD Card communication are as follows.
    CC3000 Breakout Board              Gizduino
          SCK   <------------------> Digital pin 13
          MISO  <------------------> Digital pin 12
          MOSI  <------------------> Digital pin 11
          CS    <------------------> Digital pin 10
          V_EN  <------------------> Digital pin 5
          uSDCS <------------------> Digital pin 4
          IRQ   <------------------> Digital pin 3
References:
         - Adafruit_CC3000 ChatServer.ino
         - Ethernet WebServer.ino
         - Important Libraries from Adafruit: https://learn.adafruit.com/adafruit-cc3000-wifi/cc3000-library-software

Created On:  28 APR 14
        By:  e-Gizmo Mechatronix Central
*/

#include <Adafruit_CC3000.h>
#include <SPI.h>
#include "utility/debug.h"
#include "utility/socket.h"

/* --- CC3000 constants --- */
// These are the interrupt and control pins
#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
// These can be any two pins
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    10
// Use hardware SPI for the remaining pins
// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
                                         SPI_CLOCK_DIVIDER); // you can change this clock speed
#define WLAN_SSID       "yourWifi"           // cannot be longer than 32 characters!
#define WLAN_PASS       "yourWifipassword"
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2
#define LISTEN_PORT           80
Adafruit_CC3000_Server gizduinoServer(LISTEN_PORT);  //(LISTEN_PORT);

/* --- Webpage variables --- */
String req;     // Will handle the request of the client.
String reqsub;  // Request substring to for keyword "on" or "of".
char webpage[404] = "<!DOCTYPE HTML><html><body><center><h1>Wireless Controller via Wi-Fi</h1><p>by e-Gizmo</p><br><form method=\"get\"><input type=\"button\"style=\"height:100px;width:100px\" value=\"ON\"onclick=\"window.location='/?on'\">&nbsp;<input type=\"button\"style=\"height:100px;width:100px\"value=\"OFF\"onclick=\"window.location='/?of'\"></form></center></body></html>";

/* --- LED Indicators --- */
#define controlLED 14
#define wifiLED 9

void setup(void)
{
  Serial.begin(9600);
  Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC);
  /* Initialise the module */
  Serial.println("Initializing...");
  if (!cc3000.begin())
  {
    Serial.println("Couldn't begin()! Check your wiring?");
    while(1);
  }
  Serial.print("Attempting to connect to "); Serial.println(WLAN_SSID);
  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println("Failed!");
    while(1);
  }  
  Serial.println("Connected!");  
  Serial.println("Request DHCP...");
  cc3000.checkDHCP();
  // Display the IP address DNS, Gateway, etc.
  while (! displayConnectionDetails()) {  
    delay(1000);
  }  
  gizduinoServer.begin();  // Start listening for connections
  Serial.println("Waiting for Client...");
  
  pinMode(wifiLED,OUTPUT);  // LED pin for Wifi connection indicator.
  digitalWrite(wifiLED,HIGH);
  pinMode(controlLED,OUTPUT);  // LED pin to be controlled.
  
}

void loop(void){
  
  if(!cc3000.checkConnected()){
    Serial.println("CONNECTION LOST!");
    digitalWrite(wifiLED,LOW);
    while(1);
  }else{  
    // Try to get a client which is connected.
    Adafruit_CC3000_ClientRef client = gizduinoServer.available();
    if (client) {
      Serial.println("New client");
      // an http request ends with a blank line
      boolean currentLineIsBlank = true;
      while (client.connected()) {
        if (client.available()) {
          char c = client.read();
          Serial.write(c);
          req += c;
          reqsub = req.substring(6,8);
          if (reqsub == "of"){
            digitalWrite(controlLED, LOW);
          }
          if (reqsub == "on"){
            digitalWrite(controlLED, HIGH);
          }
          // Send a reply to the client
          if (c == '\n' && currentLineIsBlank) {
            // send a standard http response header
            client.println("HTTP/1.1 200 OK");
            client.println("Content-Type: text/html");
            client.println("Connection: close");  // the connection will be closed after completion of the response
            client.println();
            // Give the web page to the client
            client.println(webpage);
            client.println("");      
            break;
          }
          if (c == '\n') {
            // you're starting a new line
            currentLineIsBlank = true;
          }
          else if (c != '\r') {
            // you've gotten a character on the current line
            currentLineIsBlank = false;
          }
        }
      }    
      // give the web browser time to receive the data
      delay(100);
      // close the connection
      client.close();
      Serial.println("Client disconnected");
      req="";
    }    
  }
}

/**************************************************************************/
/*!
    @brief  Tries to read the IP address and other connection details
*/
/**************************************************************************/
bool displayConnectionDetails(void)
{
  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
  
  if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
  {
    Serial.println(F("Unable to retrieve the IP Address!\r\n"));
    return false;
  }
  else
  {
    Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
    Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
    Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
    Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
    Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
    Serial.println();
    return true;
  }
}


When I open the Serial Monitor, it prints the Free RAM and Initializing only....  smiley-confuse


* cc3000400.png (216.5 KB, 400x354 - viewed 28 times.)

* gizduinoplusV30400.png (185.75 KB, 400x316 - viewed 28 times.)
« Last Edit: August 09, 2014, 08:51:43 pm by nexysllanes » Logged

Scotland
Offline Offline
Edison Member
*
Karma: 26
Posts: 1334
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What does your suppliers support say?
Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

They are not responding yet.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please, help me. smiley-sad
Logged

Scotland
Offline Offline
Edison Member
*
Karma: 26
Posts: 1334
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

As this is a non standard arduino copy, unless some one has had this exact issue, without any details (it won't connect tells us nothing)  did you change the network ID, password & security tp match your router?
Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

if you're from the philippines and wish to get adafruit's cc3000 here's the link
Shield http://www.circuit-help.com.ph/product/adafruit-cc3000-wifi-shield-w-onboard-ceramic-antenna/
Breakout Board http://www.circuit-help.com.ph/product/adafruit-cc3000-wifi-breakout-with-onboard-ceramic-antenna/
Logged

Pages: [1]   Go Up
Jump to: