Hello again,
I tried now to use SD-CARD and WIFI together - without success!
Here is my short code (not the best,...quick and dirty)
/*
Used parts:
# Tinyduino - Processor Board
# TinyShield - USB & ICP
# TinyShield - WIFI
# TinyShield - SD Card
# TinyShield - Proto Board
*/
// Include libraries
#include <Adafruit_CC3000.h>
#include <SPI.h>
#include <SD.h>
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
// WIFI-CC3000
#define ADAFRUIT_CC3000_IRQ 2 // must be a IRQ Pin
#define ADAFRUIT_CC3000_VBAT A3 //
#define ADAFRUIT_CC3000_CS 8 // PIN: ChipSelect für WIFI
#define WLAN_SSID "???????" // cannot be longer than 32 characters!
#define WLAN_PASS "???????"
#define WLAN_SECURITY WLAN_SEC_WPA2 // This can be WLAN_SEC_UNSEC, WLAN_SEC_WEP,
// WLAN_SEC_WPA or WLAN_SEC_WPA2
// SD-CARD
#define SD_CS 10 // PIN: ChipSelect für SD-CARD
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
// WIFI
uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
// WIFI-CC3000 instance
Adafruit_CC3000 wifi = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ,
ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIV2);
// SD-CARD
File dataFile;
String dataString = "";
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
// setup
void setup()
{
Serial.begin(9600);
/* ----------------------------------------------------------
Starting
----------------------------------------------------------*/
Serial.println("Starting...");
Serial.println("Controller is starting...");
/* ----------------------------------------------------------
WIFI
----------------------------------------------------------*/
// Initialise the CC3000 module
Serial.println("WIFI Module");
Serial.println("* Initialising...");
if (!wifi.begin()) {
while(1) {
}
}
// Connect to WiFi network
wifi.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);
// Check DHCP
Serial.print("\n* Request DHCP");
while (!wifi.checkDHCP())
{
delay(100);
}
/* Display the IP address DNS, Gateway, etc. */
if(!wifi.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv)) {
Serial.println("!!! Unable to retrieve the IP Address!!!\r\n");
}
else {
Serial.print("\n* IP Addr: ");
wifi.printIPdotsRev(ipAddress);
Serial.print("\n* Netmask: ");
wifi.printIPdotsRev(netmask);
Serial.print("\n* Gateway: ");
wifi.printIPdotsRev(gateway);
Serial.print("\n* DHCPsrv: ");
wifi.printIPdotsRev(dhcpserv);
Serial.print("\n* DNSserv: ");
wifi.printIPdotsRev(dnsserv);
}
Serial.println("\n* WiFi connection successfully finished!");
/* ----------------------------------------------------------
SD-CARD
----------------------------------------------------------*/
Serial.print("Initializing SD card...\n");
pinMode(10, OUTPUT); // Pin 10 must be configured as output
if (!SD.begin(SD_CS)) {
Serial.println("initialization failed. Things to check:");
Serial.println("* is a card is inserted?");
Serial.println("* Is your wiring correct?");
Serial.println("* did you change the chipSelect pin to match your shield or module?");
Serial.println("---------------------------------");
return;
}
else {
Serial.println("initialization successfull!");
dataFile = SD.open("data.txt", FILE_WRITE);
Serial.println("Wiring is correct and a card is present.");
}
if (dataFile) {
dataString += "Controller started";
dataFile.println(dataString);
dataFile.close();
// print to the serial port too:
Serial.println(dataString);
}
Serial.println("* SD-Card successfully started...");
Serial.println("---------------------------------");
Serial.println("Controller sucessfully started!");
Serial.println("=================================");
}
/*****************************************************************************/
// loop
void loop() {
// do something
}
// end loop
/*****************************************************************************/
If I commend out the SD-CARD section it work - this means WIFI work and on the serial monitor you will see the WIFI parameter:
Starting...
Controller is starting...
WIFI Module
* Initialising...
Started AP/SSID scan
Connecting to ???????...Waiting to connect...
* Request DHCP
* IP Addr: 10.0.0.6
* Netmask: 255.255.255.0
* Gateway: 10.0.0.254
* DHCPsrv: 10.0.0.254
* DNSserv: 10.0.0.254
* WiFi connection successfully finished!
Controller sucessfully started!
=================================
If I include the SD-CARD section, nothing will be shown on the serial monitor.
If I commend out the WIFI section it work - this means SD-CARD work and on the serial monitor you will see some informations:
Starting...
Controller is starting...
Initializing SD card...
initialization successfull!
Wiring is correct and a card is present.
Controller started
* SD-Card successfully started...
---------------------------------
Controller sucessfully started!
=================================
Why is now nothing on the serial monitor?
Who can help me?
What is wrong?
But maybe there is an other problem, why?
I work on a MacBook Pro with OS 10.9 with ARDUINO 1.0.5 and how you can see in the code above I use 9600 for Serial communication.
But on the terminal monitor I have to adjust 4800 to see all messages, otherwise I see only some characters.
Is this normal?
Thanks in advance
[EDIT]: I solved now the problem with the serial communication (baud rate) - use the right board and than it will work

.
But all other problems are still here.