Show Posts
Pages: [1]
1  Using Arduino / Networking, Protocols, and Devices / Re: web server to read file from SD card and show its content as HTML on: January 08, 2013, 05:27:33 pm
Thank you very much Tim for your support and patience,

after hours of debugging I found out that the file does not open from the first time I call "SD.open" , but does open correctly the second time,

I have tried to delay some time after the open call and before the read call , but with no success..

so I added the open code once again right after the first call and it's working  smiley :
Code:
          File fh = SD.open("index.htm");
          fh = SD.open("index.htm");
That seems odd I know , but still better than nothing..
2  Using Arduino / Networking, Protocols, and Devices / Re: web server to read file from SD card and show its content as HTML on: January 08, 2013, 04:37:16 pm
Thanks you all..

The SRAM is 657  right before the open file failed..
and 813 right before the end of setup()....


3  Using Arduino / Networking, Protocols, and Devices / Re: web server to read file from SD card and show its content as HTML on: January 08, 2013, 03:37:52 pm
I'm using Arduino Uno Rev3..

can I test the SRAM some how ?

or is there is away to reset the arduino to its "factory settings"?
4  Using Arduino / Networking, Protocols, and Devices / Re: web server to read file from SD card and show its content as HTML on: January 08, 2013, 03:18:00 pm
Does this work for you?
no !!!

The web page is blank, and I got "file open failed" error on the serial monitor:""

Code:
Starting SD..ok
Ready
Client request: GET / HTTP/1.1

POST data:
Sending response
file open failed
done
this is driving me crazy !!! I have tried tens of codes with no lock ...
5  Using Arduino / Networking, Protocols, and Devices / Re: web server to read file from SD card and show its content as HTML on: January 08, 2013, 01:19:34 pm
Could you describe the error, please?

-br

I cannot open a file for reading from SD card when a client is connected to a web server on my arduino UNO r3 with Ethernet Shield ,
the full code on the first post..

Thank you..
6  Using Arduino / Networking, Protocols, and Devices / Re: web server to read file from SD card and show its content as HTML on: January 08, 2013, 12:40:27 pm
I'm sure the file exists because the same exact code is working OK on startup():
and the file is only about 21 words ..

Code:
void setup()
{
 
  Ethernet.begin(mac, ip);
  server.begin();

  Serial.begin(9600);
 
  Serial.print("Initializing SD card...");
  pinMode(10, OUTPUT);
 
   if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

          myFile = SD.open("datalog.csv");
         if (myFile) {
         Serial.println("datalog.csv:");
   
        // read from the file until there's nothing else in it:
        while (myFile.available()) {
           Serial.println(myFile.read());// ################ I GOT THE FILE CONTENTS ON THE SERIAL MONITOR SCREEN
        }
        myFile.close();
      } else {
        Serial.println("error opening datalog.csv");
      }
}
7  Using Arduino / Networking, Protocols, and Devices / Re: web server to read file from SD card and show its content as HTML on: January 08, 2013, 10:59:47 am
Thank you Tim for your answer ,
I have changed my code to set them both HIGH before the end of setup()..
but still having the same error !
8  Using Arduino / Networking, Protocols, and Devices / web server to read file from SD card and show its content as HTML on: January 08, 2013, 06:16:28 am
I'm working on a monitoring project that logs some data to the SD card of the official Ethernet Shield as csv file, I want to show the logs contents on a web page that is produced by the arduino , but when I try to open the csv file for reading after the client is connected to the server , I get an error but when I try to open it on startup its working OK.

I have read that I should switch between ethernet SS PIN and SD card SS pin but I cannot manage to make it work !!

Is it possible to switch ethernet SS pin while the client is connected and then switch it back after reading from SD card without losing the client connection??

here is my code :
Code:
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,2, 230);
EthernetServer server(80);

File myFile;

void setup()
{
  
  Ethernet.begin(mac, ip);
  server.begin();

  Serial.begin(9600);
  
  Serial.print("Initializing SD card...");
  pinMode(10, OUTPUT);
  
   if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
}


void loop()
{
EthernetClient client = server.available();
  if (client)
  {
    boolean current_line_is_blank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        if (c == '\n' && current_line_is_blank) {
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<h2>CSV Data : </h2>");

         // csv file data
         myFile = SD.open("datalog.csv");
         if (myFile) {
         Serial.println("datalog.csv:");
  
        // read from the file until there's nothing else in it:
        while (myFile.available()) {
           client.println(myFile.read());
        }
        myFile.close();
      } else {
        Serial.println("error opening datalog.csv"); // ################### I GOT THIS ERROR
      }

          break;
        }
        if (c == '\n') {
          current_line_is_blank = true;
        } else if (c != '\r') {
          current_line_is_blank = false;
        }
      }
    }
    delay(1);
    client.stop();
  }

}

9  Using Arduino / Sensors / Re: What is the best product counter sensor? on: January 03, 2013, 01:42:16 am
Thank you robtillaart  for your reply..

It's an interlock/bricks/tiles plant, every packet is a 1 meter^3 of packed  palletized bricks/tiles or other cement products,
the speed is slow, a bout 15-20 packets every minute, and the distance between 2 packets is 50cm...

10  Using Arduino / Sensors / What is the best product counter sensor? on: January 02, 2013, 01:02:33 pm
I'm working in a project that count the number of packages out of a production unit..
I have read a lot of articles that explain 2 kind of sensors :

1- IR Emitter - Receiver .
2- Laser Diode - Photocell.

I need the most accurate and executive solution that takes the following into consideration :

- The project will work almost 24/7.
- The project will be exposed to dust,noise,ambient light and vibration.

Thank you very much and sorry for my bad English >_<..
Pages: [1]