Anonymouslemming

I have a WiFi shield on an Arduino Uno (rev 1), and I'm trying to use the wifi and the SD card in the same sketch. I can use the SD card in its own sketch, and I can use the the WiFi in a separate sketch. But as soon as I try and use them in the same sketch, things behave oddly.

Can anyone point me at an example that uses both the WiFi shield and the SD card in the same sketch, or advise where I'm going wrong here please?

The only change between working and failing is the addition of the following lines to the setup() method

/* setup Setup various pin modes, LCD display and ensure that we are connected to the wifi network*/void setup() { Serial.begin(9600);

Serial.println("Arduino in setup()");

// set up the LCD's number of columns and rows: lcd.begin(16, 2); lcd.print("Temp: ");

wifiStatus = connectToNetwork();}

/* connectToNetwork Connect to a wifi network

- if we are able to connect to the network, we briefly display the SSID on the LCD then Net: OK - if we fail to connect to the network, we display Net: BAD on the LCD*/int connectToNetwork() { while(!Serial) ;

- if we are able to connect to the network, we briefly display the SSID on the LCD then Net: OK - if we fail to connect to the network, we display Net: BAD on the LCD*/int connectToNetwork() { while(!Serial) ;

Anonymouslemming

If that works ok, then copy and paste your wifi startup where I put the comment. Then it should start the wifi ok. The SD library begin() function call returns with the SD SPI disabled (D4 HIGH).

edit. Once these SS lines are initialized, you do not need to manipulate them anywhere else. The libraries will take care of that in the low level read/write functions.

Huh, ok - thanks!

Interestingly it works if I have the SD and the WiFi setup all in the setup() method. If I do the SD and then do the WiFi in a separate method (like I had it with connectToNetwork, then it fails still.

Any idea why that is ?

Again - thanks for the help - it makes the setup a bit more ugly, but it lets me keep going

That seems to have done the trick - I wasn't aware that my use of static strings like this could hurt me in the long run. I've now added this to all of them. Now to just look up the F function and see what cost this magic comes at