Forum Members section DIY Ferduino controller Problem with ethernet module W5100

Problem with ethernet module W5100  [SOLVED]

Ask here about your controller made with pieces purchased in other shops.

Post Number:#21 Post Mon Aug 10, 2015 4:24 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 40
Location: São Paulo
Gender: Male
National Flag:
Brazil

Change the IP of your router to 192.168.0.1.

EDIT: Why /23? What's this?
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#22 Post Mon Aug 10, 2015 6:45 pm
Posts: 45
Topics: 9
Solve rating: 0
Joined: Thu Apr 10, 2014 12:21 pm
Topics: 9
Age: 39
Gender: None specified
National Flag:
Brazil
Change the IP of your router to 192.168.0.1.

EDIT: Why /23? What's this?



I changed but not success....
/23 ou /24 is a mask(subnet) of network.

/24 is 255.255.255.0

~x( ~x(

Post Number:#23 Post Tue Aug 11, 2015 10:30 am
Posts: 45
Topics: 9
Solve rating: 0
Joined: Thu Apr 10, 2014 12:21 pm
Topics: 9
Age: 39
Gender: None specified
National Flag:
Brazil
will be defective in module?

I'm almost buying an ethernet shield with SD and remove a bridge and remove pins 50, 51, 52 and 53 of the TFT shield and to test ...
and follow the steps in the topic: viewtopic.php?f=24&t=36

This Ethernet Shield:
http://produto.mercadolivre.com.br/MLB- ... o-mega-_JM

Good idea?

Post Number:#24 Post Tue Aug 11, 2015 11:41 am
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 40
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

Maybe, make the test only with Arduino and W5100 without anything else.

Using the example "Ethernet shield with W5100".

Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#25 Post Tue Aug 11, 2015 1:22 pm
Posts: 45
Topics: 9
Solve rating: 0
Joined: Thu Apr 10, 2014 12:21 pm
Topics: 9
Age: 39
Gender: None specified
National Flag:
Brazil
Hi!

Maybe, make the test only with Arduino and W5100 without anything else.

Using the example "Ethernet shield with W5100".

Best regards.



Hi Fernando,

Tested a code only arduino and module w5100:
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 0, 177); // Change the IP according to your local network

const byte SelectSlave_SD = 5; // For Ferduino Mega
//const byte SelectSlave_SD = 4; // For ethernet shield
const byte SelectSlave_ETH = 53;
const byte SelectSlave_RFM = 69;

EthernetServer server(80);

void setup()
{
   pinMode(SelectSlave_SD, OUTPUT);
   pinMode(SelectSlave_RFM, OUTPUT);
   digitalWrite(SelectSlave_SD, HIGH);
   digitalWrite(SelectSlave_RFM, HIGH);
// Open serial communications and wait for port to open:
   Serial.begin(9600);
   while (!Serial)
   {
      ; // wait for serial port to connect. Needed for Leonardo only
   }
   // start the Ethernet connection and the server:
   Ethernet.begin(mac, ip, SelectSlave_ETH);
   server.begin();
   Serial.print("server is at ");
   Serial.println(Ethernet.localIP());
}


void loop()
{
   // listen for incoming clients
   EthernetClient client = server.available();
   if (client)
   {
      uint8_t remoteIP[4];
      client.getRemoteIP(remoteIP);
      Serial.print("New client: ");
      Serial.print(remoteIP[0]);
      Serial.print(".");
      Serial.print(remoteIP[1]);
      Serial.print(".");
      Serial.print(remoteIP[2]);
      Serial.print(".");
      Serial.println(remoteIP[3]);

      // an http request ends with a blank line
      boolean currentLineIsBlank = true;
      while (client.connected())
      {
         if (client.available())
         {
            char c = client.read();
            Serial.write(c);
            // if you've gotten to the end of the line (received a newline
            // character) and the line is blank, the http request has ended,
            // so you can send a reply
            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("Refresh: 5");  // refresh the page automatically every 5 sec
               client.println();
               client.println("<!DOCTYPE HTML>");
               client.println("<html>");
               // output the value of each analog input pin
               for (int analogChannel = 0; analogChannel < 6; analogChannel++)
               {
                  int sensorReading = analogRead(analogChannel);
                  client.print("analog input ");
                  client.print(analogChannel);
                  client.print(" is ");
                  client.print(sensorReading);
                  client.println("<br />");
               }
               client.println("</html>");
               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(1);
      // close the connection:
      client.stop();
      Serial.println("client disonnected");
   }
}


Results:

In browser

analog input 0 is 336
analog input 1 is 333
analog input 2 is 336
analog input 3 is 334
analog input 4 is 383
analog input 5 is 361


Serial monitor:

New client: 192.168.0.187
GET / HTTP/1.1
Host: 192.168.0.177
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cache-Control: max-age=0


After tested same code with arduino, module w5100 and tft shield with screen (Full monted):
Results
Browser:

analog input 0 is 332
analog input 1 is 327
analog input 2 is 325
analog input 3 is 324
analog input 4 is 384
analog input 5 is 357


Serial monitor:

client disonnected
New client: 192.168.0.187
GET / HTTP/1.1
Host: 192.168.0.177
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cache-Control: max-age=0
*********


After again a code teste "Simple webserver running on SD card" with a full monted arduino
and in serial monitor:
Serial monitor

server is at 192.168.0.177
Initializing SD card...
SUCCESS - SD card initialized.
SUCCESS - Found index.htm file.


but dont access in browser, i restarted a arduino e tested again,
Results:
Serial monitor

server is at 192.168.0.177
Initializing SD card...
ERROR - SD card initialization failed!


Restard again,
Results:

server is at 192.168.0.177
Initializing SD card...
SUCCESS - SD card initialized.
SUCCESS - Found index.htm file.


and this time in browser appear:

ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ...


Restart again arduino
Results:

server is at 192.168.0.177
Initializing SD card...
SUCCESS - SD card initialized.
SUCCESS - Found index.htm file.


But no access browser... and restart again arduino and ERROR - SD card initialization failed!...

Post Number:#26 Post Tue Aug 11, 2015 1:32 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 40
Location: São Paulo
Gender: Male
National Flag:
Brazil

It's ok for you?

const byte SelectSlave_SD = 5; // For Ferduino Mega
//const byte SelectSlave_SD = 4; // For ethernet shield
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#27 Post Tue Aug 11, 2015 1:58 pm
Posts: 45
Topics: 9
Solve rating: 0
Joined: Thu Apr 10, 2014 12:21 pm
Topics: 9
Age: 39
Gender: None specified
National Flag:
Brazil
It's ok for you?

const byte SelectSlave_SD = 5; // For Ferduino Mega
//const byte SelectSlave_SD = 4; // For ethernet shield


x_x I'm going 8-}

I go change to 4 and teste again.

Aapologize for the lack of attention

-------------------------------- Last edited Tue Aug 11, 2015 2:09 pm --------------------------------

Returned with results:

tested "Ethernet shield with W5100" with a arduino, w5100, screen with sd and tft shield
 
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 0, 177); // Change the IP according to your local network

//const byte SelectSlave_SD = 5; // For Ferduino Mega
const byte SelectSlave_SD = 4; // For ethernet shield
const byte SelectSlave_ETH = 53;
const byte SelectSlave_RFM = 69;

EthernetServer server(80);

void setup()
{
   pinMode(SelectSlave_SD, OUTPUT);
   pinMode(SelectSlave_RFM, OUTPUT);
   digitalWrite(SelectSlave_SD, HIGH);
   digitalWrite(SelectSlave_RFM, HIGH);
// Open serial communications and wait for port to open:
   Serial.begin(9600);
   while (!Serial)
   {
      ; // wait for serial port to connect. Needed for Leonardo only
   }
   // start the Ethernet connection and the server:
   Ethernet.begin(mac, ip, SelectSlave_ETH);
   server.begin();
   Serial.print("server is at ");
   Serial.println(Ethernet.localIP());
}


void loop()
{
   // listen for incoming clients
   EthernetClient client = server.available();
   if (client)
   {
      uint8_t remoteIP[4];
      client.getRemoteIP(remoteIP);
      Serial.print("New client: ");
      Serial.print(remoteIP[0]);
      Serial.print(".");
      Serial.print(remoteIP[1]);
      Serial.print(".");
      Serial.print(remoteIP[2]);
      Serial.print(".");
      Serial.println(remoteIP[3]);

      // an http request ends with a blank line
      boolean currentLineIsBlank = true;
      while (client.connected())
      {
         if (client.available())
         {
            char c = client.read();
            Serial.write(c);
            // if you've gotten to the end of the line (received a newline
            // character) and the line is blank, the http request has ended,
            // so you can send a reply
            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("Refresh: 5");  // refresh the page automatically every 5 sec
               client.println();
               client.println("<!DOCTYPE HTML>");
               client.println("<html>");
               // output the value of each analog input pin
               for (int analogChannel = 0; analogChannel < 6; analogChannel++)
               {
                  int sensorReading = analogRead(analogChannel);
                  client.print("analog input ");
                  client.print(analogChannel);
                  client.print(" is ");
                  client.print(sensorReading);
                  client.println("<br />");
               }
               client.println("</html>");
               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(1);
      // close the connection:
      client.stop();
      Serial.println("client disonnected");
   }
}


Result:
Browser:
analog input 0 is 342
analog input 1 is 339
analog input 2 is 344
analog input 3 is 340
analog input 4 is 398
analog input 5 is 370


Serial monitor:
client disonnected
New client: 192.168.0.187
GET / HTTP/1.1
Host: 192.168.0.177
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cache-Control: max-age=0


After test with code "Simple webserver running on SD card"
#include <SPI.h>
#include <Ethernet.h>
#include <SdFat.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 0, 177); // IP address, may need to change depending on network
EthernetServer server(80);

const byte SelectSlave_ETH = 53;
const byte SelectSlave_SD = 4; // For ethernet shield
//const byte SelectSlave_SD = 5;   // For Ferduino Mega 2560
const byte SelectSlave_RFM = 69;   // For Ferduino Mega 2560

Sd2Card card;
SdFile file;
SdFile root;
SdVolume volume;

void setup()
{
   pinMode(SelectSlave_RFM, OUTPUT);
   digitalWrite(SelectSlave_RFM, HIGH);
   
   Serial.begin(9600);
   while (!Serial)
   {
      ; // wait for serial port to connect. Needed for Leonardo only
   }
   Ethernet.begin(mac, ip, SelectSlave_ETH);
   server.begin();
   Serial.print("server is at ");
   Serial.println(Ethernet.localIP());

   Serial.println("Initializing SD card...");

   if (!card.init(SPI_QUARTER_SPEED, SelectSlave_SD))
   {
      Serial.println("ERROR - SD card initialization failed!");
      return;
   }
   volume.init(&card);
   root.openRoot(&volume);

   Serial.println("SUCCESS - SD card initialized.");

   if (!file.open(&root, "index.htm", O_READ))
   {
      Serial.println("ERROR - Can't open index.htm file!");
      return;
   }
   file.close();
   Serial.println("SUCCESS - Found index.htm file.");
}

void loop()
{
   EthernetClient client = server.available();

   if (client)
   {
      boolean currentLineIsBlank = true;
      while (client.connected())
      {
         if (client.available())
         {
            char c = client.read();

            if (c == '\n' && currentLineIsBlank)
            {
               client.println("HTTP/1.1 200 OK");
               client.println("Content-Type: text/html");
               client.println("Connection: close");
               client.println();

               if (file.open(&root, "index.htm", O_READ))
               {
                  while(file.available())
                  {
                     client.write(file.read());
                  }
                  file.close();
               }
               break;
            }
            if (c == '\n')
            {
               currentLineIsBlank = true;
            }
            else if (c != '\r')
            {
               currentLineIsBlank = false;
            }
         }
      }
      delay(1);
      client.stop();
   }
}


Result:
server is at 0.0.0.0
Initializing SD card...
ERROR - SD card initialization failed!


Reset a arduino 5 times and result is same described above.

Post Number:#28 Post Tue Aug 11, 2015 2:55 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 40
Location: São Paulo
Gender: Male
National Flag:
Brazil

Format this SD as FAT and try change SPI_QUARTER_SPEED to SPI_HALF_SPEED or SPI_FULL_SPEED.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#29 Post Tue Aug 11, 2015 3:07 pm
Posts: 45
Topics: 9
Solve rating: 0
Joined: Thu Apr 10, 2014 12:21 pm
Topics: 9
Age: 39
Gender: None specified
National Flag:
Brazil
Format this SD as FAT and try change SPI_QUARTER_SPEED to SPI_HALF_SPEED or SPI_FULL_SPEED.



the SD card is already formatted in FAT32, and just write it "SPI_QUARTER_SPEED" but I will try again with SPI_HALF_SPEED or SPI_FULL_SPEED.

-------------------------------- Last edited Tue Aug 11, 2015 3:27 pm --------------------------------

Format this SD as FAT and try change SPI_QUARTER_SPEED to SPI_HALF_SPEED or SPI_FULL_SPEED.



the SD card is already formatted in FAT32, and just write it "SPI_QUARTER_SPEED" but I will try again with SPI_HALF_SPEED or SPI_FULL_SPEED.


Tested code :
#include <SdFat.h>

const byte SelectSlave_SD = 4; // For ethernet shield
//const byte SelectSlave_SD = 5;   // For Ferduino Mega 2560
const byte SelectSlave_RFM = 69;   // For Ferduino Mega 2560
const byte SelectSlave_ETH = 53;   // For Ferduino Mega 2560

Sd2Card card;
SdFile file;
SdFile root;
SdVolume volume;

float temp;
float tempe;

void setup()
{
   int16_t n;
   char buf[8];

   pinMode(SelectSlave_RFM, OUTPUT);
   pinMode(SelectSlave_ETH, OUTPUT);
   digitalWrite(SelectSlave_RFM, HIGH);
   digitalWrite(SelectSlave_ETH, HIGH);
   
   Serial.begin(9600);

   card.init(SPI_QUARTER_SPEED, SelectSlave_SD);
   volume.init(&card);
   root.openRoot(&volume);

   while(!Serial)
   {
      ; // wait for serial.
   }

   if(file.open(&root, "LOGTDIA.TXT", O_CREAT | O_APPEND | O_WRITE))
   {
      Serial.println("Writing...");
      Serial.println();

      for(temp = 27.5; temp > 22.0; temp -= 0.15)
      {
         file.print(temp);
         file.write((uint8_t*)"\0", 1);
         file.write((uint8_t*)"\r\n", 2);
      }

      for(tempe = 22.5; tempe < 28.0; tempe += 0.15)
      {
         file.print(tempe);
         file.write((uint8_t*)"\0", 1);
         file.write((uint8_t*)"\r\n", 2);
      }
      file.close();
      Serial.println("Done!");
      Serial.println();
   }
   else
   {
      Serial.println("Can't open.");
   }

   if(file.open(&root, "LOGTDIA.TXT", O_READ))
   {
      Serial.println("Reading...");
      Serial.println();
      delay(5000);
      while ((n = file.read(buf, sizeof(buf))) > 0)
      {
         Serial.println(buf);
      }
      file.close();
      Serial.println();
      Serial.print("Finished!");
   }
}
void loop()
{
}


Results:

With sd formated fat32 "SPI_QUARTER_SPEED" and w5100 module off
Serial monitor
Writing...

Done!

Reading...

27.50
27.35
27.20
27.05
26.90
26.75
26.60
26.45
26.30
....


With w5100 module off and "SPI_HALF_SPEED" or "SPI_FULL_SPEED"
Serial Monitor
can't open



With sd formated fat32 "SPI_QUARTER_SPEED" and w5100 module on
Serial monitor:
Can't open.


With module w5100 on and "SPI_HALF_SPEED" or "SPI_FULL_SPEED"
Serial monitor:
can't open

Post Number:#30 Post Tue Aug 11, 2015 3:56 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 40
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hard ..... Where I told to format as FAT32?
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#31 Post Tue Aug 11, 2015 4:09 pm
Posts: 45
Topics: 9
Solve rating: 0
Joined: Thu Apr 10, 2014 12:21 pm
Topics: 9
Age: 39
Gender: None specified
National Flag:
Brazil
Hard ..... Where I told to format as FAT32?

Hi,
Did not speak, but the SD was already with FAT and the result was the same ... then formatted as FAT32 to test, where I got this result.

Post Number:#32 Post Wed Aug 12, 2015 12:58 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 40
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

This problem is caused by conflict between SD card and W5100 both are SPI devices.

But it shouldn't happen using 2 different chip select.

You need make sure that the bridge is fine.

You did test with other SD card?

Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#33 Post Thu Aug 13, 2015 2:29 pm
Posts: 45
Topics: 9
Solve rating: 0
Joined: Thu Apr 10, 2014 12:21 pm
Topics: 9
Age: 39
Gender: None specified
National Flag:
Brazil
Hi!

This problem is caused by conflict between SD card and W5100 both are SPI devices.

But it shouldn't happen using 2 different chip select.

You need make sure that the bridge is fine.

You did test with other SD card?

Best regards.


Hi Fernando, yes, tested with other SD :(

I get a multimeter and get a pic for show test and see if I missed something.
Follow:

The Shield with bridge:
Image

Teste P53 with R16
Image

Test P53 with P4
Image

Test P53 with a side of the R16 dont welded
Image

I missed something?
I'm almost buying the ethernet shield to mount another way instead of module.

Post Number:#34 Post Fri Aug 14, 2015 5:30 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 40
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

All seems very well for me.

I don't know where's the problem exactly. :(

Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#35 Post Tue Aug 18, 2015 9:20 am
Posts: 45
Topics: 9
Solve rating: 0
Joined: Thu Apr 10, 2014 12:21 pm
Topics: 9
Age: 39
Gender: None specified
National Flag:
Brazil
HI Fernando!

I purchased a ethernet shield with SD, disabled a pin 10,11,12,13 in shield and make a bridge from pin 10 to 53 in mega and tested a codes and all works perfect!

All test only ethernet shield with sd and mega, i will test with a tft shield and screen yet.

Obs.: In all test a SD work with all speed, FULL, HALF and QUARTER.

See a results:
#include <SdFat.h>

const byte SelectSlave_SD = 4; // For ethernet shield
//const byte SelectSlave_SD = 5;   // For Ferduino Mega 2560
const byte SelectSlave_RFM = 69;   // For Ferduino Mega 2560
const byte SelectSlave_ETH = 53;   // For Ferduino Mega 2560

Sd2Card card;
SdFile file;
SdFile root;
SdVolume volume;

float temp;
float tempe;

void setup()
{
   int16_t n;
   char buf[8];

   pinMode(SelectSlave_RFM, OUTPUT);
   pinMode(SelectSlave_ETH, OUTPUT);
   digitalWrite(SelectSlave_RFM, HIGH);
   digitalWrite(SelectSlave_ETH, HIGH);
   
   Serial.begin(9600);

   card.init(SPI_FULL_SPEED, SelectSlave_SD);
   volume.init(&card);
   root.openRoot(&volume);

   while(!Serial)
   {
      ; // wait for serial.
   }

   if(file.open(&root, "LOGTDIA.TXT", O_CREAT | O_APPEND | O_WRITE))
   {
      Serial.println("Writing...");
      Serial.println();

      for(temp = 27.5; temp > 22.0; temp -= 0.15)
      {
         file.print(temp);
         file.write((uint8_t*)"\0", 1);
         file.write((uint8_t*)"\r\n", 2);
      }

      for(tempe = 22.5; tempe < 28.0; tempe += 0.15)
      {
         file.print(tempe);
         file.write((uint8_t*)"\0", 1);
         file.write((uint8_t*)"\r\n", 2);
      }
      file.close();
      Serial.println("Done!");
      Serial.println();
   }
   else
   {
      Serial.println("Can't open.");
   }

   if(file.open(&root, "LOGTDIA.TXT", O_READ))
   {
      Serial.println("Reading...");
      Serial.println();
      delay(5000);
      while ((n = file.read(buf, sizeof(buf))) > 0)
      {
         Serial.println(buf);
      }
      file.close();
      Serial.println();
      Serial.print("Finished!");
   }
}
void loop()
{
}


Serial Monitor:
Writing...

Done!

Reading...

27.50
27.35
...


---------------------------------------------------

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 0, 177); // Change the IP according to your local network

//const byte SelectSlave_SD = 5; // For Ferduino Mega
const byte SelectSlave_SD = 4; // For ethernet shield
const byte SelectSlave_ETH = 53;
const byte SelectSlave_RFM = 69;

EthernetServer server(80);

void setup()
{
   pinMode(SelectSlave_SD, OUTPUT);
   pinMode(SelectSlave_RFM, OUTPUT);
   digitalWrite(SelectSlave_SD, HIGH);
   digitalWrite(SelectSlave_RFM, HIGH);
// Open serial communications and wait for port to open:
   Serial.begin(9600);
   while (!Serial)
   {
      ; // wait for serial port to connect. Needed for Leonardo only
   }
   // start the Ethernet connection and the server:
   Ethernet.begin(mac, ip, SelectSlave_ETH);
   server.begin();
   Serial.print("server is at ");
   Serial.println(Ethernet.localIP());
}


void loop()
{
   // listen for incoming clients
   EthernetClient client = server.available();
   if (client)
   {
      uint8_t remoteIP[4];
      client.getRemoteIP(remoteIP);
      Serial.print("New client: ");
      Serial.print(remoteIP[0]);
      Serial.print(".");
      Serial.print(remoteIP[1]);
      Serial.print(".");
      Serial.print(remoteIP[2]);
      Serial.print(".");
      Serial.println(remoteIP[3]);

      // an http request ends with a blank line
      boolean currentLineIsBlank = true;
      while (client.connected())
      {
         if (client.available())
         {
            char c = client.read();
            Serial.write(c);
            // if you've gotten to the end of the line (received a newline
            // character) and the line is blank, the http request has ended,
            // so you can send a reply
            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("Refresh: 5");  // refresh the page automatically every 5 sec
               client.println();
               client.println("<!DOCTYPE HTML>");
               client.println("<html>");
               // output the value of each analog input pin
               for (int analogChannel = 0; analogChannel < 6; analogChannel++)
               {
                  int sensorReading = analogRead(analogChannel);
                  client.print("analog input ");
                  client.print(analogChannel);
                  client.print(" is ");
                  client.print(sensorReading);
                  client.println("<br />");
               }
               client.println("</html>");
               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(1);
      // close the connection:
      client.stop();
      Serial.println("client disonnected");
   }
}


Serial Monitor:
Serial:
sserver is at 192.168.0.177
New client: 192.168.0.187
GET / HTTP/1.1
Host: 192.168.0.177
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive


In Browser:
Browser:
analog input 0 is 353
analog input 1 is 343
analog input 2 is 345
analog input 3 is 349
analog input 4 is 405
analog input 5 is 371


--------------------------------------------------------

#include <SPI.h>
#include <Ethernet.h>
#include <SdFat.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 0, 177); // IP address, may need to change depending on network
EthernetServer server(80);

const byte SelectSlave_ETH = 53;
const byte SelectSlave_SD = 4; // For ethernet shield
//const byte SelectSlave_SD = 5;   // For Ferduino Mega 2560
const byte SelectSlave_RFM = 69;   // For Ferduino Mega 2560

Sd2Card card;
SdFile file;
SdFile root;
SdVolume volume;

void setup()
{
   pinMode(SelectSlave_RFM, OUTPUT);
   digitalWrite(SelectSlave_RFM, HIGH);
   
   Serial.begin(9600);
   while (!Serial)
   {
      ; // wait for serial port to connect. Needed for Leonardo only
   }
   Ethernet.begin(mac, ip, SelectSlave_ETH);
   server.begin();
   Serial.print("server is at ");
   Serial.println(Ethernet.localIP());

   Serial.println("Initializing SD card...");

   if (!card.init(SPI_FULL_SPEED, SelectSlave_SD))
   {
      Serial.println("ERROR - SD card initialization failed!");
      return;
   }
   volume.init(&card);
   root.openRoot(&volume);

   Serial.println("SUCCESS - SD card initialized.");

   if (!file.open(&root, "index.htm", O_READ))
   {
      Serial.println("ERROR - Can't open index.htm file!");
      return;
   }
   file.close();
   Serial.println("SUCCESS - Found index.htm file.");
}

void loop()
{
   EthernetClient client = server.available();

   if (client)
   {
      boolean currentLineIsBlank = true;
      while (client.connected())
      {
         if (client.available())
         {
            char c = client.read();

            if (c == '\n' && currentLineIsBlank)
            {
               client.println("HTTP/1.1 200 OK");
               client.println("Content-Type: text/html");
               client.println("Connection: close");
               client.println();

               if (file.open(&root, "index.htm", O_READ))
               {
                  while(file.available())
                  {
                     client.write(file.read());
                  }
                  file.close();
               }
               break;
            }
            if (c == '\n')
            {
               currentLineIsBlank = true;
            }
            else if (c != '\r')
            {
               currentLineIsBlank = false;
            }
         }
      }
      delay(1);
      client.stop();
   }
}


Serial Monitor:
server is at 192.168.0.177
Initializing SD card...
SUCCESS - SD card initialized.
SUCCESS - Found index.htm file.


In Browser:
// Save this file on SD card as index.htm
Hello world!
This page is stored in a SD card plugged on Arduino

Visit my website: www.ferduino.com

Code adapted by Fernando Garcia


I do not know if the module was faulty or if there was some other problem.

I will test with tft shield and screen and post de result here.

Thanks for the cooperation and patience.
:D :D :D :D :D :D :D

Post Number:#36 Post Thu Aug 27, 2015 9:09 am
Posts: 45
Topics: 9
Solve rating: 0
Joined: Thu Apr 10, 2014 12:21 pm
Topics: 9
Age: 39
Gender: None specified
National Flag:
Brazil
Hi Again Fernando! :)

I tried to stack the ethernet shield_SD, shield_tft and screen but is not good, the plates do not fit completely.

I will try to connect the ethernet shield without piling, connecting wired up to the mega.

You can say the pin in ethernet shield i need for turn on wire to connect to mega?

Thx

Post Number:#37 Post Thu Aug 27, 2015 10:42 am
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 40
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

Connect the ICSP header and pin 10 to pin 53.

I think better make this "half shield".

Image


Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#38 Post Fri Aug 28, 2015 3:04 pm
Posts: 45
Topics: 9
Solve rating: 0
Joined: Thu Apr 10, 2014 12:21 pm
Topics: 9
Age: 39
Gender: None specified
National Flag:
Brazil
Thx Fernando, i will verify.

Using this shield, I leave the pin bridge 4 to R 16 in TFT Shield or remove that bridge and welding the R16 on the PCB.

Post Number:#39 Post Fri Aug 28, 2015 4:16 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 40
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

Remove the bridge and pins 50, 51, 52 and 53 on TFT shield.

viewtopic.php?f=24&t=36

Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#40 Post Tue Sep 01, 2015 9:42 am
Posts: 45
Topics: 9
Solve rating: 0
Joined: Thu Apr 10, 2014 12:21 pm
Topics: 9
Age: 39
Gender: None specified
National Flag:
Brazil
Hi Fernando!

THx for all!


I could leave everything running smoothly.
Mega> ethernet Shield_SD> TFT shield> Screen
I did the assembly of the ethernet shield without piling, for I had designed the box to use a module and not the ethernet shield, as I had problems with the module and migrated pro ethernet shield everything was resolved.

I had asked about the link and you gave me to connect ISCP header, did everything right but still gave error in SD.

When I went to audition with ethernet shield stacked in mega everything worked, but with the ethernet shield attached by wires not.

I researched the topic and saw the friend: viewtopic.php?f=18&t=238
which was set up the way I was trying and the photo I saw that out the ISCP header and wire PIN10 had another wire attached, the picture could not see where the pin was on and I was searching on google where I found this site telling you how to connect wired ethernet shield, https://zugiduino.wordpress.com/2012/07 ... et-shield/
Out the pins that were already connected to the site reported connect the ethernet shield Pin4 in the mega Pin4, I made this connection and everything worked perfectly.

So for this type of function call, should call the ISCP header, pin 10 ethernetshiel in mega pin53 and pin 4 ethernet_shield on pin 4 mega.

I've done assembly and communication with the Joyreef using port 5000 and all funcinou, including changing some config by joyreef and then looking straight at the mega really saved the changes I made and everything was there except.

I would ask thank you once again for your help and patience.

My box is already mounted, the box also with the metering, the circuit of temp sensors, all set.
As the main thing now is working perfectly I will take the next step to make the assembly and testing of modules dosing_P, temp, LED and timer.

THX!

PreviousNext



Return to DIY Ferduino controller





Who is online

Users viewing this topic: No registered users and 0 guests