Go Down

Topic: CC3000 Wifi Shield and SD card problem. (Read 714 times) previous topic - next topic

mfacen

   I'm working in a project where I connect an arduino DUE with a Adafruit CC3000 wifi shield running a server to a web interface, there is a file I need to read from the SD card and send trough WIFI, if I dont start the server in the Arduino the SD card reads fine, as soon as the server starts listening for clients the SD card stops working, both devices share the SPI but i rechecked and there shouldn't be any conflicts, CS for the SD card is pin 4 and for the WiFi Shield is pin 10.
   The program is quite extensive, the relevant parts are:
Code: [Select]

#include <Keypad.h>
#include <Wire.h>
#include <SPI.h>
#include <Time.h>
#include <SD.h>
#include <dht.h>
#include <MenuBackendPlus.h>
//#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>

//#include <Tone.h>
#include "Adafruit_MCP9808.h"
#include <Adafruit_CC3000.h>      // include the CC3000 library
#include "utility/debug.h"        // idk why this are included with the CC3000
#include "utility/socket.h"       //   this one too

//########################################################################################
// These are the interrupt and control pins                       ALL THIS IS CC3000 RELATED
#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       "INFINITUM08DA47"   // cannot be longer than 32 characters!
#define WLAN_PASS       "xxxxxxxxx"               // I just x'ed the password here
// 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      // What TCP port to listen on for connections. 
                                      // The HTTP protocol uses port 80 by default.
Adafruit_CC3000_Server httpServer(LISTEN_PORT);

//#########################################################################################
void setup() {

  pinMode ( 10, OUTPUT );    // CS for the WIFI shield

if (SD.begin(4)) {
    if (SD.exists("settings.qsc")) { loadSettings() ;  msg("Settings file found."); }
  }

//###################################  SERVER STUFF
  if (!cc3000.begin()) msg("bad cables ?");
  lcd.clear(); lcd.print("connecting to:");lcd.setCursor(0,1);lcd.print (WLAN_SSID);
  cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);
  lcd.setCursor(0,3); lcd.print ("Get DHCP");
  while (!cc3000.checkDHCP())
  {
    delay(100); // ToDo: Insert a DHCP timeout!
  } 
   httpServer.begin();

        if (SD.exists("settings.qsc"))   {   msg("Settings file found."); }

}


  That's just the setup part of the program, when I run it it prints on the LCD "Settings file found" ( thats the void msg() function ) the first time before initializing the server, after the initialization I added a second msg that should get printed too but the Arduino fails to find the file.
    I tried to narrow down the problem and this is as close to it I can get, I tried putting a delay after httpServer.begin() , tried to deselct manually the SD and WiFi, etc. If I comment out the Wifi part then the SD card works troughout the program ( there is a lot of writing and reading from SD card and it works perfectly). The Wifi works fine, its just that I cant read the SD card while listening for clients.
   Something I've been thinking about is the way the shield is built, it has a SPI header for the DUE, but it works also with the UNO using the pins 10, 11, 12 and 13, but as far as I can tell there is no conflicts.
   This problem kept me up for 2 days, I can't find a solution for it, if someone can give me some clues I'd really appreciate it.

mfacen

ok I solved it. Thank you so much for all the replies. It just took me a week .

badank


ok I solved it. Thank you so much for all the replies. It just took me a week .


Hi mfacen,

Actually I have identical problem when I "#include <SD.h>" to the sketch, the httpServer of my CC3000 couldn't start.

Can you share how you resolve the problem?
I am not found any replies on this thread.

dfbrown

Ok, so I would like to see your solution too.

Go Up