Go Down

Topic: Automated Reptile Control System(webserver, Data Logging, RTC and much more) (Read 41770 times) previous topic - next topic

wallaceb

sorry, forgot to upload the code:

https://www.dropbox.com/s/eyg6vdv6dt0ut9b/Arduino5-26-13.rar

let me know if you have any issues.

wallaceb

ok, i have made several changes


1.) corrected an issue where the heat lamp would not properly turn off
2.) modified the system so the images used on the main page to signify if the relays are on/off and if the temperature sensors are good/bad are no longer pulled off my photobucket account, but are pulled directly off the SD card.

latest code, now "officially" at version 1.1 dated 6/6/3013 can be found at https://www.dropbox.com/s/cun7nqg9qrlfj9k/1.1%20-%206-6-2013.zip


mkcinek

Hi,

Just wondering if you made any changes to the sketch?
Are you working on other great  arduino projects?
Thanks!

wallaceb


Hi,

Just wondering if you made any changes to the sketch?
Are you working on other great  arduino projects?
Thanks!


i have not made any changes. it has been working exactly as i want, and i have not found any issues after running constantly for 2.5 months without interruption.

i have created another project here:
http://forum.arduino.cc/index.php?topic=183000.0

barbudancristian

Hello WALLACEB,

First of all it is the best arduino project seen by me. You did a good job.
I have some issue and I dont know where is the problem and maybe you can help me:

In both situation I only use the arduino mega + RTC + Ethernet shiel + microSD 4GB

1. In first situation after I upload webserverinit I see on serial monitor that all parameters are ok, after that I upload the webserver code and also this one on serial monitor is ok. I ping the IP and is working very well. The isue is after I browsing thrue webserver pages the webpage (after 1-2 min) is not responding.

2. After one week of pause I re-upload all the codes again because in this week I use arduino for other projects and the situation is like this: arduino respond on ping, did not open any webpage anymore and few seconds after I try to open the webpage is start pulsing fast the orange led on the ethernet shiel (the one near pin 13) and I can't do nothing.

It is any problem because I did not conect any temp senzor yet and only I want to play with the webpage?

Please advice me.

Thank you very much
Dan

wallaceb


Hello WALLACEB,

First of all it is the best arduino project seen by me. You did a good job.
I have some issue and I dont know where is the problem and maybe you can help me:

In both situation I only use the arduino mega + RTC + Ethernet shiel + microSD 4GB

1. In first situation after I upload webserverinit I see on serial monitor that all parameters are ok, after that I upload the webserver code and also this one on serial monitor is ok. I ping the IP and is working very well. The isue is after I browsing thrue webserver pages the webpage (after 1-2 min) is not responding.

2. After one week of pause I re-upload all the codes again because in this week I use arduino for other projects and the situation is like this: arduino respond on ping, did not open any webpage anymore and few seconds after I try to open the webpage is start pulsing fast the orange led on the ethernet shiel (the one near pin 13) and I can't do nothing.

It is any problem because I did not conect any temp senzor yet and only I want to play with the webpage?

Please advice me.

Thank you very much
Dan


specifically off the top of my head, it sounds a lot like the issues i had when accessing the web pages from my smart phone's browser. in andriod, the stock browser would always cause the arduino Ethernet shield to not respond anymore. If i used firefox on my andriod, then everything worked fine.

with that said, i have used IE and firefox without issues. what browser are you using?

what i would do to see what the issue is to add a serial print command at the beginning of every function. that way you can see how the functions are called, and then you can see which function the arduino stops responding at.

barbudancristian

Thank you for fast response.
I use Safari on iMac and also on the same iMac I use Chrome. I will test with Firefox today.

Question: Is mandatory to connect the sensors and the relay shield or the webserver must work also without this stuff connected? I did not connect yet the sensors because right now I have only two for temp and only relay shield with 4 relays....

Thank you

wallaceb


Thank you for fast response.
I use Safari on iMac and also on the same iMac I use Chrome. I will test with Firefox today.

Question: Is mandatory to connect the sensors and the relay shield or the webserver must work also without this stuff connected? I did not connect yet the sensors because right now I have only two for temp and only relay shield with 4 relays....

Thank you


everything else will still work without sensors or the relays attached. The main system screen will just show all the sensors as offline by showing red circles and the temperatures will all show zero. if no humidity sensor is connected, the feedback will display random results depending on what the analog input is floating at.

i wonder if the Safari might be causing the issues, hopefully firefox will fix it. I have not tried chrome on my systems. i assume there is some large bug in how the code handles the different browser HTTP traffic, but i have not figured it out.

barbudancristian

You have right with Firefox work fine. Please tell me I try to translate the webpage in my language and I deal with strange issue.
You make for View Recorded Data one HTML. I try to translate it in htmldata.h changing the code into this:
"<Table border = \"1\">"
         "<tr>"
            "<td align = \"center\">Date</td>"
            "<td align = \"center\">Time</td>"
            "<td align = \"center\">Temperatura 1</td>"
            "<td align = \"center\">Temperatura 2</td>"
            "<td align = \"center\">Temperatura 3</td>"
            "<td align = \"center\">Medie Temperatura Ambient</td>"
            "<td align = \"center\">Umiditate Medie</td>"
            "<td align = \"center\">Releu 1</td>"
            "<td align = \"center\">Releu 2</td>"
            "<td align = \"center\">Releu 3</td>"
            "<td align = \"center\">Releu 4</td>"
            "<td align = \"center\">Releu 5</td>"
            "<td align = \"center\">Releu 6</td>"
         "</tr>";
After I re-upload the code, the HTML report is no changed on table header showing me like the original one.
Please tell me where is the mistake.

Thanks

barbudancristian

It's OK now the header translation for Recorded data table. The code for this was in web server.ino not in htmldata.h . But why is also in the htmldata.h ?
Another questions:
1. Main page "System Overview" have an refresh time? seems to remain unrefreshed and I have to right click on it and choose Reload page to see any change in temp .
2. Can I change the date format from M/D/Y to D/M/Y like we use in our country?

Thank you again and sorry to kill you with those question.

P.S. I see when I chose to open recorded data file that the system give command to relay for short time. Why when is open the html page with the table the system act the relays?

wallaceb


You have right with Firefox work fine. Please tell me I try to translate the webpage in my language and I deal with strange issue.
You make for View Recorded Data one HTML. I try to translate it in htmldata.h changing the code into this:
"<Table border = \"1\">"
         "<tr>"
            "<td align = \"center\">Date</td>"
            "<td align = \"center\">Time</td>"
            "<td align = \"center\">Temperatura 1</td>"
            "<td align = \"center\">Temperatura 2</td>"
            "<td align = \"center\">Temperatura 3</td>"
            "<td align = \"center\">Medie Temperatura Ambient</td>"
            "<td align = \"center\">Umiditate Medie</td>"
            "<td align = \"center\">Releu 1</td>"
            "<td align = \"center\">Releu 2</td>"
            "<td align = \"center\">Releu 3</td>"
            "<td align = \"center\">Releu 4</td>"
            "<td align = \"center\">Releu 5</td>"
            "<td align = \"center\">Releu 6</td>"
         "</tr>";
After I re-upload the code, the HTML report is no changed on table header showing me like the original one.
Please tell me where is the mistake.

Thanks



to translate, you should not have to edit the htmldata.h file, but the webserver file.

look for this code:

Code: [Select]
if (data_log_enabled == 1 && ((SDUSEDSPACE() / volumesize) * 100) <99 && abs(((second + (minute*60) + (hour*3600)) - last_time_data_saved)) >= data_log_period){//is data logging enabled by the user and there is space available on the card?
      last_time_data_saved = (second + (minute*60) + (hour*3600));
      char newfile[12] = "";//variable for the log file name
      sprintf(newfile,"%.2d%.2d%.2d.htm", month, dayOfMonth, year);//generate the file name in the followin format "010513.htm" for a file created on January 13th, 2013
      if (counter != dayOfMonth){//if the day is a new day, then we need to add the header information to the log file
        counter = dayOfMonth;//set the counter to the current day so the system knows we have gon through this code before until the next day
        if (!file.open(root,newfile, O_READ)){//does the file already exist?
          file.open(root,newfile , O_CREAT | O_APPEND | O_WRITE); // no the file does not exist, lets create the file
          wdt_reset();
          //add the header information to the log file
          file.print(F("<Table border = \"1\">"
"<tr>"
"<td align = \"center\">Date</td>"
"<td align = \"center\">Time</td>"
"<td align = \"center\">Cold Side Ground Temperature</td>"
"<td align = \"center\">Middle Ground Temperature</td>"
"<td align = \"center\">Hot Side Ground Temperature</td>"
"<td align = \"center\">Average Ambient Temperature</td>"
"<td align = \"center\">Average Humidity</td>"
"<td align = \"center\">Cold Side Ground Heater Status</td>"
"<td align = \"center\">Middle Ground Heater Status</td>"
"<td align = \"center\">Hot Side Ground Heater Status</td>"
"<td align = \"center\">Humidifier Status</td>"
"<td align = \"center\">Heat Lamp Status</td>"
"<td align = \"center\">UV Light Status</td>"
"</tr>"));
           file.close();
           wdt_reset();
        }else{
          //yes the file exists, close the file and move on
          file.close();
          wdt_reset();
        }
      }else{
        //we hae already created the file, now we need to append the log data to it as the headers are already written to it.
        file.open(root,newfile , O_APPEND | O_WRITE); // Tested OK
        wdt_reset();
        file.print(F("<tr>"));
        file.print(F("<td align = \"center\">"));
        sprintf(newfile, "%.2d/%.2d/%.2d", month, dayOfMonth, year);
        file.print(newfile);
        file.print(F("</td>"));
        file.print(F("<td align = \"center\">"));
        sprintf (newfile, "%.2d:%.2d:%.2d", hour, minute, second);
        file.print(newfile);
        file.print(F("</td>"));
        file.print(F("<td align = \"center\">"));
        file.print(cold_side_temp_whole);
        file.print(".");
        file.print(cold_side_temp_fract);
        file.print(F("</td>"));
        file.print(F("<td align = \"center\">"));
        file.print(middle_temp_whole);
        file.print(".");
        file.print(middle_temp_fract);
        file.print(F("</td>"));
        file.print(F("<td align = \"center\">"));
        file.print(hot_side_temp_whole);
        wdt_reset();
        file.print(".");
        file.print(hot_side_temp_fract);
        file.print(F("</td>"));
        file.print(F("<td align = \"center\">"));
        file.print((((float)ambient_temp_2_whole + (float)ambient_temp_1_whole + ((float)ambient_temp_2_fract / 100) + ((float)ambient_temp_1_fract / 100))/2));
        file.print(F("</td>"));
        file.print(F("<td align = \"center\">"));
        file.print(RH);
        file.print(F("</td>"));
        file.print(F("<td align = \"center\">"));
        if (cold_side_status == 1){
          file.print(F("ON"));
        }else{
          file.print(F("OFF"));
        }
        file.print(F("</td>"));
        file.print(F("<td align = \"center\">"));
        wdt_reset();
        if (middle_status == 1){
          file.print(F("ON"));
        }else{
          file.print(F("OFF"));
        }
        file.print(F("</td>"));
        file.print(F("<td align = \"center\">"));
        if (hot_side_status == 1){
          file.print(F("ON"));
        }else{
          file.print(F("OFF"));
        }
        file.print(F("</td>"));
        file.print(F("<td align = \"center\">"));
        if (humidifier_status == 1){
          file.print(F("ON"));
        }else{
          file.print(F("OFF"));
        }
        file.print(F("</td>"));
        file.print(F("<td align = \"center\">"));
        if (heat_lamp_status == 1){
          file.print(F("ON"));
        }else{
          file.print(F("OFF"));
        }
        file.print(F("</td>"));
        file.print(F("<td align = \"center\">"));
        if (UV_Light_status == 1){
          file.print(F("ON"));
        }else{
          file.print(F("OFF"));
        }
        file.print(F("</td>"));
        file.print("</tr>");
        file.close();
        wdt_reset();
      }
    }


and edit the table header entries there. i was going to add that to the htmldata.h file, but never implemented it  :smiley-roll-sweat:



wallaceb


It's OK now the header translation for Recorded data table. The code for this was in web server.ino not in htmldata.h . But why is also in the htmldata.h ?
Another questions:
1. Main page "System Overview" have an refresh time? seems to remain unrefreshed and I have to right click on it and choose Reload page to see any change in temp .
2. Can I change the date format from M/D/Y to D/M/Y like we use in our country?

Thank you again and sorry to kill you with those question.

P.S. I see when I chose to open recorded data file that the system give command to relay for short time. Why when is open the html page with the table the system act the relays?


as i said, i added the entry in the htmldata.h file, but never implemented the code to retrieve it from PROGMEM.

none of the html pages update on their own. however it is very easy to make them update on their own if you edit the html data by adding code in the following format

Code: [Select]
<html>
<head>
<title>HTML in 10 Simple Steps or Less</title>
<meta http-equiv="refresh" content="5" >
</head>
<body>
</body>
</html>


the line

Code: [Select]
<meta http-equiv="refresh" content="5" >

instructs your web browser to refresh every 5 seconds. as you can see, this line needs to be added within the HTML header and not the body. if you want to change the date format, you will have to edit the following code within the

void sendSubstitute(EthernetClient client, int nUriIndex, int nSubstituteIndex, BUFFER & requestContent)

function

Code: [Select]

           sendProgMemAsString(client, (char*)pgm_read_word(&(basic_table[32])));  //client.print("  ");
           client.print(month);
           sendProgMemAsString(client, (char*)pgm_read_word(&(basic_table[10])));  //client.print("/");
           client.print(dayOfMonth);
           sendProgMemAsString(client, (char*)pgm_read_word(&(basic_table[11])));  //client.print("/20");
           client.println(year);
           wdt_reset();
           break;


to make it into your arrangement, the lines "client.print(month);" and "client.print(dayOfMonth);" need to be swapped. you will have to do this for every page, but it all in the same location. This will change the date format in the upper right of all the pages. to change the format in the log file, look for this line

Code: [Select]
sprintf(newfile,"%.2d%.2d%.2d.htm", month, dayOfMonth, year);//generate the file name in the followin format "010513.htm" for a file created on January 13th, 2013

and swap the variables "month" and "dayOfMonth"



when you are downloading a large log file, because it may take several minutes, i coded the system to shut down three of the relays. in my system, those relays power heaters that heat up fairly fast. if they stayed on during a long download, the temperature would get too high and i did not want that.

if you do not like that, look in the "void GETETHERNET(void)" function and completely remove the following lines of code:

Code: [Select]
if (strcmp(global_pUri,"/on.png")==0){
         }else if (strcmp(global_pUri,"/off.png")==0){
         }else if (strcmp(global_pUri,"/green.png")==0){
         }else if (strcmp(global_pUri,"/red.png")==0){
         }else{
           digitalWrite(cold_side_ground_pin, HIGH);
           digitalWrite(middle_side_ground_pin, HIGH);
           digitalWrite(hot_side_ground_pin, HIGH);//relay 1 - cold side ground
           cold_side_status = 0;
           hot_side_status = 0;
           middle_status = 0;
         }


now, when you are downloading a log file, the relays will remain in what ever state they were in when the log file download started until the download is done.

mkcinek

Hi,

Finally somebody pointed the same problem I was having with safari on imac/iphone.. So adding <meta http-equiv="refresh" content="5" > line to refresh page would make it possible to view it on safari ?thanks

wallaceb


Hi,

Finally somebody pointed the same problem I was having with safari on imac/iphone.. So adding <meta http-equiv="refresh" content="5" > line to refresh page would make it possible to view it on safari ?thanks



unfortunately no, adding that line will simply make the page auto-refresh. i do not know why the system does not seem to work when using browsers other than IE or firefox  =( =( =(

Go Up