please solution conflict between <SD.H> and <UIPETHERNET.h> ENC82J60  

I have Aurduino Uno and Ethernet shield ENC82J60 http://www.syrduino.com/index.php/products/ethernet-shield

The code work fine. I Stack the ethernet shield on Arduino Uno

/*
 * UIPEthernet EchoServer example.
 *
 * UIPEthernet is a TCP/IP stack that can be used with a enc28j60 based
 * Ethernet-shield.
 *
 * UIPEthernet uses the fine uIP stack by Adam Dunkels <adam@sics.se>
 *
 *      -----------------
 *
 * This Hello World example sets up a server at 192.168.1.6 on port 1000.
 * Telnet here to access the service.  The uIP stack will also respond to
 * pings to test if you have successfully established a TCP connection to
 * the Arduino.
 *
 * This example was based upon uIP hello-world by Adam Dunkels <adam@sics.se>
 * Ported to the Arduino IDE by Adam Nielsen <malvineous@shikadi.net>
 * Adaption to Enc28J60 by Norbert Truchsess <norbert.truchsess@t-online.de>
 */

#include <SPI.h>
#include <UIPEthernet.h>

//#include <SD.h>

EthernetServer server = EthernetServer(80);

void setup()
{
  /*Serial.begin(9600);
  
  
  pinMode(2,OUTPUT);
  digitalWrite(2,HIGH);
  
  pinMode(3,OUTPUT);
  digitalWrite(3,HIGH);
  
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);
  
  pinMode(5,OUTPUT);
  digitalWrite(5,HIGH);
  
  pinMode(6,OUTPUT);
  digitalWrite(6,HIGH);
  
  pinMode(7,OUTPUT);
  digitalWrite(7,HIGH);
  
  pinMode(8,OUTPUT);
  digitalWrite(8,HIGH);
  
  pinMode(9,OUTPUT);
  digitalWrite(9,HIGH);
  
  
  
  
  pinMode(10,OUTPUT);
   digitalWrite(10,LOW);
  
  */
  

  uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
  IPAddress myIP(192,168,1,200);

  Ethernet.begin(mac,myIP);

  server.begin();
}

void loop()
{
  size_t size;

  if (EthernetClient client = server.available())
    {
      while((size = client.available()) > 0)
        {
          uint8_t* msg = (uint8_t*)malloc(size);
          size = client.read(msg,size);
          Serial.write(msg,size);
          free(msg);
        }
      client.println("DATA from Server!");
      client.stop();
    }
}

and I can open the 192.168.1.200 from browser without problem
when I add #include <SD.h> to Code it get may be conflict and I can’t open the web page although I can’t add any SD card shield
and my Ethernet shield do not have the SD card slot . the Ethernet Shield use ss pin 10 . and try set all pin to HIGH and pin 10 to
LOW . from month I can not find solution. sorry for bad English

Set pin 10 to HIGH too. The library will set it low when it uses it, leaving it HIGH otherwise.

Thanks for replay i set it high and not working why

Maybe you are running out of SRAM. I don't use the ENC28J60, so I can't test it, but I hear the library is larger. That and the SD library may require more SRAM than you have available.

Try adding this function to your code.

int freeRam() {
  extern int __heap_start,*__brkval;
  int v;
  return (int)&v - (__brkval == 0 ? (int)&__heap_start : (int) __brkval);  
}

Then call it like this before and after you start the ethernet shield with the SD.h library included.

  Serial.print(F("SRAM left: "));
  Serial.println(freeRam());

It will not show zero if it runs out of SRAM. It will show a negative number or an unreasonably large number.

Thanks for replay ther is no problem in memory it consumes only 65% from ram . From month i test every thing no solution any ideas plese

freeRam does not return a percentage. Try this code and post the serial monitor output. The server could return a packet that allocates more SRAM than you have available.

#include <SPI.h>
#include <UIPEthernet.h>
#include <SD.h>

uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
IPAddress myIP(192,168,1,200);

EthernetServer server = EthernetServer(80);

int freeRam() {
  extern int __heap_start,*__brkval;
  int v;
  return (int)&v - (__brkval == 0 ? (int)&__heap_start : (int) __brkval);  
}

void setup()
{
  Serial.begin(9600);

  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);
  
  Serial.print(F("SRAM left before ethernet begin: "));
  Serial.println(freeRam());

  Ethernet.begin(mac,myIP);

  server.begin();

  Serial.print(F("SRAM left after server begin: "));
  Serial.println(freeRam());
}

void loop()
{
  size_t size;

  if (EthernetClient client = server.available())
    {
      while((size = client.available()) > 0)
        {
// this malloc could request more SRAM than you have
          uint8_t* msg = (uint8_t*)malloc(size);
          size = client.read(msg,size);
          Serial.write(msg,size);

          Serial.print(F("SRAM left after client read: "));
          Serial.println(freeRam());

          free(msg);
        }


      client.println("DATA from Server!");
      client.stop();
    }
}

thanks you for replay I try the code the output from serial monitor

SRAM left before ethernet begin: 263
SRAM left after server begin: 263

any ideas why that.

It appears you are out of SRAM. If you try to allocate memory for the client request with malloc, there will not be enough to allocate.

The SD library allocates a bunch of SRAM for a buffer. Comment out the "#include SD.h" and run it again.

I comment the include <SD.H> the output is

SRAM left before ethernet begin: 869
SRAM left after server begin: 869
GET / HTTP/1.1
Host: 192.168.1.200
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,ar;q=0.6

SRAM left after client read: 477
GET /favicon.ico HTTP/1.1
Host: 192.168.1.200
Connection: keep-alive
Accept: */*
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,ar;q=0.6

SRAM left after client read: 563

when I add #include<SD.H> again the the page not open and the output only

SRAM left before ethernet begin: 263
SRAM left after server begin: 263

That 263 bytes is not enough memory remaining to allocate 392 bytes for the client request with the malloc.

thank s very much . what can I do for that . please help me for that . my final project next week

=( =( =( =( =( =( =( =( =( =( =( =( =( =(

Don't allocate that much SRAM. You are using only the first line of the request. Search the forum for zoomkat's server code. He limits the number of characters to about 100. Here is an example of his code:

He uses the String data type. I prefer a character array.

the zoomkat’s server code is longer frm my code . is there any way to Enlarge the size of sram

You don’t need all of zoomkat’s code. Just use the part that gets the client request and disregard the rest.

  String readString;

  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

// here is the part that keeps the SRAM use down to about 100 bytes
         if (readString.length() < 100) {
          readString += c; 
         } 
        //check if HTTP request has ended
        if (c == '\n') {

          //check get atring received
          Serial.println(readString);

I test this Code

#include <SPI.h>
#include <UIPEthernet.h>
#include <SD.h>

uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
IPAddress myIP(192,168,1,200);

EthernetServer server = EthernetServer(80);

int freeRam() {
  extern int __heap_start,*__brkval;
  int v;
  return (int)&v - (__brkval == 0 ? (int)&__heap_start : (int) __brkval);  
}

void setup()
{
  Serial.begin(9600);

  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);
  
  Serial.print(F("SRAM left before ethernet begin: "));
  Serial.println(freeRam());

  Ethernet.begin(mac,myIP);

  server.begin();

  Serial.print(F("SRAM left after server begin: "));
  Serial.println(freeRam());
}

void loop()
{
  size_t size;

  String readString;

  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

// here is the part that keeps the SRAM use down to about 100 bytes
         if (readString.length() < 100) {
          readString += c; 
         } 
        //check if HTTP request has ended
        if (c == '\n') {

          //check get atring received
          Serial.println(readString);
      
      
      ///////////////////////////////////////
      
      
      
      while((size = client.available()) > 0)
        {
// this malloc could request more SRAM than you have
          uint8_t* msg = (uint8_t*)malloc(size);
          size = client.read(msg,size);
          Serial.write(msg,size);

          Serial.print(F("SRAM left after client read: "));
          Serial.println(freeRam());

          free(msg);
        }

///////////////////////////////////////////////////




      client.println("DATA from Server!");
      client.stop();
      
      
        }
      }
    }
  }
      
      
      
      //////////////////////////////////////////
    
}

and the output

SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS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SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSMMMMMMMMíSRAM left before ethernet begin: 263
SRAM left after server begin: 263

but the page not diplay

is there any way to Enlarge the size of sram

Like Viagra for SRAM? No.

You need to quit wasting what you have or get an Arduino with more to waste.

:grin: :grin: :grin: :grin: :grin: :grin:

finaly the 2 shield work together but I cut the half of the code

I write this code and I can open web page and Initializing SD card

#include <UIPEthernet.h>
#include <SD.h>




File webFile;
uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
IPAddress myIP(192,168,1,200);

EthernetServer server = EthernetServer(80);



void setup()
{
  Serial.begin(9600);
  
  
   // initialize SD card
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;    // init failed
    }
    Serial.println("SUCCESS - SD card initialized.");
    
    


  Ethernet.begin(mac,myIP);

  server.begin();

}

void loop()
{

  String readString;

  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

         if (readString.length() < 100) {
          readString += c; 
         } 
      
        if (c == '\n') {

          
          Serial.println(readString);
          
          
          
          
                  /*    webFile = SD.open("index.htm");        // open web page file
                    if (webFile) {
                        while(webFile.available()) {
                            client.write(webFile.read()); // send web page to client
                        }
                        webFile.close();
                    }
                    break;
                   */
                   
                   

     client.println("DATA from Server!");
     client.stop();
      
      
        }
      }
    }
  }
      
      
    
}

but comment the code to get index.htm from SD card because it get problem in SRAM

the output from serial is

Initializing SD card...
SUCCESS - SD card initialize.



GET / HTTP/1.1

GET /favicon.ico HTTP/1.1

GET / HTTP/1.1

what is solution to small SRAM I can not write any code in ajax for automation Home