Arduino Forum

Topics => Home Automation and Networked Objects => Topic started by: wallaceb on Jan 04, 2013, 07:10 pm

Title: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jan 04, 2013, 07:10 pm
UPDATE: NOW SUPPORTS EITHER ARDUINO WIFI 101 SHIELD OR ARDUINO ETHERNET SHILED
REFER TO THIS POST FOR DETAILS SHARED BETWEEN THE TWO PROJECTS
REFER TO POST #3 FOR DETAILS ON JUST THE WIFI VERSION

i have been working on a home project to automate the control of my ball python cage. the cage has three under-the-tank heaters, humidifier, heat lamp, and UV light.

the arduino system is composed of the following:
Arduino Mega 2560 (http://www.amazon.com/gp/product/B006H0DWZW/ref=oh_details_o09_s01_i00?ie=UTF8&psc=1)
Arduino Ethernet Shield (http://www.amazon.com/gp/product/B006UT97FE/ref=oh_details_o09_s03_i00?ie=UTF8&psc=1)
RTC Module (http://www.amazon.com/gp/product/B004G2IPOG/ref=oh_details_o08_s00_i00?ie=UTF8&psc=1)
5x onewire temperature sensors  (http://www.amazon.com/gp/product/B008RIOGP2/ref=oh_details_o04_s00_i00?ie=UTF8&psc=1)
2x humidity sensors  (http://sensing.honeywell.com/product%20page?pr_id=53944)
6 relays (http://www.amazon.com/gp/product/B0057OC5WK/ref=oh_details_o09_s00_i00?ie=UTF8&psc=1)
SD card in the Ethernet shield  (http://www.amazon.com/gp/product/B001CQT0X4/ref=oh_details_o07_s00_i00?ie=UTF8&psc=1)
7.5 volt power for the arduino  (http://www.amazon.com/gp/product/B000Z31G3M/ref=oh_details_o04_s00_i00?ie=UTF8&psc=1)
5 volt power for the relay coils (http://www.amazon.com/gp/product/B001PUSERA/ref=oh_details_o09_s01_i01?ie=UTF8&psc=1)
2x humidifier  (http://www.amazon.com/gp/product/B000634980/ref=oh_details_o04_s00_i00?ie=UTF8&psc=1)
humidifier air pump  (http://www.amazon.com/Tetra-77850-Whisper-Pump-100-Gallon/dp/B004PB8SRM/ref=sr_1_10?ie=UTF8&qid=1370537956&sr=8-10&keywords=aquarium+air+pump)
3x under-the-tank heaters  (http://www.amazon.com/gp/product/B0010OP4CY/ref=oh_details_o04_s00_i00?ie=UTF8&psc=1)
heat lamp  (http://www.amazon.com/gp/product/B000TZ1XH0/ref=oh_details_o00_s00_i00?ie=UTF8&psc=1)

with airtight / water tight Hoffman enclosure (ebay, no link available)


the system is controlled and monitored through a web server running on the arduino. the system has 9 different pages:
1.) System Overview -- allows the user to see the current temperatures from the 5 onewire sensors, the average cage ambient temperature (average of sensors 4 and 5), to see if the sensors are currently functioning, the status of the relays (on/off) and the average humidity within the cage
The images used to signify if the relays are on/off as well as the images used to signify if the temperature sensors are good/bad are stored on the SD card and read off the SD card.

(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/page1_zps2cc38d0b.png)

2.)Temperature Adjust - allows the user to configure the system to use either degrees F or degrees C as the temp scale. It also allows the user to control the on/off temperature settings for the three under-the-tank heaters connected to relays 1 through 3, and the heat lamp connected to relay 4. the settings can be configured for both day-time and night-time to simulate lower temperatures at night if the user desires
all data entry areas have logic to determine if the entered values are acceptable. if they are not, the web-page details the issue the user
all user settings are saved to EEPROM

(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/page2part1_zps1b344ec2.png)
(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/page2part2_zps9d52c2d0.png)

3.)Humidity Adjust - allows the user to configure the system's humidifier on/off settings for both day time and night time
all data entry areas have logic to determine if the entered values are acceptable. if they are not, the web-page details the issue the user
all user settings are saved to EEPROM

(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/page3_zps200ed17e.png)

4.)Date/Time Adjust - allows the user to set the system's day, month, year, day of the week, and time zone. the system also allows for the hour, minute, and seconds to be updated over the internet through a NTP server. the code is written so a specific IP is not required for the NTP server. instead it uses DNS to resolve the IP of time.nist.gov as it is resolved to all of the server addresses in a round-robin sequence to equalize the load across all of the servers. the system automatically always connects to the internet every 24 hours to update its time again to correct for any drift associated with the RTC
The page also allows the user to configure when the UV light turns off and on signifying when the system considers it either "day time" or "night time"
all user settings are saved to EEPROM

(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/page4_zps1ef1224f.png)


5.)Data Logging Adjust - allows the user to enable or disable data logging, allowing the system to log one sample every 10, 20, 30, 40, 50, or 60 seconds.
This page also explains all the details of the SD card inserted into the Ethernet shield
if no SD card is present, it will tell you and prevent the user from data logging.
if the SD card is present, but not formatted, it will tell the user and prevent data logging
if the SD card is present, formatted, but cannot be accessed for one reason or another it will tell the user and prevent data logging
it tells the user the size of the SD card in kilobytes and megabytes
it tells the user the amount of space used on the SD card in both kilobytes and megabytes, verified to read the same value as windows explorer
it has a progress bar that shows the percentage of SD card space used
data logging enable/disable settings are not saved to EEPROM. data logging must be enabled manually every time the system powers up.
allows for the log files to be individually deleted off the SD card if desired (image does not show this part of the form as i have not updated the image i am using in this post ;) ). at 1 sample per 10 seconds, 24 hours of recording equates to approximately 3250 plus or minus 20 kB.

(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/page5_zpsdaadbdf5.png)

6.)View Recorded Data - lists all the log files on the SD card so the data can be viewed and downloaded by the user. the system creates a different log file every day of logging is enabled. the files are named for the month, day and year so the user can easily look back at what happened with the system at a specific time with ease.

(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/page6part1_zps4b177976.png)

(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/page6part2_zpse63a1bf4.png)

7.)I/O Setup-  allows the user to decide how the 6 relays are controlled - either automatic, or manual. each relay can be configured independently. when the relay is set for manual control, then the user can press a button to turn it on or off
when the system powers up, all relays are configured to be controlled by the system by default. any time the system restarts, resets, or is power cycled, the relays would have to be set back to manual control if manual control is desired.

(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/page7part1_zpsb2a750f9.png)
(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/page7part2_zpsde7d59e8.png)
(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/page7part3_zps5e71bed8.png)

8.)Network Setup - allows the user to configure the system for static settings or DHCP. even if using DHCP, the system shows the user the IP address, subnet mask, default gateway, and DNS server. if the system is using static settings, all user settings are saved to EEPROM

(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/page8_zps324b9223.png)

9.)System Information - gives a system up-time counter in years, months, days, hours, seconds. also displays the MAC address of the system. Displays if there were any instances in which the temperature sensors malfunctioned. any time any sensor malfunction is detected, the counter will increase. The system will also send an e-mail indicating to the user that a sensor is not working and needs to be checked. finally, displays the available system RAM

latest code revision:
https://www.dropbox.com/s/uxf89wcth826cj0/2.0%206-6-2016%20experimental.zip?dl=0

NOTE: POST WAS UPDATED WITH THE LATEST INFORMATION AVAILABLE. PREVIOUS INFORMATION WAS REPLACED AS REQUIRED.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: draythomp on Jan 04, 2013, 07:43 pm
Very nice.  You must really like that snake!  Or, maybe you hate having to adjust the environment every 15 minutes.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: robtillaart on Jan 04, 2013, 08:47 pm
Looks very well done (+1),

(nitpicking -  Automated Reptile Environment Control System  - makes a better acronym  arecs that's an anagram of scare ;)
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jan 04, 2013, 09:20 pm
WIFI VERSION:


i am waiting for my wifi 101 shield to arrive. since the wifi shield does not have an SD card slot like the ethernet shield did, and i wanted to clean up the physical look of my work, i have used a mega protoshield to hold an SD card board, the RTC, a and all of the headers for my temperature probes.

you can see what i designed here (https://www.dropbox.com/s/b55sng2t9wxgq8y/Visio-Drawing1.pdf?dl=0):

and you can see the result here (https://www.dropbox.com/s/rnk09k2js2tg7ku/IMG_20160616_115648.jpg?dl=0):

you can also see what it looks like when paired with my existing ethernet shield (https://www.dropbox.com/s/edtb7wbqmv89x24/IMG_20160617_102241.jpg?dl=0).

i made sure to use pin 5 for my new protoboard SD chip select pin so it did not interfere with the SD shield.

please note! what i have shown above is electrically not compatible with the ethernet based project unless you edit the pin assignments used by the temperature probes to the following:

Code: [Select]

#define CSG1wirepin 38
#define MSG1wirepin 44
#define HSG1wirepin 42
#define AA11wirepin 46
#define AA21wirepin 48


and change the SD card initialization to the following if you do not want to use the SD card in the ethernet shield:

Code: [Select]
if (!card.init(0, 5)){




ORIGIONAL RESPONSE BELOW, THIS POST HAS BEEN EDITED TO ADD MORE DETAIL ON NEW WIFI VERSION OF THE SYSTEM
Very nice.  You must really like that snake!  Or, maybe you hate having to adjust the environment every 15 minutes.
i like making things such as this, but need a reason.... cough.... excuse ;)
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: blastboot on Jan 18, 2013, 11:57 am
Hello, really nice project!
Can you explain how can you positioning the values into the tables of your html pages?
Do you need to refresh the page everytime you want see if there was a change in the reads, or the page is always "connected" to arduino?

THANKS!!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jan 21, 2013, 12:56 am

Hello, really nice project!
Can you explain how can you positioning the values into the tables of your html pages?
Do you need to refresh the page everytime you want see if there was a change in the reads, or the page is always "connected" to arduino?

THANKS!!


currently the code is written so you need to refresh the page any time you want to see what the current readings are. it would be very easy to add the HTML "refresh" tag to the code to get it to auto refresh.

i have finished my enclosure and posted some images below:

(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/IMAG0022_zps0dff35ae.jpg)
(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/IMAG0023_zps6c56c15c.jpg)
(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/IMAG0025_zps5729ed15.jpg)
(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/IMAG0026_zps9d5abfc0.jpg)
(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/IMAG0027_zps39ecfd08.jpg)
(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/IMAG0028_zpsb096de7e.jpg)
(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/IMAG0029_zps1432d847.jpg)
(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/IMAG0030_zpsef6b7fd8.jpg)
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jan 21, 2013, 12:57 am
i attached my code and the different libraries i used

some things are not done, and i know if a few bugs that need to be fixed, but i would say 98% of everything is working fine.

note: written in IDE version 1.0
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: robtillaart on Jan 21, 2013, 09:22 pm

Decent piece of work!  be proud!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: gvaf on Jan 30, 2013, 06:36 am
Hi everyone
"wallaceb" you have done a very good job here.

Question: It possible this code to work on UNO ?

Thanks
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jan 30, 2013, 07:33 pm

Hi everyone
"wallaceb" you have done a very good job here.

Question: It possible this code to work on UNO ?

Thanks



unfortunately no. the entire sketch currently uses 106,000 bytes of FLASH, too much for the UNO. However with that said, most of the 106,000 bytes is the PROGMEM storage of the HTML pages. If the sketch was somehow changed to pull the HTML off the SD card instead, it might fit, but i have not checked.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mxing on Feb 14, 2013, 01:49 am
Is it me or is there an issue with the Arduino.zip file?  When I try to open it, it seems it is invalid...
I could benefit from this code.  I'm looking for tabulating code to be able to show status of things and then yet to be able to set values via the web.

tb
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Feb 14, 2013, 04:28 pm
i have actually completed my code. i added more functionality and fixed bugs.

in the data logging adjust page, i added the ability to delete selected data files and fixed a bug in my used space calculation. now the webpage displays the exact same value as windows explorer does.  :smiley-mr-green:

i also added another page for system information that includes system up-time, MAC address, number of sensor malfunctions if any, and the amount of free system RAM.


there were about 10 bugs that i found over the course of testing which appear to be fixed. there is still a bug in that the watch dog timer will reset the unit ever 1-2 days if i have data logging enabled, but not if it is off. i am looking into that.


with this said, tonight when i get off work, i will post all the code directly on this page.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: ericklil on Feb 14, 2013, 05:20 pm
Very Nice Work indeed do you have a set up diagram as well  :)
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Feb 15, 2013, 04:39 am

Very Nice Work indeed do you have a set up diagram as well  :)


are you referring to a system schematic?


i cannot paste my code into the page because of a 9500 character limit. i am going to try uploading it to a file service


edit:
https://www.dropbox.com/s/2hdyqq6l3xn3dol/Arduino.zip

hopefully the supplied link will work.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: ericklil on Feb 15, 2013, 01:56 pm
Zip worked fine, very nice.

System schematic would be grand, looks well thought out in the pictures.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: ODwyerPW on Feb 20, 2013, 07:14 pm
Wallaceb,
That is a very nice project. One of the absolute best I have ever seen! True genius.
Peter
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: iouzzr on Feb 21, 2013, 03:22 am
106K flash is really large  :P, use microSD instead!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Feb 21, 2013, 12:16 pm
it looks great!!!

however after uploading the code I can not get into it- DHCP on my router does not seem to see it.

What would be the way to set the static ip in the code ?

thanks!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Feb 22, 2013, 10:41 pm

Wallaceb,
That is a very nice project. One of the absolute best I have ever seen! True genius.
Peter


thanks very much for the complement  8)


it looks great!!!

however after uploading the code I can not get into it- DHCP on my router does not seem to see it.

What would be the way to set the static ip in the code ?

thanks!


:smiley-eek-blue: oops.. i forgot to post the code i used to "program" the EEPROM for all the "default" settings. when i get home later tonight i will post that code  :smiley-mr-green:



106K flash is really large  :P, use microSD instead!


with 256 k of available memory i was not going to worry about it. i originally thought to use the SD card, but decided that PROGMEM coding would be easier to code and control and faster with respect to I/O since the processor would not have to read a byte from SD card, store it locally, then send it to the Ethernet shield.


Looks very well done (+1),

(nitpicking -  Automated Reptile Environment Control System  - makes a better acronym  arecs that's an anagram of scare ;)



thanks for pointing that out. i made the upadtes to the code. have not gotten to changing the pictures in the post though

edit: added a link to the initialization sketch.

download this to the arduino, it will configure all the EEPROM.
download the normal code to the arduino and the web-page default URL is static at 192.168.1.200
you can then configure all the settings to your likings.


https://www.dropbox.com/s/we0tnxp3h0w90al/webserverinit.rar


edit:

i am adding more stuff to my code from here:
http://arduino.cc/forum/index.php?topic=134868.0

to make the downloading of log files MUCH faster. i will post the new code soon
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Feb 24, 2013, 10:42 pm
for anyone who is trying to use my code, there was a fairly large bug that was cause by my attempt to reduce the amount of RAM usage. this bug would make any page forms submitted to not process properly.

i have subsequently corrected the bug. the latest version of ALL code is in the link below, the libraries i use, the EEPROM initialize code, and the latest working code that i have.

https://www.dropbox.com/s/3e75754ivc1m0by/Arduino_2-24-2013.zip
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Feb 25, 2013, 04:47 am
Thanks for an update :)

Would you be so kind and draw a diagram and list parts used,please?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Feb 25, 2013, 04:31 pm
i cannot really give a list other than what i did on the first page. all the enclosure supplies i either already had lying around the house and do not have part number for, or i got on e-bay by performing searches for what i wanted and combed through the results until i found what looked good. the case, the switches, the terminal blocks, the fuse blocks, i do not have part numbers for. the outlets are standard outlets you can get a home depot or something.

i do not have a diagram of how it is wired... i do all that from my head, but i feel it is fairly straightforward how the outlets should be wired to the relays. all the low voltage wiring for the sensors and the RTC are based on the respective device data sheets, and how the libraries require them to be wired.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Feb 26, 2013, 04:03 pm
i am suddenly experiencing some complete crash / freeze issues after about half a day  =(

i previously was having issues where the watch dog would reset my program after a few days, but this is horrible.

i do know it is suggested to not use strings in programs, but it was the way i figured out how to code what i wanted. i did some searching and i have found this thread:

"String corrupts the heap and crashes" http://arduino.cc/forum/index.php/topic,115552.0.html

i am going to try using the modified string library Paul Stoffregen created to correct the memory issues related to the string library.

i wanted to know if anyone can either run the code on their own setup and see if you also crash/freeze, or help me come up with a better way to remove all need for strings.  Thanks :smiley-mr-green:
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: zoomkat on Feb 27, 2013, 02:28 am
Do you do the below with your Strings before exiting the subroutines in which the Strings were used?

Code: [Select]
String datastring = "";
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Feb 27, 2013, 03:22 am

Do you do the below with your Strings before exiting the subroutines in which the Strings were used?

Code: [Select]
String datastring = "";


no i do not. i thought that when a function is ended, any local variables used within the function were cleared.

i will give that a try though


i am also wondering if it is something with the ethernet shield. i have been able to crash the arduino if i purposfully send lots of information over to it really fast. it just stops responding.


i am also wondering why my arduino freezes when i have the watchdog enabled. should that not reset the system?

i tried to use the "Wstring.cpp" and "Wstring.h" from Paul Stoffregen's teensey system. everything compiled, but it would no longer function and i have not determined what is causing it to not work.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: zoomkat on Feb 27, 2013, 04:11 am
Quote
no i do not. i thought that when a function is ended, any local variables used within the function were cleared.


From what others have discussed, that is the premis of Strings issue, that the last String memory location used in the function is not automatically cleared as expected, resulting in that memory location no longer being available for use. May or may not help.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Feb 27, 2013, 06:59 pm

Quote
no i do not. i thought that when a function is ended, any local variables used within the function were cleared.


From what others have discussed, that is the premis of Strings issue, that the last String memory location used in the function is not automatically cleared as expected, resulting in that memory location no longer being available for use. May or may not help.


i have read that as well.

i have added to my code the lines to set all used strings to "" before the function ends. so far the arduino has 14 hours of up time.

i am in the process of trying to remove all uses of strings within my code. the main area strings are used is in processing of the data submitted by a web-page form in the function "sendPage"

Code: [Select]
void sendPage(EthernetClient & client, int nUriIndex, BUFFER & requestContent, char * global_pUri)
{
  if (nUriIndex < NUM_PAGES){
    wdt_reset();
    String datastring = "";
   
    //page was received, need to determine if the page returned ay form data
    //if form data was was received we need to process it on a per page process
    //page 1 does not have any form data
    //page 2 have 17 form entries for different temperature settings. these settings need to be extracted from the requestcontent
    //variable. once the data is extracted it needs to be saved to the correct variables and then to EEPROM so the setting take effect
    //between power outages
   
    /***************************************************************
    //PAGE 2 DATA PROCESSING
    ***************************************************************/
   
    if (nUriIndex == 1){//page 2
      //convert the request content variable from an array into a string
     
      for (byte x=0; x < 129; x++){
        datastring.concat(requestContent[x]);
      } 
      if (datastring.substring(0,2)=="1="){ //tests if the page has had a form submitted with data or not
          for (byte x = 1; x<18; x++){ //page 2 contains 17 data entry text boxes, so we want to run through all of them
            String temp1 = ""; //initilize temp variables to clear any previous data
            String temp2 = "";
            //the format for the submitetd form data is:
            //1=entry1&2=entry2&3=entry3 ect...
            //we want to use the sub string command, so we need to know the index locations for where the desired data entry index is
            //along with the data entry index of the next entry.
            temp1.concat(x);
            temp1.concat("=");
            temp2.concat(x+1);
            temp2.concat("=");
            //we need to see if the current entry is below 10. if the entry is below 10, we only need to skip 2 entries, one for the entry number
            //and another for the equals sign. however if the entry is above 10, we need to skip 3 entries becuase of the two digits for the entry
            //and another entry for the equals sign
            if (x<10){
              char valueArray[datastring.substring(datastring.indexOf(temp1) + 2,datastring.indexOf(temp2) -1).length() + 1];
              datastring.substring(datastring.indexOf(temp1) + 2,datastring.indexOf(temp2) -1).toCharArray(valueArray, sizeof(valueArray));
              if (x == 1){      //if the currently processing entry is entry 1
                if (atoi(valueArray)>= min_temp_setting && atoi(valueArray) <= max_temp_setting){    //is the entred entry within the allowable bounds?
                  INCSGDTON = atoi(valueArray);    //converts the string value of the entred data into a interger
                  if (EEPROM.read(INCSGDTONEEPROMADDR)!=INCSGDTON){    //if the user has not changed the entry from what is already in memory, then we do not want to save to EEPROM again as the EEPROM has a shorter life time
                    EEPROM.write(INCSGDTONEEPROMADDR, INCSGDTON);    //since the user has entered a new number, we now need to save this to memory
                    INCSGDTON_incorrect = false;    //because a valid entry was entered, we do not want the web-page to display "Invalid Entry!"
                  }
                }else{
                  INCSGDTON_incorrect = true;//if the user did enter an invalid value then we want the web-page to display "invalid entry!" when the substitution function runs
                }
              }else if (x == 2){
                if (atoi(valueArray)>= min_temp_setting && atoi(valueArray) <= max_temp_setting){
                  CSGDTOFF = atoi(valueArray);
                  if (EEPROM.read(CSGDTOFFEEPROMADDR)!=CSGDTOFF){
                    EEPROM.write(CSGDTOFFEEPROMADDR, CSGDTOFF);
                    CSGDTOFF_incorrect = false;
                  }
                }else{
                  CSGDTOFF_incorrect = true;
                }
              }else if (x == 3){
                if (atoi(valueArray)>= min_temp_setting && atoi(valueArray) <= max_temp_setting){
                  MSGDTON = atoi(valueArray);
                  if (EEPROM.read(MSGDTONEEPROMADDR)!=MSGDTON){
                    EEPROM.write(MSGDTONEEPROMADDR, MSGDTON);
                    MSGDTON_incorrect = false;
                  }
                }else{
                  MSGDTON_incorrect = true;
                }
              }else if (x == 4){
                if (atoi(valueArray)>= min_temp_setting && atoi(valueArray) <= max_temp_setting){
                  MSGDTOFF = atoi(valueArray);
                  if (EEPROM.read(MSGDTOFFEEPROMADDR)!=MSGDTOFF){
                    EEPROM.write(MSGDTOFFEEPROMADDR, MSGDTOFF);
                    MSGDTOFF_incorrect = false;
                  }
                }else{
                  MSGDTOFF_incorrect = true;
                }
              }else if (x == 5){


ect....


i turn the submitted data into a string so i can use this code
Code: [Select]
char valueArray[datastring.substring(datastring.indexOf(temp1) + 2,datastring.indexOf(temp2) -1).length() + 1];
              datastring.substring(datastring.indexOf(temp1) + 2,datastring.indexOf(temp2) -1).toCharArray(valueArray, sizeof(valueArray));


to extract the different entry values

i have not tested it yet, but i am going to try using the following demonstration code instead

Code: [Select]
#include <.h>
void setup()
{
  // start serial port at 9600 bps:
  Serial.begin(9600);
}

void loop()
{
//incomming string of data. string is actually 128 characters long, but this is the only section we care ot process. The "=%" indicates the end of the part of the strign we care about
char str[] = "1=80&2=82&3=83&4=84&5=85&6=86&7=87&8=88&9=89&10=90&11=91&12=92&13=93&14=94&15=95&16=96&17=97&18=%";
Serial.print("The string of submitted data is: ");
Serial.println(str);
for (byte x = 1;x<=17;x++){
   char ValueArray={NULL};
   PROCESSREQUESTCONTENT(x, str, &ValueArray);
   Serial.print("The value of entry # ");
   Serial.print(x);
   Serial.print(" is equal to: ");
   Serial.println(atoi((char *)ValueArray));
}
}

void PROCESSREQUESTCONTENT(byte index, char * str, char * output){
int pch=0;
byte beginning=0;
byte ending=0;
byte counter=0;
//locate where "%" is located so we know where to stop
pch=atoi(strchr(str,'%'));

//"pch-4" is required because pch indicates where the "%" sign is with the first character starting at 1. however the char array starts at 0. in addition we do not care about the "&17=" part of the ending.
//the length of the "5" itself is removed because of the offset from starting point 1 to starting point 0
//the "-4" is so the code ignores the "&18=" characters
for (byte x=0;x<= pch-4;x++){
   if (strncmp((char *)str[x],"=",1)==0){
     beginning = x+1; //starting character position of actual data entry
   }else if (strncmp((char *)str[x],"&",1)==0){
     ending=x-1;//ending character position of actual data entry
     counter++;//increment counter so we can see if this is the data entry we care about
   }
   if (counter==index){//have we found the data antry we care about?
     counter = 0;
     for (byte i=0; i<=(ending-beginning);i++){//copy the data entry so we can use it
       output[i] = str[beginning + i];
       break;
     }
   }     
}
 
}




wish me luck
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: draythomp on Feb 27, 2013, 07:15 pm
Check in the playground for memory usage.  There are a couple of routines there that can tell you how much you have left at any given time.  I use them extensively to keep away from running out of memory.  You can put them in temporarily to measure what you have left and isolate a problem area then fix whatever is needed.

In a couple of hard cases, I put them in the loop() and automatically rebooted the board to clean things out when free memory reached a low number.  This was a stop gap measure I used while I tried to figure out what the heck was going on.  These days, I try desperately to avoid using Strings and use the old reliable strcat, strcmp, etc. instead.

Something like:
Code: [Select]

#include <avr/pgmspace.h>

void showMem(){
  uint8_t * heapptr, * stackptr;
 
  strcpy_P(Dbuf,PSTR("Mem = "));
  Serial.print(Dbuf);
  stackptr = (uint8_t *)malloc(4);   // use stackptr temporarily
  heapptr = stackptr;                // save value of heap pointer
  free(stackptr);                    // free up the memory again (sets stackptr to 0)
  stackptr =  (uint8_t *)(SP);       // save value of stack pointer
  Serial.println(stackptr - heapptr);
}

// and then sprinkle these around to get a feel for what is going on

    showMem();

Or maybe you would prefer:
Code: [Select]

#include <MemoryFree.h>

void showMem(){
  strcpy_P(Dbuf,PSTR("Mem = "));
  Serial.print(Dbuf);
  Serial.println(freeMemory());
}

// and then, as above, I sprinkle these around to see what is happening

showMem();

I use both in different applications.  Don't have a preference either way.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Feb 27, 2013, 07:18 pm
i do already have a free memory routine that displays the amount of memory on one f the web-pages. i have never seen it go below 4200 bytes. i will have to post the exact routine i am using later, in case it is displaying the wrong result
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: draythomp on Feb 27, 2013, 07:30 pm
You probably need to sprinkle them around more places.  I've had to go so far as to put them before the return of many routines to get a clue what was happening.  Sometimes when you're recursing, the level of recursion can get so deep that you run out of memory.  If it returns, the memory unwinds back to a good level.  This can happen when some routine allocates and then calls something else as well.

You can get lost and not have any idea what the heck happened until you really start to dissect it.

But then, you could also just be running past the end of some buffer somewhere and clobbering yourself.  These problems can be tough to find.  Been there, done that...sigh.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: alvydas001 on Feb 28, 2013, 02:15 pm
Fantastic job! Congratulations!

One proposal, and it will be a perfect system. DS18B20 sensors can be connected on a single cable. It is more convenient.
But then you need to know their address. Here is a sample of how addresses are assigned sensors: http://www.homebrewtalk.com/f51/arduino-networked-temperature-monitor-340294/index2.html#post4286666
The combination of both programs get a great system.

My English is very bad, but I hope you got the idea... :)
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Feb 28, 2013, 05:18 pm

Fantastic job! Congratulations!

One proposal, and it will be a perfect system. DS18B20 sensors can be connected on a single cable. It is more convenient.
But then you need to know their address. Here is a sample of how addresses are assigned sensors: http://www.homebrewtalk.com/f51/arduino-networked-temperature-monitor-340294/index2.html#post4286666
The combination of both programs get a great system.

My English is very bad, but I hope you got the idea... :)


i see nothing wrong with your English.

i did think about having them on one bus, however per the Dallas Semiconductor data sheets, a star topology is not recommended. i wanted the least possible issues with the data feedback, and so i choose to have each sensor on its own "one wire master" giving me the best possible electrical setup to reduce error.

and with so many I/O on the MEGA i had no worries about running out of pins.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: alvydas001 on Mar 01, 2013, 01:50 pm
I have project and use 10 DS18B20 sensors to connected on one cable (parasite power mode). Longest distance of 16-18 meters (2 pieces), 10-12 meters (5 units), the other 3-4 meters. Runs great. The project is here: http://www.saulevire.lt/en (and here- http://www.ksduino.org/?devices&device_id=3331) (works half the year, but the site still has not been made).
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: zoomkat on Mar 01, 2013, 04:50 pm
Quote
i am also wondering if it is something with the ethernet shield. i have been able to crash the arduino if i purposfully send lots of information over to it really fast. it just stops responding.


I think the 5100 chip is capable of only four sockets, so if a socket is not properly allowed to close, it may become unavailable for future use.

Quote
i am also wondering why my arduino freezes when i have the watchdog enabled. should that not reset the system?


I haven't looked at the watchdog code. Is it a proven design?

Quote
i tried to use the "Wstring.cpp" and "Wstring.h" from Paul Stoffregen's teensey system. everything compiled, but it would no longer function and i have not determined what is causing it to not work.


I think those librarys are included in the latest arduino core design. If you use the string functions, under some conditions it is said that used memory is not automatically released, and might eventually deplete available memory, causing a freeze. Recently various patch solutions have been posted

Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Mar 01, 2013, 05:35 pm
I have completly removed the string library from my code and replaced it with char arrays. I am testing the code now to see if it crashes, resets, or freezes.

Luckily removing the string class actually saves about 4k of flash and I appear to be using about 600 fewer bytes of SRAM.

I will post the code shortly.

I have found a bug with my "system uptime calculator" where it calculates wrong when transitioning from February to march. I wi have to look onto that issue

Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: draythomp on Mar 01, 2013, 06:59 pm
Go to the playground and look at the Time and TimeAlarms library.  You don't have to actually set the time, but you already have an RTC, so it should be easy to do.  In the Time header file are a lot of macros including days between dates and such.  Also, out on the web are a ton of days between dates routines that you can use.  Most of the samples also have the seconds between date that will work for you as well, although saving the unix time when you start and just subtracting it from the current time will give you seconds pretty easily.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Mar 01, 2013, 10:06 pm
i have a few other bugs now, because of the removal of strings, my ability to download log files, and to delete the log files no longer works. i will look into that now as well.

edit: those are fixed now  8)

still going to look into the "system up time" calculator


Go to the playground and look at the Time and TimeAlarms library.  You don't have to actually set the time, but you already have an RTC, so it should be easy to do.  In the Time header file are a lot of macros including days between dates and such.  Also, out on the web are a ton of days between dates routines that you can use.  Most of the samples also have the seconds between date that will work for you as well, although saving the unix time when you start and just subtracting it from the current time will give you seconds pretty easily.


thanks for the info, i will take a look at those.


edit: latest code
https://www.dropbox.com/s/4s3vzc5gopik7re/Arduino3-1-2013.zip
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Mar 11, 2013, 05:57 pm
Hi,

could you tell me what moisture sensor have you used?

thanks!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Mar 12, 2013, 07:15 pm
i am using http://sensing.honeywell.com/product%20page?pr_id=53944
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Mar 28, 2013, 12:37 am
Hi,


No humidity sensor attached so far, just checking if all relays can be controlled in manual mode
but  for unknown reason humidifier does not turn off in manual mode.
Any ideas ?

thanks!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Mar 28, 2013, 12:41 am
ps. Talking about RTC, which pin SCL and SDA is connected on the arduino board  please ?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: Nick_Pyner on Mar 28, 2013, 03:47 am
On a standard Uno it is SDA to A4 and SCL to A5. Note that it is pins 20, 21 on a Mega. Most Megas have this marked on the board.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Mar 28, 2013, 08:44 pm

Hi,


No humidity sensor attached so far, just checking if all relays can be controlled in manual mode
but  for unknown reason humidifier does not turn off in manual mode.
Any ideas ?

thanks!



sorry for not responding sooner, been really busy.

to answer your question, i had the same issue. i know i fixed it, and if i recall there is a typo in the version of code i posted. when i get home tonight i will post the latest. that WILL fix that issue.  :smiley-mr-green:


ps. Talking about RTC, which pin SCL and SDA is connected on the arduino board  please ?


i have the RTC connected to pins 20 and 21 on the MEGA



i would also like to update that the random system reboots and freezes have been fixed. now that i have removed the string class the system is stable. i also removed some code that had the unit auto-update its time every 24 hours. without that, you can still get the correct time by manually initiating a time update. the system has now been going for 25 days while logging data without issues.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Mar 30, 2013, 12:46 am
latest code:

https://www.dropbox.com/s/s1tdkgo04rtc6cj/Arduino_3-29-13.rar
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Mar 30, 2013, 11:27 pm
hi,

thanks - manual moisture control works now.

I have encountered another issue, when trying to connect with smartphone, arduino freezes - orange led starts blinking and no response...
Is there a way to use mobile devices with your control system?

Thanks!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Mar 31, 2013, 12:07 am
ps. what rtc module do you use ? I do not know why but I just can not start mine - it is Tiny RTC I2C module...
thanks!

Really appreciate your help and response!!!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: Nick_Pyner on Mar 31, 2013, 01:11 am
I have five of those, they cost a couple of dollars each, and they all work fine. I have heard that they must have a battery installed to work. I don't understand why, but somebody recently had a dud battery and that was apparently the problem.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Mar 31, 2013, 09:38 am
Thanks, I will test the battery ( perhaps I will buy another RTC)

Would you have an idea when trying to connect with smartphone, arduino freezes - orange led starts blinking and no response...
Is there a way to use mobile devices with your control system?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: Nick_Pyner on Mar 31, 2013, 12:52 pm
No idea, I don't have a smart phone.  My involvement is more about feeds to the internet and the only mobile device is a laptop getting the same data feed via bluetooth. 
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Mar 31, 2013, 01:36 pm

No idea, I don't have a smart phone.  My involvement is more about feeds to the internet and the only mobile device is a laptop getting the same data feed via bluetooth. 


thanks for fast reply!

I wonder if there is anybody who has tried to connect to this sketch with a smartphone ?

Thanks !
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Mar 31, 2013, 05:15 pm

hi,

thanks - manual moisture control works now.

I have encountered another issue, when trying to connect with smartphone, arduino freezes - orange led starts blinking and no response...
Is there a way to use mobile devices with your control system?

Thanks!


i have experienced this as well when using the stock android browser. i have to use Mobile Fire Fox browser and i have no issues when using my smart phone. i have not determined what the cause of this behavior is. Just use fire fox mobile and you should not have any problems. there must be some issue with how the stock andriod browser behaves that keep the sketch in an infinite loop within the client connected code.


Thanks, I will test the battery ( perhaps I will buy another RTC)

Would you have an idea when trying to connect with smartphone, arduino freezes - orange led starts blinking and no response...
Is there a way to use mobile devices with your control system?


the battery is required to keep the RTC module's time going when no external power is applied. otherwise the clock resets to zero.


ps. what rtc module do you use ? I do not know why but I just can not start mine - it is Tiny RTC I2C module...
thanks!

Really appreciate your help and response!!!

i just did a search on amazon for RTC modules.



Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Apr 11, 2013, 11:05 am
hi, any idea why I am only getting Middle Ground temp reading although Cold and Middle sensors connected.
Two one wire sensors with 4,7k resistors on each.

thanks!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: Nick_Pyner on Apr 11, 2013, 03:58 pm
You only need one 4k7 but I don't know if this is the cause of your problem.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Apr 11, 2013, 06:40 pm

hi, any idea why I am only getting Middle Ground temp reading although Cold and Middle sensors connected.
Two one wire sensors with 4,7k resistors on each.

thanks!


i honestly do not know. i myself have one 4.7k resistor per sensor as well since each data line goes to its own dedicated I/O pin. do you have the sensors connected to the correct pin? have you tried to make sure the sensors that are not working, work correctly when connected to the I/O pin of one that does?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Apr 12, 2013, 08:42 pm


hi, any idea why I am only getting Middle Ground temp reading although Cold and Middle sensors connected.
Two one wire sensors with 4,7k resistors on each.

thanks!


i honestly do not know. i myself have one 4.7k resistor per sensor as well since each data line goes to its own dedicated I/O pin. do you have the sensors connected to the correct pin? have you tried to make sure the sensors that are not working, work correctly when connected to the I/O pin of one that does?

As far as I know one wire sensors are attached to 22,24,26, 28,30 pins.
Only getting Middle Ground readings, however after switching from Celsius to Fahrenheit I can get readings wherever sensor is connected, do you work on F or C?
thanks!!!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Apr 13, 2013, 01:05 am
i keep mine in F the entire time. i just checked, and it is doing the same thing on my system when set to C.... i will have to look into what is going on.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Apr 13, 2013, 01:11 am
found the issue

change the current code:

Code: [Select]
void CONVERT_TEMP(byte Sensor_PIN, byte & temp_whole, byte & temp_fract, byte & temp_status) {
  OneWire  dSensor1(Sensor_PIN);
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];
  int HighByte, LowByte, TReading, SignBit, Tc_100;
 
 
  if ( !dSensor1.search(addr)) {
    dSensor1.reset_search();
    delay(250);
    temp_whole = 0;
    temp_fract = 0;
    temp_status = 0;
    badsensorcount ++;
    return;
  }

  if ( OneWire::crc8( addr, 7) != addr[7]) {
      temp_whole = 0;
    temp_fract = 0;
    temp_status = 0;
    badsensorcount ++;
    return;
  }

  // The DallasTemperature library can do all this work for you!

  dSensor1.reset();
  dSensor1.select(addr);
  dSensor1.write(0x44,0);         // start conversion, without parasite power on at the end
 
  delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a dSensor1.depower() here, but the reset will take care of it.
 
  present = dSensor1.reset();
  dSensor1.select(addr);   
  dSensor1.write(0xBE);         // Read Scratchpad

  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = dSensor1.read();
  }

  LowByte = data[0];
  HighByte = data[1];
  TReading = (HighByte << 8) + LowByte;
  SignBit = TReading & 0x8000;  // test most sig bit
  if (SignBit) // negative
  {
    TReading = (TReading ^ 0xffff) + 1; // 2's comp
  }
  Tc_100 = (6 * TReading) + TReading / 4;    // multiply by (100 * 0.0625) or 6.25
 
  if (temp_scale == 1){//if using degrees F, the celcius reading from the sensor must be converted
     temp_whole = (int)(((Tc_100)*(1.8))+3200)/100;
     temp_fract = (int)(((Tc_100)*(1.8))+3200)%100;
     if (temp_whole > 32){
       temp_status = 1;//if the temperature is above 32 degrees F, then the sensor is OK
     }else{
       temp_status = 0;//the sensor must be bad as the temperature must never get down as low as 32 degrees F, the snake would die!!
     }
   }else{//if using degrees C, the temp reading is good as is.
     middle_temp_whole = Tc_100/100;
     middle_temp_fract = Tc_100%100;
     if (temp_whole > 0){
       temp_status = 1;//if the temperature is above 0 degrees C, then the sensor is OK
     }else{
       temp_status = 0;//the sensor must be bad as the temperature must never get down as low as 0 degrees C
     }
   }
}


to

Code: [Select]
void CONVERT_TEMP(byte Sensor_PIN, byte & temp_whole, byte & temp_fract, byte & temp_status) {
  OneWire  dSensor1(Sensor_PIN);
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];
  int HighByte, LowByte, TReading, SignBit, Tc_100;
 
 
  if ( !dSensor1.search(addr)) {
    dSensor1.reset_search();
    delay(250);
    temp_whole = 0;
    temp_fract = 0;
    temp_status = 0;
    badsensorcount ++;
    return;
  }

  if ( OneWire::crc8( addr, 7) != addr[7]) {
      temp_whole = 0;
    temp_fract = 0;
    temp_status = 0;
    badsensorcount ++;
    return;
  }

  // The DallasTemperature library can do all this work for you!

  dSensor1.reset();
  dSensor1.select(addr);
  dSensor1.write(0x44,0);         // start conversion, without parasite power on at the end
 
  delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a dSensor1.depower() here, but the reset will take care of it.
 
  present = dSensor1.reset();
  dSensor1.select(addr);   
  dSensor1.write(0xBE);         // Read Scratchpad

  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = dSensor1.read();
  }

  LowByte = data[0];
  HighByte = data[1];
  TReading = (HighByte << 8) + LowByte;
  SignBit = TReading & 0x8000;  // test most sig bit
  if (SignBit) // negative
  {
    TReading = (TReading ^ 0xffff) + 1; // 2's comp
  }
  Tc_100 = (6 * TReading) + TReading / 4;    // multiply by (100 * 0.0625) or 6.25
 
  if (temp_scale == 1){//if using degrees F, the celcius reading from the sensor must be converted
     temp_whole = (int)(((Tc_100)*(1.8))+3200)/100;
     temp_fract = (int)(((Tc_100)*(1.8))+3200)%100;
     if (temp_whole > 32){
       temp_status = 1;//if the temperature is above 32 degrees F, then the sensor is OK
     }else{
       temp_status = 0;//the sensor must be bad as the temperature must never get down as low as 32 degrees F, the snake would die!!
     }
   }else{//if using degrees C, the temp reading is good as is.
     temp_whole = Tc_100/100;
     temp_fract = Tc_100%100;
     if (temp_whole > 0){
       temp_status = 1;//if the temperature is above 0 degrees C, then the sensor is OK
     }else{
       temp_status = 0;//the sensor must be bad as the temperature must never get down as low as 0 degrees C
     }
   }
}
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on May 26, 2013, 01:57 am
i realized i never put up pictures of my entire final setup

(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/IMAG0055_zps25a0fc17.jpg) (http://s73.photobucket.com/user/wallacebrf/media/arduino/IMAG0055_zps25a0fc17.jpg.html)


(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/IMAG0053_zps05c18744.jpg) (http://s73.photobucket.com/user/wallacebrf/media/arduino/IMAG0053_zps05c18744.jpg.html)


(http://i73.photobucket.com/albums/i226/wallacebrf/arduino/IMAG0052_zpsef24afb7.jpg) (http://s73.photobucket.com/user/wallacebrf/media/arduino/IMAG0052_zpsef24afb7.jpg.html)


Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on May 28, 2013, 04:39 pm
It looks great, everything is organized as it should be - but where is the snake ;) ?

Have you update your code recently ?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on May 28, 2013, 06:49 pm

It looks great, everything is organized as it should be - but where is the snake ;) ?

Have you update your code recently ?


the snake only like to come out at night  :smiley-sleep:

my latest will be uploaded later tonight. only a few small things have been tweaked, and i re-added corrected code so the RTC will update off NTP servers once a day.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on May 30, 2013, 09:19 pm
sorry, forgot to upload the code:

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

let me know if you have any issues.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jun 07, 2013, 02:19 am
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
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Jun 12, 2013, 06:23 pm
Great !!!

Thanks for an update, will install it now.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Sep 16, 2013, 01:38 am
Hi,

Just wondering if you made any changes to the sketch?
Are you working on other great  arduino projects?
Thanks!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Sep 22, 2013, 11:59 pm

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
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: barbudancristian on Oct 04, 2013, 01:21 pm
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
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Oct 04, 2013, 06:07 pm

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.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: barbudancristian on Oct 04, 2013, 07:02 pm
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
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Oct 04, 2013, 07:25 pm

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.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: barbudancristian on Oct 06, 2013, 01:54 pm
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
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: barbudancristian on Oct 06, 2013, 07:47 pm
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?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Oct 07, 2013, 08:03 pm

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:


Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Oct 07, 2013, 08:15 pm

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.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Oct 08, 2013, 05:36 am
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
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Oct 08, 2013, 10:20 pm

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  =( =( =(
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Oct 11, 2013, 02:26 pm
What I figured out is fact that Firefox on OSX can communicate with Arduino, however Safari can not. I'd say or arduino can only recognize Firefox or this is the way other browsers talk to Arduino, but it was mentioned that it also works with IE ? Perhaps a line with browser detection - auto detection would help ?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Oct 14, 2013, 09:58 pm

What I figured out is fact that Firefox on OSX can communicate with Arduino, however Safari can not. I'd say or arduino can only recognize Firefox or this is the way other browsers talk to Arduino, but it was mentioned that it also works with IE ? Perhaps a line with browser detection - auto detection would help ?


if i could more easily understand the exact differences in how IE/Firefox Versus Chrome or Safari interact with the arduino, then yes i could use browser detection. i have looked into the differences between some of the browsers, and i think the reason for the "incompatibility" is the length/amount of data that is sent during the HTTP communications. i think that it is causing a buffer over flow since the buffer is only 128 bytes in size.

if you can, perhaps make the line

Code: [Select]
#define STRING_BUFFER_SIZE 128 in the webserver.h file 256 or possibly even bigger, and see if that possibly fixes the issue?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: pico on Dec 03, 2013, 07:11 pm
I've been adapting your ARECS code as a demo to connect to the Internet using my wireless RFXduino (http://embeddedcoolness.com) system, and you'll be pleased to hear that in the process I found your browser bug!

It's a doozy, actually. Basically, you were forgetting to send response headers before your html  in your sendPage() function! So instead of getting

Code: [Select]

HTTP/1.1 200 OK
Server: arduino
Cache-Control: no-store, no-cache, must-revalidate
Connection: keep-alive
Content-type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title>Automated Reptile Environment Control System</title><style>body {font-family: Verdana, Arial, sans-serif;background: #fff;margin: 0px auto;padding: 0 0 20px [...]


by way of a response, the browsers were just getting hit directly with

Code: [Select]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title>Automated Reptile Environment Control System</title><style>body {font-family: Verdana, Arial, sans-serif;background: #fff;margin: 0px auto;padding: 0 0 20px [...]


The differences in the browsers behavior just reflected how they individually handled the (fairly extreme) situation. IE10 and Chrome were the most liberal, simply recognizing it as html, and assuming some default response header values that seemed to work pretty well. Firefox was a bit more  conservative, and treated it as text/plain rather than text/html content-type, and so it would show a nice screen full of html tags. Safari just turned it's nose up at the whole thing and did a good job of pretending it didn't receive anything.

As I was debugging this today, it took a while for the penny to drop, as it didn't occur that browsers like IE and Chrome could work at all without getting some sort of response headers. It was looking a FF "View Page Info" that first alerted me to the fact that the content-type was being set as "text/plain" rather than "text/html". How could that be? Something subtly wrong with the response headers? Well, yeah... like they were completely missing!  :)

Anyway, I also found a few other less serious bugs, which I will document more fully after I've had a bit more of a play with and test the system, but I thought I'd give you all a quick heads up on the "incompatible browser" issue. I've got it working using RFXduino with IE10, Chrome (WIndows and Android), Firefox (Windows and Android), and Safari (Windows).

Basic changes (should also work if using ethernet shield, although I haven't tested directly):

In sendPage(), change

Code: [Select]

   sendProgMemAsString(client, (char*)pgm_read_word(&(contents_main[CONT_TOP])));
   //wdt_reset();
   //sendUriContentByIndex(client, nUriIndex, requestContent, 0, CONT_TOP);


to

Code: [Select]

   // send response headers
   sendProgMemAsString(client, (char*)pgm_read_word(&(contents_main[CONT_HEADER])));

   // send HTML header
   sendProgMemAsString(client, (char*)pgm_read_word(&(contents_main[CONT_TOP])));
   //wdt_reset();
   //sendUriContentByIndex(client, nUriIndex, requestContent, 0, CONT_TOP);


and in htmldata.h, change

Code: [Select]

PROGMEM prog_char content_main_header[] = "HTTP/1.0 200 OK\nServer: arduino\nCache-Control: no-store, no-cache, must-revalidate\nPragma: no-cache\nConnection: close\nContent-Type: text/html\n";


to

Code: [Select]

PROGMEM prog_char content_main_header[] = "HTTP/1.1 200 OK\r\n"
"Server: arduino\r\n"
"Cache-Control: no-store, no-cache, must-revalidate\r\n"
"Connection: keep-alive\r\n"
"Content-type: text/html\r\n"
"\r\n";


Thanks for your nice system -- I hope you don't mind me adapting it as a demo for my purposes! It has some nice technical and design features that makes it quite a nice showcase program for my system, I think. In my configuration, all the SD card storage can be on the Raspberry Pi gateway device, and so it's like a mini "cloud" server for all the Arduinos connecting through it. Also, things like the RTC function are also virtualised, so the only thing the ARECS Arduino has to do in terms of real devices is manage the relays. I'm thinking I'll be able to get the fully converted program running on a 328 Uno-class board, but we'll have to see how converting the html strings from progmem to SD flash affects performance. But I thought you'd like a heads-up on the browser issue in the meantime.

Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Dec 05, 2013, 09:56 pm
wow, thanks for the report. i cannot believe i forgot to include that in my header  =(

at least it is a "simple" mistake in that it is not an issue with the fundamental code base used in the project.

i will make the change. i also look forward to hearing about the other bugs you discovered.

i am glad you like the code. i have no issues with you using it, that is why i posted it here  ;)  8)



I've been adapting your ARECS code as a demo to connect to the Internet using my wireless RFXduino (http://embeddedcoolness.com) system, and you'll be pleased to hear that in the process I found your browser bug!

It's a doozy, actually. Basically, you were forgetting to send response headers before your html  in your sendPage() function! So instead of getting

Code: [Select]

HTTP/1.1 200 OK
Server: arduino
Cache-Control: no-store, no-cache, must-revalidate
Connection: keep-alive
Content-type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title>Automated Reptile Environment Control System</title><style>body {font-family: Verdana, Arial, sans-serif;background: #fff;margin: 0px auto;padding: 0 0 20px [...]


by way of a response, the browsers were just getting hit directly with

Code: [Select]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title>Automated Reptile Environment Control System</title><style>body {font-family: Verdana, Arial, sans-serif;background: #fff;margin: 0px auto;padding: 0 0 20px [...]


The differences in the browsers behavior just reflected how they individually handled the (fairly extreme) situation. IE10 and Chrome were the most liberal, simply recognizing it as html, and assuming some default response header values that seemed to work pretty well. Firefox was a bit more  conservative, and treated it as text/plain rather than text/html content-type, and so it would show a nice screen full of html tags. Safari just turned it's nose up at the whole thing and did a good job of pretending it didn't receive anything.

As I was debugging this today, it took a while for the penny to drop, as it didn't occur that browsers like IE and Chrome could work at all without getting some sort of response headers. It was looking a FF "View Page Info" that first alerted me to the fact that the content-type was being set as "text/plain" rather than "text/html". How could that be? Something subtly wrong with the response headers? Well, yeah... like they were completely missing!  :)

Anyway, I also found a few other less serious bugs, which I will document more fully after I've had a bit more of a play with and test the system, but I thought I'd give you all a quick heads up on the "incompatible browser" issue. I've got it working using RFXduino with IE10, Chrome (WIndows and Android), Firefox (Windows and Android), and Safari (Windows).

Basic changes (should also work if using ethernet shield, although I haven't tested directly):

In sendPage(), change

Code: [Select]

   sendProgMemAsString(client, (char*)pgm_read_word(&(contents_main[CONT_TOP])));
   //wdt_reset();
   //sendUriContentByIndex(client, nUriIndex, requestContent, 0, CONT_TOP);


to

Code: [Select]

   // send response headers
   sendProgMemAsString(client, (char*)pgm_read_word(&(contents_main[CONT_HEADER])));

   // send HTML header
   sendProgMemAsString(client, (char*)pgm_read_word(&(contents_main[CONT_TOP])));
   //wdt_reset();
   //sendUriContentByIndex(client, nUriIndex, requestContent, 0, CONT_TOP);


and in htmldata.h, change

Code: [Select]

PROGMEM prog_char content_main_header[] = "HTTP/1.0 200 OK\nServer: arduino\nCache-Control: no-store, no-cache, must-revalidate\nPragma: no-cache\nConnection: close\nContent-Type: text/html\n";


to

Code: [Select]

PROGMEM prog_char content_main_header[] = "HTTP/1.1 200 OK\r\n"
"Server: arduino\r\n"
"Cache-Control: no-store, no-cache, must-revalidate\r\n"
"Connection: keep-alive\r\n"
"Content-type: text/html\r\n"
"\r\n";


Thanks for your nice system -- I hope you don't mind me adapting it as a demo for my purposes! It has some nice technical and design features that makes it quite a nice showcase program for my system, I think. In my configuration, all the SD card storage can be on the Raspberry Pi gateway device, and so it's like a mini "cloud" server for all the Arduinos connecting through it. Also, things like the RTC function are also virtualised, so the only thing the ARECS Arduino has to do in terms of real devices is manage the relays. I'm thinking I'll be able to get the fully converted program running on a 328 Uno-class board, but we'll have to see how converting the html strings from progmem to SD flash affects performance. But I thought you'd like a heads-up on the browser issue in the meantime.


Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Dec 21, 2013, 12:22 am
Hi Wallaceb,

would you share your sketch if updated ? I messed too much with mine and saved ;)
thanks!
Merry Xmas !
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Dec 23, 2013, 03:27 am

Hi Wallaceb,

would you share your sketch if updated ? I messed too much with mine and saved ;)
thanks!
Merry Xmas !


no problem, i actually changed a few things anyways.

https://www.dropbox.com/s/0twzm2aztgg8o22/webserver-1.3%2012-22-2013%20-%20Copy.zip (https://www.dropbox.com/s/0twzm2aztgg8o22/webserver-1.3%2012-22-2013%20-%20Copy.zip)

i changed the way the system calculates the system up-time on page9 with code i created for a countdown clock so it calculates perfectly.

i also added functionality so the system will send e-mails when any sensor(s) have been detected to be malfunctioning so the user knows to check on things before anything may go too horribly wrong.

i also fixed the issues were certain web-browsers appeared to cause the system to crash. with the help from user pico, and also by changing a buffer size from 128 to 256, all browsers i tested work.

ENJOY!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: tmaros on Jan 13, 2014, 04:32 pm
Hi all! I tired to upload (after webserverinit) your sketch webserver.ino, but I get multiple errors, i.e.:
C:\Users\me\Documents\Arduino\libraries\libraries\EthernetDHCP.cpp:545: error: 'ethernet_compat_write_GAR' was not declared in this scope
C:\Users\me\Documents\Arduino\libraries\libraries\EthernetDHCP.cpp:546: error: 'ethernet_compat_write_SUBR' was not declared in this scope
...

I don't know what's wrong. It seems strange that path includes "libraries" two times, but don't know why either..
BTW: it's an excellent job!
Best regards!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jan 13, 2014, 05:41 pm

Hi all! I tired to upload (after webserverinit) your sketch webserver.ino, but I get multiple errors, i.e.:
C:\Users\me\Documents\Arduino\libraries\libraries\EthernetDHCP.cpp:545: error: 'ethernet_compat_write_GAR' was not declared in this scope
C:\Users\me\Documents\Arduino\libraries\libraries\EthernetDHCP.cpp:546: error: 'ethernet_compat_write_SUBR' was not declared in this scope
...

I don't know what's wrong. It seems strange that path includes "libraries" two times, but don't know why either..
BTW: it's an excellent job!
Best regards!


i am sorry, when i posted my version 1.3 code, i forgot to add the library folder within the zip file.

please download this file:

https://www.dropbox.com/s/cun7nqg9qrlfj9k/1.1%20-%206-6-2013.zip

go into the zip file's libraries folder and copy the following into your Arduino IDE library folder:
EthernetBonjour
EthernetDHCP
EthernetDNS
OneWire

those will give you all the needed external library files the compiler is complaining about.

my bad!  :smiley-roll-blue:
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: tmaros on Jan 13, 2014, 06:02 pm
No, actually it is my fault - it was other reason. Sorry for offtopic, maybe admin should just delete my last post?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: pico on Mar 06, 2014, 03:05 pm


Thanks for your nice system -- I hope you don't mind me adapting it as a demo for my purposes! It has some nice technical and design features that makes it quite a nice showcase program for my system, I think. In my configuration, all the SD card storage can be on the Raspberry Pi gateway device, and so it's like a mini "cloud" server for all the Arduinos connecting through it. Also, things like the RTC function are also virtualised, so the only thing the ARECS Arduino has to do in terms of real devices is manage the relays. I'm thinking I'll be able to get the fully converted program running on a 328 Uno-class board, but we'll have to see how converting the html strings from progmem to SD flash affects performance. But I thought you'd like a heads-up on the browser issue in the meantime.

i am glad you like the code. i have no issues with you using it, that is why i posted it here  ;)  8)


hi wallaceb,

I thought you might like to see my write-up of the RFXduino demo project that ARECS evolved into... ARVCS! ;-)

http://embeddedcoolness.com/rfxduino-demo-projects/

OK, so now it's controlling a roof ventilation system rather than keeping a reptile comfortable, but I think you will instantly spot the family resemblance nevertheless, ;-)

Also, the virtual SD Card and virtual RTC functionality have worked in nicely, and I did get it to fit onto an Uno as result, so it has ticked all the boxes I had in mind originally for a demo project.

Thanks again for your efforts in providing the original program. Nice framework, and I anticipate a few more derivative projects before we're done!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Mar 12, 2014, 05:13 pm



Thanks for your nice system -- I hope you don't mind me adapting it as a demo for my purposes! It has some nice technical and design features that makes it quite a nice showcase program for my system, I think. In my configuration, all the SD card storage can be on the Raspberry Pi gateway device, and so it's like a mini "cloud" server for all the Arduinos connecting through it. Also, things like the RTC function are also virtualised, so the only thing the ARECS Arduino has to do in terms of real devices is manage the relays. I'm thinking I'll be able to get the fully converted program running on a 328 Uno-class board, but we'll have to see how converting the html strings from progmem to SD flash affects performance. But I thought you'd like a heads-up on the browser issue in the meantime.

i am glad you like the code. i have no issues with you using it, that is why i posted it here  ;)  8)


hi wallaceb,

I thought you might like to see my write-up of the RFXduino demo project that ARECS evolved into... ARVCS! ;-)

http://embeddedcoolness.com/rfxduino-demo-projects/

OK, so now it's controlling a roof ventilation system rather than keeping a reptile comfortable, but I think you will instantly spot the family resemblance nevertheless, ;-)

Also, the virtual SD Card and virtual RTC functionality have worked in nicely, and I did get it to fit onto an Uno as result, so it has ticked all the boxes I had in mind originally for a demo project.

Thanks again for your efforts in providing the original program. Nice framework, and I anticipate a few more derivative projects before we're done!



very nice, i am very glad the base code worked so well for you and that your project is working

i really want to ask, how are you doing the web-page graphs of data?  :smiley-eek: i wanted to do something like that  :smiley-mr-green:
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: pico on Mar 12, 2014, 06:26 pm

very nice, i am very glad the base code worked so well for you and that your project is working

i really want to ask, how are you doing the web-page graphs of data?  :smiley-eek: i wanted to do something like that  :smiley-mr-green:


Well, all the source code is on the site (embeddedcoolness.com) if you want to check into any of the details.

But the basic thing is that data is being logged to the cloud server (Xively in this case), and then the graphs are being displayed as embedded images using the <img src=""> tags in the html pages. Here's a fragment:

Code: [Select]

<img src="https://api.xively.com/v2/feeds/1234567890/datastreams/roof_out_temp.png?width=730&height=250&
colour=F15A24&timezone=+10&duration=^|hours&xlabel=hours&l=temp%20(C)&b=true&g=true"
alt="roof_out_temp.png plot here"/>


Notice that after "duration" I have a ^| placeholder inserted -- that's the equivalent of one of the STX characters in your html template files.

That's so I can dynamically specify how much history to display in the graphs (from 1 hour to ten days.)

(Also, I substituted my actual Xively feed id with "1234567890" for the example above.)

Does that help answer your question at all?

Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Mar 12, 2014, 06:43 pm


very nice, i am very glad the base code worked so well for you and that your project is working

i really want to ask, how are you doing the web-page graphs of data?  :smiley-eek: i wanted to do something like that  :smiley-mr-green:


Well, all the source code is on the site (embeddedcoolness.com) if you want to check into any of the details.

But the basic thing is that data is being logged to the cloud server (Xively in this case), and then the graphs are being displayed as embedded images using the <img src=""> tags in the html pages. Here's a fragment:

Code: [Select]

<img src="https://api.xively.com/v2/feeds/1234567890/datastreams/roof_out_temp.png?width=730&height=250&
colour=F15A24&timezone=+10&duration=^|hours&xlabel=hours&l=temp%20(C)&b=true&g=true"
alt="roof_out_temp.png plot here"/>


Notice that after "duration" I have a ^| placeholder inserted -- that's the equivalent of one of the STX characters in your html template files.

That's so I can dynamically specify how much history to display in the graphs (from 1 hour to ten days.)

(Also, I substituted my actual Xively feed id with "1234567890" for the example above.)

Does that help answer your question at all?




ok, that was what i was worried about, it requires an outside server, i hoped it was processed by the arduino.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Mar 17, 2014, 07:33 pm
i would like to make a quick update that the latest version of the code i have posted has been running on my system continuously for 2 months and 17 days (as of this posting) and going strong without a single hiccup.

as long as the system stays running and does not fault on its own (for example, if i loose power, then that is not the project's fault) i will update the post with the new run time to document the stability.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: pico on Mar 27, 2014, 04:01 pm

i would like to make a quick update that the latest version of the code i have posted has been running on my system continuously for 2 months and 17 days (as of this posting) and going strong without a single hiccup.

as long as the system stays running and does not fault on its own (for example, if i loose power, then that is not the project's fault) i will update the post with the new run time to document the stability.


Good to hear it's working well. BTW, I did promise to let you know about some of the relatively minor bugs I found when porting your code. The most significant problem of those was in the input buffering routines -- some of that just wasn't robust (but I get the impression you may have revamped that code anyway.) The other problems I came across were in in the HTML. When I created external html files from your header file to play around with, I ran them through a HTML checker (the well-known "HTML Tidy"), and found a surprising number of issues with things like opening and closing tags out of order, things like that. Interestingly, it didn't seem to make much difference on the actual performance of the code, as you would be aware, as all the browsers seemed to cope OK. There was one instance when I fixed the order of the tags and something broke! But it wasn't a big deal, and I actually forget what it was now -- sorry.

Anyway, all relatively minor stuff, and just a heads up if you ever want to dive into the HTML again, a check tool like HTML TIdy is useful to have. My philosophy is that if the code is as close to text-book as possible when you write it, it should hold up for the foreseeable future no matter how browsers decide to change in how they support any "gray area" stuff.  

Thanks once again wallaceb for sharing your excellent project! Some extra karma points for you. :-)
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: lapagecp on Apr 22, 2014, 06:05 pm
Great project. I have my own version of this that I created to monitor/control my coastal carpet python enclosure. If anyone is thinking or recreating your work I just wanted to throw a few ideas in the mix for people to play with. I am in the middle of a redesign where I will be off loading the heavy lifting of the web page and all decision making to a raspberry pi. So basically you write the web page and serve it from the pi. You have a program running on the pi that communicates with the arduino over i2c. The pi program reads its settings from a mysql database and requests sensor readings and ask the arduino to open or close relays storing any data collected and state changes in the database. The web page then displays sensor readings it reads from the mysql database and updates the pi program settings via the database.

The advantage, as I see it, to this approach is that you can use a cheaper arduino or even an attiny85 depending on how inputs you need. Your raspberry pi can easily have additional storage attached and can even control multiple arduinos. I wrote my code such that my pi can ask for individual bytes of data over I2C. That way it can verify that its getting good data from the sensor via the arduino. I like this approach as it makes it very easy for me to add sensors to an arduino and to add arduinos to the I2C bus. Right now I have one arduino for my carpet's enclosure and one to read switches from my houses ADT security system (registers doors opening and closing, motion detection, and garage door state).
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: craigcurtin on Apr 24, 2014, 09:34 am

Great project. I have my own version of this that I created to monitor/control my coastal carpet python enclosure. If anyone is thinking or recreating your work I just wanted to throw a few ideas in the mix for people to play with. I am in the middle of a redesign where I will be off loading the heavy lifting of the web page and all decision making to a raspberry pi. So basically you write the web page and serve it from the pi. You have a program running on the pi that communicates with the arduino over i2c. The pi program reads its settings from a mysql database and requests sensor readings and ask the arduino to open or close relays storing any data collected and state changes in the database. The web page then displays sensor readings it reads from the mysql database and updates the pi program settings via the database.

The advantage, as I see it, to this approach is that you can use a cheaper arduino or even an attiny85 depending on how inputs you need. Your raspberry pi can easily have additional storage attached and can even control multiple arduinos. I wrote my code such that my pi can ask for individual bytes of data over I2C. That way it can verify that its getting good data from the sensor via the arduino. I like this approach as it makes it very easy for me to add sensors to an arduino and to add arduinos to the I2C bus. Right now I have one arduino for my carpet's enclosure and one to read switches from my houses ADT security system (registers doors opening and closing, motion detection, and garage door state).


I would love to see this code if at all possible please ? Particularly the interaction over i2c between the Arduino and the Pi.

I have a home automation project that i am migrating from a picaxe to the Arduino environment and am using i2c to pass values between the  Arduino and the picaxe. The logical extension of this would be move to the Rpi for the web serving etc.

Craig
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Apr 24, 2014, 07:47 pm
yes, please post your code or perhaps post a link to thread you have for your project?  :D
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Jun 03, 2014, 03:29 pm
hi,
I'd appreciate getting your code as well.thanks!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: pico on Jun 03, 2014, 05:51 pm

I am in the middle of a redesign where I will be off loading the heavy lifting of the web page and all decision making to a raspberry pi. So basically you write the web page and serve it from the pi. You have a program running on the pi that communicates with the arduino over i2c.


I've got a write-up of a demo project with example code that does a similar thing distributing the "heavy lifting" part of the web-serving to a Pi, except the Arduinos connect to the Pi via a wireless link using nRF24L01+ radios instead of a wired link.

The demo project was actually inspired by wallaceb's reptile program, and although the demo application doesn't control a vivarium, the web page design will immediately trigger recognition! (Thanks again wallaceb! :-)

Anyway, here's the link to the project pages: http://embeddedcoolness.com/rfxduino-demo-projects/

Note that you can't really compile and run the code in the later stages of the sketch development without the RFXduino gateway system, but even without it the general design principles and structure of the program may be of interest.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: drupalmavie on Jun 19, 2014, 03:35 pm
Hi,
Really it's great project. I'm not expert in arduino. I saw this post before and this gave me idea to do something similar at home. so, i bought a an Arduino mega 2560 with ethernet shield to test this code. I got the boards this morning. I downloaded Arduino IDE 1.0.5 and your code. but when compiling, i got some errors :
Code: [Select]
I:\Users\drupalmavie\Documents\Arduino\libraries\EthernetDNS\EthernetDNS.cpp:25:23: error: wiring.h: No such file or directory
I:\Users\drupalmavie\Documents\Arduino\libraries\EthernetDNS\EthernetDNS.cpp: In member function 'DNSError_t EthernetDNSClass::_sendDNSQueryPacket(const char*)':
I:\Users\drupalmavie\Documents\Arduino\libraries\EthernetDNS\EthernetDNS.cpp:247: error: 'millis' was not declared in this scope
I:\Users\drupalmavie\Documents\Arduino\libraries\EthernetDNS\EthernetDNS.cpp: In member function 'DNSError_t EthernetDNSClass::pollDNSReply(byte*)':
I:\Users\drupalmavie\Documents\Arduino\libraries\EthernetDNS\EthernetDNS.cpp:375: error: 'millis' was not declared in this scope
I:\Users\drupalmavie\Documents\Arduino\libraries\EthernetDNS\EthernetDNS.cpp: In member function 'DNSError_t EthernetDNSClass::resolveHostName(const char*, byte*)':
I:\Users\drupalmavie\Documents\Arduino\libraries\EthernetDNS\EthernetDNS.cpp:402: error: 'delay' was not declared in this scope


As you can see, it's related to wiring.h (this file i can't find it in arduinos core folders) ans i have no idea. how can i solve this?

Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: drupalmavie on Jun 24, 2014, 12:15 pm
Hi,
I resolved the error. it was an outdate library that I used. now, I tested the project and i have to congratulate you for this work.
Good job Man and many thanks for the sharing.
I will learn a lot from this.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jun 27, 2014, 08:59 pm

Hi,
I resolved the error. it was an outdate library that I used. now, I tested the project and i have to congratulate you for this work.
Good job Man and many thanks for the sharing.
I will learn a lot from this.



i am glad to hear you resolved the issue on your own. and i also want to thank you for your compliments.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: gcp900 on Jul 29, 2014, 11:57 am
Hi!!

I've been taking a look at your project and in my opinion is the best arduino project I've ever seen.

Currently I've been doing another project for controlling an irrigation system and I would like to control it with an SD webserver.

The HTML is done, and the most of the webserver works correctly but I've still got a couple of problems. Once of them is that I'm using the get method to send the orders to the arduino board from the SD (I've got an arduino mega) but when I click on differents options quickly it takes time to send the orders and there's a delay. My webserver is much smaller than yours so I guess you have found the correct way to do it.

I would like to ask you, how do you do to send all those orders from the HTML webserver without any delay??

Thanks!!!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jul 31, 2014, 09:39 pm

Hi!!

I've been taking a look at your project and in my opinion is the best arduino project I've ever seen.

Currently I've been doing another project for controlling an irrigation system and I would like to control it with an SD webserver.

The HTML is done, and the most of the webserver works correctly but I've still got a couple of problems. Once of them is that I'm using the get method to send the orders to the arduino board from the SD (I've got an arduino mega) but when I click on differents options quickly it takes time to send the orders and there's a delay. My webserver is much smaller than yours so I guess you have found the correct way to do it.

I would like to ask you, how do you do to send all those orders from the HTML webserver without any delay??

Thanks!!!


thank you very much for the compliment, and as always please feel free to take my code and do as you wish with it  :smiley-mr-green: 8)

now on to the issue at hand, i would like to get a better clarification on what you are trying to do. when you refer to "sending orders from the HTML" are you referring to individual instances of hitting the "submit" button to cause the HTML form to be processed, or are you referring to all of the individual data entry boxes within the HTML form?

if you are referring to the first idea, then yes, there is a delay of (what i would guess to be a second or so) where the data is sent to the arduino (i am also using a mega), the arduino processes the data, and the web-page is subsequently updated. 

if you are referring to the latter, then i am not sure what your issue is. if you follow the standard HTML format

<form action=POST>
<form inputs (I.E. buttons, text boxes, select boxes etc..)
submit button
<end form>

refer here
Code: [Select]
<form action=page3 method=POST>"
  "<p>&nbsp;</p>"
  "<div style=\"margin-left: 250px; margin-right: 10px;\"><table width=\"67%\" height=\"28%\" border=\"1\">" 
    "<tr>"
      "<td colspan=\"2\"><center>Minimum humidity level is 10% maximum hmidity level is 90%<br>All settings will be saved to memory and will persist between power outage</center></td>"
    "</tr>"
    "<tr>"
  "<td height=\"10%\" nowrap=\"nowrap\" class=\"style42\"><strong>Day Time Humidity %</strong></td>"
  "<td><div align=\"center\" class=\"style44\" id=\"ts1\">"
                  "<table>"
                    "\002"
                    "<tr>"
                      "<td>ON:</td>"
                        "<td><input type=\"text\"  align = \"MIDDLE\"  maxlength = \"3\" name=\"1\" value=\"\002\"></td>"
                    "</tr>"
                    "\002"
                    "<tr>"
                        "<td>OFF:</td><td><input type=\"text\"  align = \"MIDDLE\"  maxlength = \"3\" name=\"2\" value = \"\002\"></td>"
                    "</tr>"
                  "</table></div>"
                 "</td>"
    "</tr>"
    "<tr>"
  "<td height=\"10%\" nowrap=\"nowrap\" class=\"style42\"><strong>Night Time Humidity %</strong></td>"
  "<td><div align=\"center\" id=\"tstat1\">"
                  "<table>"
                  "\002"
                    "<tr>"
                      "<td>ON:</td>"
                      "<td><input type=\"text\"  align = \"MIDDLE\"  maxlength = \"3\" name=\"3\" value=\"\002\"></td>"
                    "</tr>"
                    "\002"
                    "<tr>"
                      "<td>OFF:</td>"
                      "<td><input type=\"text\"  align = \"MIDDLE\"  maxlength = \"3\" name=\"4\" value = \"\002\"></td>"
                    "</tr>"
                  "</table></div>"
                "</td>"
    "</tr>"
  "</table>"
  "<br>"
  "<center><input type=submit value=Submit></center>"
  "</div>"
  "</div>"
  "<input type=hidden name=\"99\" value=\"%\">"
  "</form>"
  "</center>"
  "</body>";

/**


all of the HTML data inputs within the <form></form> all get submitted as a single data stream when the submit button is pressed.

i am assuming the first issue is what you are referring to, and if it is, it is a phenomenon inherent in the way the code works.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Aug 20, 2014, 10:07 pm
i figured i would update that the system has been running with zero operational issues for 8 months now. glad to see all of the stability issues in the beginning have been solved.  :smiley-mr-green:
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: Stefan3v on Sep 09, 2014, 07:56 am
last code https://www.dropbox.com/s/0twzm2aztgg8o22/webserver-1.3%2012-22-2013%20-%20Copy.zip not work for me
but "1.1 - 6-6-2013" version runs.
why?
Many thanks!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Sep 09, 2014, 08:39 pm
can you better explain what you mean by not working? are there compilation errors? does it malfunction when you try download the code? please be as specific as possible.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: Stefan3v on Sep 11, 2014, 08:19 am
Compilation and uploading are ok, problems occur when trying to access the webserver. http://www.youtube.com/watch?v=j-hMHYPpOUA&feature=youtu.be
If I connect  first  the USB cable and after 5 second eth cable the  webserver it works.
Not connected sensors and RTC module not work (time and date are 45: 165: 85 165/165/20165)
Thanks and sorry for my english!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Sep 14, 2014, 05:19 am
So to confirm, if you connect the usb cable to power the system and then connect the Ethernet cable, the system works, and that if you do not have the sensors attached it works?

What are you using to power the arduino? Are you using the usb connection, or are you using a external power supply?
At the moment, I do not have enough information from you to know what might be wrong.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: prnet on Sep 25, 2014, 09:44 am
wellllll done!
I made a very similar project too, with arduino mega, ethernet, ds1307, microsd, dht22 and nokia display. Seems our project are twins!

I'm curious to take a look at web server code. I become crazy to programming mine.


Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Nov 02, 2014, 05:25 pm
Hi,


How would it be possible to add login/password for more security ?
thanks
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Nov 04, 2014, 05:47 pm
Hi,


How would it be possible to add login/password for more security ?
thanks
short answer... yes it could be added.

long answer... i have looked into it, but i could not decide how to properly implement it while working around the web-server base code used within the project and how to handle any session ID information to confirm if the currently connected client is authenticated or not and to control if the authentication has timed out.

with that said, my home router is configured to block all ports and other access from the outside, unless i first log into the router's own VPN server functionality where i can then securely access the controller. this was so much easier to implement that i have not bothered and do not plan to implement password security.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: iulianxprojects on Nov 22, 2014, 08:57 pm
Hello, I'm new here.
I want to make a home automation with temperature control.
I found this code useful and after dealing with the compiling errors, I finally managed to upload the code to the board.
Now I don't know how to access the server. Can you please help me?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Nov 24, 2014, 05:50 pm
Hello, I'm new here.
I want to make a home automation with temperature control.
I found this code useful and after dealing with the compiling errors, I finally managed to upload the code to the board.
Now I don't know how to access the server. Can you please help me?
download this to the arduino, it will configure all the EEPROM.
download the normal code to the arduino and the web-page default URL is static at 192.168.1.200
you can then configure all the settings to your likings.


https://www.dropbox.com/s/we0tnxp3h0w90al/webserverinit.rar
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: iulianxprojects on Nov 28, 2014, 05:01 pm
I did this and the web page don't start. I used cmd to ping the ip and I've got ping, so the server is working.
My question is: it's necessary to have the RTC atached to start?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Dec 01, 2014, 01:07 pm
I did this and the web page don't start. I used cmd to ping the ip and I've got ping, so the server is working.
My question is: it's necessary to have the RTC atached to start?
not that I am aware of. can you add in some serial prints within the main loop to confirm the loop is running properly?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: Thomas499 on Dec 15, 2014, 08:21 pm
Quote
please download this file:

https://www.dropbox.com/s/cun7nqg9qrlfj9k/1.1%20-%206-6-2013.zip

go into the zip file's libraries folder and copy the following into your Arduino IDE library folder:
EthernetBonjour
EthernetDHCP
EthernetDNS
OneWire

those will give you all the needed external library files the compiler is complaining about.

my bad!  :smiley-roll-blue:
Are these files available for Wi-Fi by any chance?

Another question I have is I have uploaded the sketch successfully without any errors showing up, but when I click on the serial monitor this is all that comes up
Quote
«˜à•¢N%¶‘,Iÿ
I don't have a SD card yet, but should that matter as far as the serial monitor is concerned?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Dec 16, 2014, 06:50 pm
Are these files available for Wi-Fi by any chance?

Another question I have is I have uploaded the sketch successfully without any errors showing up, but when I click on the serial monitor this is all that comes up  I don't have a SD card yet, but should that matter as far as the serial monitor is concerned?
i did not design it for wifi support however the code (both the initialization code and the main code) can be updated to include that functionality. have fun!  :smiley-cool:  if you do update it, would you be so kind as to post it?

when it comes to the serial monitor, are you using the right baud rate? if you are, i honestly do not know what it is trying to output. i believe i documented out all instances of serial.print as the code is stable.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: max8051 on Dec 18, 2014, 04:59 pm
I got strange error.
I always get 404 error...
I tried to see what i get and got to this...

this is my debug ediiting if readRequestLine function:
Code: [Select]
Serial.println(readBuffer);
char * pMethod  = strtok(readBuffer, pSpDelimiters);
char * pUri     = strtok(NULL, pSpDelimiters);
char * pVersion = strtok(NULL, pSpDelimiters);
global_pUri     = strtok(NULL, pSpDelimiters);
Serial.println(readBuffer);
Serial.println(pMethod);
Serial.println(pUri);
Serial.println(pVersion);
Serial.println(global_pUri);


Code: [Select]
GET /page2 HTTP/1.1
GET






2 lines data and 4 lines NULL

where is my error?

I try to access the page with : http://10.0.0.17/page2

Thanks
Your work is awesome!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Dec 22, 2014, 01:42 pm
I got strange error.
I always get 404 error...
I tried to see what i get and got to this...

this is my debug ediiting if readRequestLine function:
Code: [Select]
Serial.println(readBuffer);
char * pMethod  = strtok(readBuffer, pSpDelimiters);
char * pUri     = strtok(NULL, pSpDelimiters);
char * pVersion = strtok(NULL, pSpDelimiters);
global_pUri     = strtok(NULL, pSpDelimiters);
Serial.println(readBuffer);
Serial.println(pMethod);
Serial.println(pUri);
Serial.println(pVersion);
Serial.println(global_pUri);


Code: [Select]
GET /page2 HTTP/1.1
GET






2 lines data and 4 lines NULL

where is my error?

I try to access the page with : http://10.0.0.17/page2

Thanks
Your work is awesome!
i am uncertain as to why you get a page not found error. i assume you properly initialized all of the EEPROM settings by downloading the "webserverinit" code?

i would sprinkle some serial print commands throughout the code so that you can see the system run through the programming and possibly help you see if something is getting hung up.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: max8051 on Dec 25, 2014, 08:59 am
changed it to:
Code: [Select]
char * pMethod  = strtok(readBuffer, " ");
char * pUri     = strtok(NULL, " ");
char * pVersion = strtok(NULL, " ");
global_pUri     = strtok(NULL, " ");

now working...

Next problem is submiting huge amount of data...
I have 50 lines and every line have 6 data entries, the max length is 5 chars but it does not work.
the submit is getting error... I this it cant handle it.
I think that the problem is somewhere in PROCESSREQUESTCONTENT function and the readHttpRequest.
Can you advise what to change to get it working?
Maybe making the requestContent var to a bigger size? now it char[512].
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Dec 30, 2014, 03:48 am
changed it to:
Code: [Select]
char * pMethod  = strtok(readBuffer, " ");
 char * pUri     = strtok(NULL, " ");
 char * pVersion = strtok(NULL, " ");
 global_pUri     = strtok(NULL, " ");

now working...

Next problem is submiting huge amount of data...
I have 50 lines and every line have 6 data entries, the max length is 5 chars but it does not work.
the submit is getting error... I this it cant handle it.
I think that the problem is somewhere in PROCESSREQUESTCONTENT function and the readHttpRequest.
Can you advise what to change to get it working?
Maybe making the requestContent var to a bigger size? now it char[512].
i am surprised the code works, as that is where the code determines if the submittable is a GET or a POST, and other important aspects of the submitted HTTP header. i am glad though that you seem to have fixed your particular issue.


when it comes to the submitted data issue, the main issue is likely to do with the size of "STRING_BUFFER_SIZE" under webserver.h

every time HTTP data is submitted, it is saved into that buffer data type using the variable "requestContent" (and other variables that use that same data type). remember that the standard header response from a browser contains a lot of information, 99% of which we do not care about like browser version, OS version etc... to accommodate the data already submitted, i needed a 256 byte buffer to prevent issues with different browsers. you will likely need to raise this to perhaps 512 bytes

see if this helps. what are you submitting that requires so much data?

edit: i see you said you already tried 512... you can try increasing another 128 or 256 bytes. i think there should be enough RAM to handle that, but i am not sure.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Apr 17, 2015, 02:02 pm
i will be posting an updated version of code that adds more error logging functionality later tonight. currently the "System Status" page tells you the number of times a sensor error has occurred. but it did not tell you what sensor was bad, or when the last error was detected.

the new code lists the number of errors detected on a sensor by sensor basis, and tells you both the date and time the last error was detected for that particular sensor. this will help anyone if they experience intermittent sensor malfunctions.   
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on May 08, 2015, 10:56 am
Hi,

Would you share your updated code please ?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on May 12, 2015, 02:01 pm
oh... i thought i updated the first post with the new version but it appears it did not take. very sorry about that. i will post it tonight.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on May 13, 2015, 11:38 pm
will appreciate, thanks!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: EvanCh on May 17, 2015, 11:22 am
Hi,

Great project ! I'm new to arduino and I have a project which is a candy dispensing device which requires scheduling dispensing time of the candies and view the dispensing logs via webpage.
My parts include arduino mega 2560, lcd shield, ethernet shield, pressure sensor, rtc and servo motor.

I found your project useful especially page 4,5 and 6. However, your code looks complex and I do not know how to modify it. Do you have a simplified version which only consists of page 4 to 6?

Thanks in advance
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: myggle on Jun 12, 2015, 01:30 pm
Fantastic project wallaceb!!!  I wish I would have stumbled upon this thread 6 months ago, but I find solace knowing I learned a butt ton in those 6 months so it wasn't a complete waste.  I built a project to control indoor garden/greenhouse that I do intend to make way more complex over time, but for now I have a functional Phase 1 of my project which now consists of a 12"x12"x6" utility box that houses 8 duplex AC outlets on the face and a single Male grounded plug to accept 125VAC from an extension cord.  On the side, I have a single DHT22 sensor, Reset-En leads, soon to be a switch to handle power selection for the EtherMega, and also ports for data wires.  Inside the box is an 8 channel relay that connects to my EtherMega (EM) (freetronics).  On the prototyping area of the EM, I soldered a Chronodot RTC.  The DHT22 sits on pin A2, and the relays are on pins D30-D37.  As of now, my sketch (attached) toggles the relays in accordance with time or climatic conditions.  I know my sketch is a mess in terms of code structure and layout, but it compiles and works, plus it is what I am using to learn Arduino and coding, and this project is what gives me incentive to press on in my studies.

(http://i1.wp.com/skydroponics.com/wp-content/uploads/2015/06/IMG_20150601_1131401.jpg)

I greatly desire to add internet connectability to my project and am holding myself to that goal before I will consider phase 2, 3 or 4.  Your project appears to be almost exactly what I am seeking.  Oh, I forgot to mention that I got antsy and jumped the gun and went and got me a PHP website as my studies suggested that I'd need to secure a domain if I wanted to connect to my project via URL.  So it is my end goal to get my project's data and pin states displayed on this website, but I am prepared to abandon the site if need be.

Before I open your zip file and begin testing your sketch, and what of your project would apply to mine, I feel a bit more learning is needed, and hope I can pick your brain (other people too) for at least key words to study, but links to good material would also be appreciated.  I lack knowledge in how serial communications work, and which types are being used, like SPI v. i2c v. SCL/SDA.  I have been through very many searches on this topic and still feel very uninformed.  Also, I know absolutely nothing about sending data streams, ie converting to strings/arrays, calculating things like sting lengths or buffers, then sending the data out.  I feel a good analyzation of your sketch, or something along those lines would be good.  I've been through the 20 chapter WebServer tutorial that serves an HTML page from the micro SD card.  Is your sketch an extended version of that?  Perhaps I should revisit that tutorial as I likely did not retain enough.

To recap, I seek Serial and data sharing literature. 

At any rate, thank you for sharing your project 2 years ago, and remaining open for questions and assistance for the time in between.  I do know I will learn a lot when I get into your files, and for that I am pre-appreciative!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: Abhijit_Pal on Jun 20, 2015, 10:28 am
Really nice project.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jun 22, 2015, 01:16 pm
sorry i have not posted sooner, i just finished moving, and i lost track of uploading my newest code and responding to this thread  :smiley-cry:  :smiley-cry:  :smiley-cry:

Really nice project.
thanks!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jun 22, 2015, 01:25 pm
Before I open your zip file and begin testing your sketch, and what of your project would apply to mine, I feel a bit more learning is needed, and hope I can pick your brain (other people too) for at least key words to study, but links to good material would also be appreciated.  I lack knowledge in how serial communications work, and which types are being used, like SPI v. i2c v. SCL/SDA.  I have been through very many searches on this topic and still feel very uninformed.  Also, I know absolutely nothing about sending data streams, ie converting to strings/arrays, calculating things like sting lengths or buffers, then sending the data out.  I feel a good analyzation of your sketch, or something along those lines would be good.  I've been through the 20 chapter WebServer tutorial that serves an HTML page from the micro SD card.  Is your sketch an extended version of that?  Perhaps I should revisit that tutorial as I likely did not retain enough.

To recap, I seek Serial and data sharing literature. 

At any rate, thank you for sharing your project 2 years ago, and remaining open for questions and assistance for the time in between.  I do know I will learn a lot when I get into your files, and for that I am pre-appreciative!
to be honest, i relied heavily on other people's work to get my project completed.


to get the web-server running i used the code here:
http://playground.arduino.cc/Code/WebServer

Note: i used the "Extended Functionality" code which is half way down the page

i analyzed it for a while figuring out how everything worked and i used it as a base. this made up 90% or more of my project's web-page based interface. this code already had a method of supporting file downloads off internal Progmem flash memory. i modified it using the SD card library to pull images and log files off the SD card.


i used the general one-wire bus library available online to give me temperature feedback.

i used the general RTC library to interface with the RTC module

i used downloadable libraries to add support for the updating of time off on-line time servers ect..

in a nut shell, i decided what functionality i wanted and i researched for already available code. once i found it, i analyzed it, figured out how it worked, and integrated it into my project.

some of the areas i made from scratch was the code to parse the POST and GET data. originally i used the String library, but kept having memory leakage errors so i moved 100% to char arrays which actually reduced my project flash memory size and also my RAM usage.

if you have specific items you would like help with, post them to this thread and we will see what we can do.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: EvanCh on Jun 25, 2015, 11:02 am
Hi,

i have hosted my webpage on the arduino ethernet shield's SD card. I would like to write logs to the SD card and post it on the webpage. May i know how this should be done? Currently, based on the code below, log.htm is created in SD card but its empty. May i know what's wrong with the code?

void WriteLogs()
{
 
  Serial.print("writing to logs......");
  char newfile[12] = "";
  if (abs(((seconds + (minutes) + (hours)) - last_time_data_saved)) >= data_log_period){ 
       last_time_data_saved = (seconds + (minutes) + (hours));

     
   sprintf(newfile,"log.htm");
        Serial.println(newfile);

         if (!SD.open(newfile, FILE_READ)){                                                                                                         //does the file already exist?
           SD.open(newfile , FILE_WRITE);                                                                                     // no the file does not exist, lets create the file

           //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\">Dispensed?</td>"                                       
         "</tr>"));
            file.close();

         }else{
           //yes the file exists, close the file and move on
           file.close();

         }

       else {
         //we have already created the file, now we need to append the log data to it as the headers are already written to it.
         SD.open(newfile , FILE_WRITE);                                              

         file.print(F("<tr>"));
         file.print(F("<td align = \"center\">"));

         file.print(newfile);
         file.print(F("</td>"));
         file.print(F("<td align = \"center\">"));
         sprintf (newfile, "%.2d:%.2d:%.2d", hours, minutes, seconds);
         file.print(newfile);
         file.print(F("</td>"));
         file.print(F("<td align = \"center\">"));

       if (flexiForceReading >1 && singbreak==1){
         
               file.print("Yes");
         }
 
      }

         file.print(F("</td>"));
         file.print("</tr>");
         file.close();
 
      }
     }
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jun 25, 2015, 01:17 pm
here is the code out of mine:

Code: [Select]
root.rewind();
     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();
       }
     }


it does appear that you are using a different SD library or different syntax as the one i used.

have you done more basic sketches to make sure your code in a stand-alone manner will write to the SD card? when i first started learning how to use the SD card, i created mini sketches to get a better understanding of what my code was doing.


the code to initialize my SD card is as follows:
Code: [Select]
 

//SD card required variabled
Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;
byte SD_init_OK;    //did the SD card initilzie ok? 1 = yes, 0 = no
byte SDFAT_init_OK;  //does the SD have an active FAT file system? yes = 1, no = 0
byte FAT_Type;        //what kind of file system does the card have? FAT32? FAT16?
byte root_OK;        //cold we open the root of the SD card? yes = 1, no = 0
byte SD_Type;      //is the SD card a SDHC or something else?
double volumesize;  //how much space is on the card in bytes?
double SD_USED_SPACE = 0;  //how many bytes of space is used on the card?
byte data_log_enabled = 0;  //does the user want data logging on or off? 1 = on, 0 = off
byte data_log_period = 10;  //how often does a sample get taken if data logging is enabled? 1 per 10, 20, 30, 40, 50, or 60 seconds?
byte counter;                //msic variable used by data logging

pinMode(53, OUTPUT);//required for SD library!
  //because of an issue with the SD library, if NO SD card is present, the SPI bus runs very slow because of changes made to two registers.
  //we are going to make a backup of these registers now before we nitilize the SD card.
  //that way, if no SD card is fond, we can re-initilize those registers back to their proper values 
  uint8_t spcr = SPCR;
  uint8_t spsr = SPSR;
  if (!card.init(0, 4)){
    SD_init_OK = 0;//SD card not initilized
    //no SD card found, restore the SPI bus settings for full speed
    SPCR = spcr;
    SPSR = spsr;
    data_log_enabled =0;
  }else{
    SD_init_OK = 1;//SD card initilized OK
    // initialize a FAT volume
    if (!volume.init(&card)){
      SDFAT_init_OK = 0;//FAT volume not initilized
      data_log_enabled =0;
    }else{
      SDFAT_init_OK = 1;//FAT volume initilized OK
      FAT_Type = volume.fatType();//what kind of fat is the card formatted with?
      if (!root.openRoot(&volume)){
        root_OK = 0;//the root of the SD card could not be opened!
        data_log_enabled =0;
      }else{
        root_OK = 1;
        SD_Type = card.type();                    //what kind of card was inserted?
        volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
        volumesize *= volume.clusterCount();       // we'll have a lot of clusters
        volumesize *= 512;                            // SD card blocks are always 512 bytes
      }
    }
  }

Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: EvanCh on Jul 06, 2015, 08:25 am
Thanks for your help. I created a small program to test out how the program behaves and added to my original code.

I have another problem. I'm able to generate the log file and it is currently exists in the SD card. How do   I display the log file onto my website? or maybe list the files of a particular folder in the SD card on the website?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jul 07, 2015, 03:10 pm
the code i use to display a list of all the files in the root of the SD card is as follows:


Code: [Select]
if (SD_init_OK ==1 && SDFAT_init_OK == 1 && root_OK ==1){
               ListFiles(client, LS_DATE);
             }else{
               client.print("");
             }



the code used to allow the downloading of the file is as follows:

Code: [Select]
if (nUriIndex < 0)//is the URL NOT a system page (pages 1 through 8?) then we need to see if ther requested page is a file contained on the SD card
    {
       root.rewind();
       if (! file.open(root, strstr(global_pUri,"/")+1, O_READ)) {
         sendProgMemAsString(client, (char*)pgm_read_word(&(page_404[0])));//if there is no applicable file on the SD card, then we need to display a file/page not found error
       }else{
         //if the file is found, print out its contents to the web-browser
         int16_t c;
         byte clientBuf[128];
         byte clientCount = 0;
         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;
         }
         while ((c = file.read()) >= 0) {
           clientBuf[clientCount] = c;
           clientCount++;
           if(clientCount > 127)
           {
             client.write(clientBuf,128);
             clientCount = 0;
             wdt_reset();
           }
         }
         //final <128 byte cleanup packet
         if(clientCount > 0) client.write(clientBuf,clientCount);           
         // close the file:
         file.close();
       }
    }


the part of the 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{


is to make sure the .png files used on the main page are not downloadable.

hope this helps.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Jul 08, 2015, 03:29 pm
Hi wallaceb,

Your project is superb, not mentioning it is very stable.

Have some basic knowledge, I am able to redesign your great project for my needs but not advanced as you, wallaceb.

I was thinking of using it for a small home automatization project, but it would require wireless connection for 2-3 rooms with wifi shield, wifi adafruit shield or even the ESP8266 which would be the best in terms of size and wifi module price.

Have you ever been thinking of wireless connection, how could I implement wireless connection in to your project please?

Appreciate even a fraction of your knowledge.

Best
Marcin
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jul 08, 2015, 07:38 pm
i did think about adding WIFI support but preferred the hardwired approach. i do not think it would be too hard to do so as the Ethernet library would be replaced and a few additional variables would be added to account for SSID and password.

what i would recommend is getting a WIFI access point. this will allow you to pick up a WIFI signal, convert it back to an Ethernet one. the WIFI access point would be easier to configure IMO.  since i do not have a WIFI shield, and have never used one, i do not know exactly how i would implement one into the code.

i have one of these in my house to jump from one floor to the other using WIFI and convert back to Ethernet.
http://www.amazon.com/gp/product/B00E98O7GC

currently priced at $20
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jul 21, 2015, 01:14 pm
i have an interesting update. the RTC module used on my system went bad. the behavior it showed when it went bad is what i think is funny.

the RTC was still incrementing time correctly and i could read from it, however i could no longer write to it. i noticed this because the RTC one morning was 8 hours off from where it should have been (causing the UV light to be on when it should not have been). nothing i did could get the date/time to change.

i loaded a different sketch to do some SPI debugging. the RTC registered on the bus fine, but again, nothing i did could get the RTC module to accept any write commands.

i removed the module and put in another module from a different project and date/time functionality in the reptile controller worked again.

i looked at the old module, the battery voltage was fine and i saw no apparent damage. i think the chip just went bad...

anyways, that is all for now.... rant over  :)
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: myggle on Jul 21, 2015, 09:06 pm
That is strange about the RTC. 

Regarding your wifi repeater, does it have good range?  Does it go through floors and walls good?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jul 22, 2015, 05:07 pm
That is strange about the RTC. 

Regarding your wifi repeater, does it have good range?  Does it go through floors and walls good?
the range through several brick walls was about 100 feet
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: thailuonghoai on Jul 23, 2015, 04:47 pm
Hello you wallaceb can talk to her via skype thailuonghoai111088 okay?
his thank you and wish you good health!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: Thomas499 on Sep 12, 2015, 04:29 pm
I am curious, if you had to do this project again, would you go the same route or would you use an app builder like firebase (https://www.youtube.com/watch?v=0Z1QYfRox-g) or app builder 2 (https://www.youtube.com/watch?v=6o_QVlltNgM)? Why or why not?

Also, is there any way you could post a simple example to show how to get your buttons (picture files saved on sd card) on the server to show up on the SimpleWebServerWiFi example?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Sep 14, 2015, 09:40 pm
I am curious, if you had to do this project again, would you go the same route or would you use an app builder like firebase (https://www.youtube.com/watch?v=0Z1QYfRox-g) or app builder 2 (https://www.youtube.com/watch?v=6o_QVlltNgM)? Why or why not?

Also, is there any way you could post a simple example to show how to get your buttons (picture files saved on sd card) on the server to show up on the SimpleWebServerWiFi example?
i wanted a web-based interface so i could use any device (Mac, PC, Andriod, Iphone) without worry about compatibility. i also have done web design and understand HTML and website scripting very well so it was an easy place to start.

for the SD card stuff, here is some of the code explained


the different variables i have
Code: [Select]
//SD card required variabled
Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;
byte SD_init_OK;    //did the SD card initilzie ok? 1 = yes, 0 = no
byte SDFAT_init_OK;  //does the SD have an active FAT file system? yes = 1, no = 0
byte FAT_Type;        //what kind of file system does the card have? FAT32? FAT16?
byte root_OK;        //cold we open the root of the SD card? yes = 1, no = 0
byte SD_Type;      //is the SD card a SDHC or something else?
double volumesize;  //how much space is on the card in bytes?
double SD_USED_SPACE = 0;  //how many bytes of space is used on the card?


initialization code
Code: [Select]
pinMode(53, OUTPUT);//required for SD library!
  //because of an issue with the SD library, if NO SD card is present, the SPI bus runs very slow because of changes made to two registers.
  //we are going to make a backup of these registers now before we nitilize the SD card.
  //that way, if no SD card is fond, we can re-initilize those registers back to their proper values  
  uint8_t spcr = SPCR;
  uint8_t spsr = SPSR;
  if (!card.init(0, 4)){
    SD_init_OK = 0;//SD card not initilized
    //no SD card found, restore the SPI bus settings for full speed
    SPCR = spcr;
    SPSR = spsr;
    data_log_enabled =0;
  }else{
    SD_init_OK = 1;//SD card initilized OK
    // initialize a FAT volume
    if (!volume.init(&card)){
      SDFAT_init_OK = 0;//FAT volume not initilized
      data_log_enabled =0;
    }else{
      SDFAT_init_OK = 1;//FAT volume initilized OK
      FAT_Type = volume.fatType();//what kind of fat is the card formatted with?
      if (!root.openRoot(&volume)){
        root_OK = 0;//the root of the SD card could not be opened!
        data_log_enabled =0;
      }else{
        root_OK = 1;
        SD_Type = card.type();                    //what kind of card was inserted?
        volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
        volumesize *= volume.clusterCount();       // we'll have a lot of clusters
        volumesize *= 512;                            // SD card blocks are always 512 bytes
      }
    }
  }


the code to send the data to the browser
Code: [Select]
root.rewind();
       if (! file.open(root, strstr(global_pUri,"/")+1, O_READ)) {
         sendProgMemAsString(client, (char*)pgm_read_word(&(page_404[0])));//if there is no applicable file on the SD card, then we need to display a file/page not found error
       }else{
         //if the file is found, print out its contents to the web-browser
         int16_t c;
         byte clientBuf[128];
         byte clientCount = 0;
         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;
         }
         while ((c = file.read()) >= 0) {
           clientBuf[clientCount] = c;
           clientCount++;
           if(clientCount > 127)
           {
             client.write(clientBuf,128);
             clientCount = 0;
             wdt_reset();
           }
         }
         //final <128 byte cleanup packet
         if(clientCount > 0) client.write(clientBuf,clientCount);            
         // close the file:
         file.close();
       }
    }



adjusting the above code within the wifi example should get the functionality to work.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: private1492 on Nov 08, 2015, 10:58 pm
error compiling  :smiley-eek-blue:  :smiley-eek-blue:  :smiley-eek-blue:  :smiley-eek-blue:  wallaceb,please send the last code and libraries..... sorry
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Nov 09, 2015, 03:35 pm
what link did you use to download? the latest should have the libraries.


the latest code is here:
https://www.dropbox.com/s/0twzm2aztgg8o22/webserver-1.3%2012-22-2013%20-%20Copy.zip

to "initialize" your MEGA, you need to configure the EEPROM

download the below link to the arduino, it will configure all the EEPROM.
download the normal code (version 1.3) to the arduino and the web-page default URL is static at 192.168.1.200
you can then configure all the settings to your likings.

https://www.dropbox.com/s/we0tnxp3h0w90al/webserverinit.rar


if the version 1.3 zip does not have the libraries, go through this thread and look for the 1.1 version, which should have them.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: exxon on Feb 02, 2016, 09:40 pm
IDE version 1.6.6 will not compile.  :(  Any solutions? In addition to switching to the old version.  :D
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Feb 03, 2016, 07:57 pm
IDE version 1.6.6 will not compile.  :(  Any solutions? In addition to switching to the old version.  :D
can you give me details on the errors you get?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: miketheitguy on Apr 17, 2016, 04:57 am
Hello Wallaceb,

(SOLVED)

Love your project and detail.

I am also getting a lot of errors on compiling this project can you please help?

I have attached a txt file due to large number of error can you please take a look.
I hope this is a simple fix

Many thanks,

Mike.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: miketheitguy on Apr 19, 2016, 01:30 am
To Wallaceb and all who have used this project code.

After successfully having this working. But i noticed one strange issue,

This is the UV Lamp will not stay on for 12 hours i think the longest it will stay on for is 3-4hours which is very strange.

Date/Time temps everything else is working as it should.

Could someone give me a little guidance please... i'm pulling my hair out! :(

Their was one other small issue being 12hours out IE 10am is showing 22hours (10pm) none of the setting changed this correctly in the time/date setting UTC +12 is correct for New Zealand, but no big i can live with this.

This is probably really simple to fix for the knowledgable ones...

Thanks All,

Mike.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: Morke on Apr 30, 2016, 01:35 am
Omg this project is perfect and terrible at the same time for me.
I got into arduino just to build something like this, so I was very excited when I found this thread
but when I opened the scripts I almost fainted.
This is WAY complex for a starter :( The only part I get is web coding...
I hope I can understand it someday..
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on May 04, 2016, 12:37 pm
To all, i apologize for not responding sooner. I generally check this thread once a week, but I have not checked it since February....

Omg this project is perfect and terrible at the same time for me.
I got into arduino just to build something like this, so I was very excited when I found this thread
But when I opened the scripts I almost fainted.
This is WAY complex for a starter :( The only part I get is web coding...
I hope I can understand it someday..
Please feel free to post questions on how sections of the code work. Everyone needs to start somewhere


To Wallaceb and all who have used this project code.

After successfully having this working. But i noticed one strange issue,

This is the UV Lamp will not stay on for 12 hours i think the longest it will stay on for is 3-4hours which is very strange.

Date/Time temps everything else is working as it should.

Could someone give me a little guidance please... I'm pulling my hair out! :(

There was one other small issue being 12hours out IE 10am is showing 22hours (10pm) none of the setting changed this correctly in the time/date setting UTC +12 is correct for New Zealand, but no big i can live with this.

This is probably really simple to fix for the knowledgeable ones...

Thanks All,

Mike.
I actually am not sure what is wrong there. Would you for experimentation, change your time zone to "(UTC-6:00) Central (US & Canada)" and see if everything works?
I have been using this code for years and in my snakes cage i have the light on for 13.5 hours per day and everything seems to work. I am wondering if there is a glitch with how the time zone factors into things...



Hello Wallaceb,

(SOLVED)

Love your project and detail.

I am also getting a lot of errors on compiling this project can you please help?

I have attached a txt file due to large number of error can you please take a look.
I hope this is a simple fix

Many thanks,

Mike.
Looking at your errors, i think i can fix 99% easily if you add one line of code to the beginning where i include all the libraries. It appears that between the versions of the compiler I originally used and now, the "PROGMEM" declaration is not self-supported but requires:

Code: [Select]
#include <avr/pgmspace.h>

Refer here for additional details:
https://www.arduino.cc/en/Reference/PROGMEM

If you properly include the pgmspace.h library that is available in the AVR architecture, nearly all of those errors should go away
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: ceres_ces on Jun 02, 2016, 02:47 am
i can't undestand how you fixed that problem.
i found pgmspace.h sourcecode from Atmel and i pasted it on notepad then renamed it like*.h.
so i copyed it like library on my libraries folder. the compiler recognised it like a valid library but i continue to have your specific errors on compiler step.
 :smiley-sad-blue:
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: ceres_ces on Jun 02, 2016, 04:58 am
i've found this topic:
http://forum.arduino.cc/index.php?topic=272313.0
and so i replaced all prog_char with const char.
then i replaced
PROGMEM const char *basic_table[] =

with:
PGM_P const basic_table[]  PROGMEM =

then the compiler gone well but....
it give me:

Arduino:1.6.8 (Windows 10), Scheda:"Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

In file included from sketch\Ethernet\interactive-matter-HTTPClient-af6ba9a\HTTPClient.cpp:27:0:

sketch\Ethernet\interactive-matter-HTTPClient-af6ba9a\HTTPClient.cpp: In member function '__file* HTTPClient::getURI(char*, http_client_parameter*, http_client_parameter*)':

sketch\Ethernet\interactive-matter-HTTPClient-af6ba9a\HTTPClient.cpp:78:45: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]

   sendUriAndHeaders(result, this->hostName, PSTR("GET"), uri, parameters,

                                             ^

In file included from sketch\Ethernet\interactive-matter-HTTPClient-af6ba9a\HTTPClient.cpp:29:0:

sketch\Ethernet\interactive-matter-HTTPClient-af6ba9a\HTTPClient.h:191:3: error:   initializing argument 3 of 'char HTTPClient::sendUriAndHeaders(__file*, char*, char*, char*, http_client_parameter*, http_client_parameter*)' [-fpermissive]

   sendUriAndHeaders(FILE* stream, char* hostName, char* requestType, char* uri,

   ^

In file included from sketch\Ethernet\interactive-matter-HTTPClient-af6ba9a\HTTPClient.cpp:27:0:

sketch\Ethernet\interactive-matter-HTTPClient-af6ba9a\HTTPClient.cpp: In member function '__file* HTTPClient::postURI(char*, http_client_parameter*, char*, http_client_parameter*)':

sketch\Ethernet\interactive-matter-HTTPClient-af6ba9a\HTTPClient.cpp:107:45: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]

   sendUriAndHeaders(result, this->hostName, PSTR("POST"), uri, parameters,

                                             ^

In file included from sketch\Ethernet\interactive-matter-HTTPClient-af6ba9a\HTTPClient.cpp:29:0:

sketch\Ethernet\interactive-matter-HTTPClient-af6ba9a\HTTPClient.h:191:3: error:   initializing argument 3 of 'char HTTPClient::sendUriAndHeaders(__file*, char*, char*, char*, http_client_parameter*, http_client_parameter*)' [-fpermissive]

   sendUriAndHeaders(FILE* stream, char* hostName, char* requestType, char* uri,

   ^

In file included from sketch\Ethernet\interactive-matter-HTTPClient-af6ba9a\HTTPClient.cpp:27:0:

sketch\Ethernet\interactive-matter-HTTPClient-af6ba9a\HTTPClient.cpp: In member function '__file* HTTPClient::putURI(char*, http_client_parameter*, char*, http_client_parameter*)':

sketch\Ethernet\interactive-matter-HTTPClient-af6ba9a\HTTPClient.cpp:134:45: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]

   sendUriAndHeaders(result, this->hostName, PSTR("PUT"), uri, parameters,

                                             ^

In file included from sketch\Ethernet\interactive-matter-HTTPClient-af6ba9a\HTTPClient.cpp:29:0:

sketch\Ethernet\interactive-matter-HTTPClient-af6ba9a\HTTPClient.h:191:3: error:   initializing argument 3 of 'char HTTPClient::sendUriAndHeaders(__file*, char*, char*, char*, http_client_parameter*, http_client_parameter*)' [-fpermissive]

   sendUriAndHeaders(FILE* stream, char* hostName, char* requestType, char* uri,

   ^

exit status 1
Errore durante la compilazione per la scheda Arduino/Genuino Mega or Mega 2560.


 >:(
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jun 03, 2016, 08:28 pm
i truthfully did not try recompiling the code myself, i was hoping that by adding the additional declaration for the PROGMEM then the code will work.

looking at your errors and looking at the PROGMEM turorial, i think the issue is here:

Quote
Note

Please note that variables must be either globally defined, OR defined with the static keyword, in order to work with PROGMEM.

The following code will NOT work when inside a function:

Code: [Select]
const char long_str[] PROGMEM = "Hi, I would like to tell you a bit about myself.\n";

The following code WILL work, even if locally defined within a function:

Code: [Select]
const static char long_str[] PROGMEM = "Hi, I would like to tell you a bit about myself.\n"
i am leaning more and more towards the conclusion that since the time i wrote this code using what is now a very old version of the compiler and now, a lot of rules pertaining to how to use and implement PROGMEM have changed.

for example, in my "htmldata.h" file i have the following:

Code: [Select]
PROGMEM prog_char basic3[] =" ";

i believe this should be changed to

Code: [Select]
const PROGMEM static char basic3[] =" ";


in addition, in my "webserver.ino" file:

Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jun 06, 2016, 01:45 pm
ok.... i actually had to fix a lot more than i thought. i have not downloaded this onto a board but i was able to get it to finally compile. i have another MEGA and Ethernet shield which i plan to use for verification. i will do this shortly.

if anyone wants to see if they can get the following code to work on their boards:

https://www.dropbox.com/s/uxf89wcth826cj0/2.0%206-6-2016%20experimental.zip?dl=0
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jun 09, 2016, 01:22 am
i just downloaded the code onto another MEGA and ethernet shield i had. it appears all of the code works. i am uncertain as to the stability right now, so i am leaving the unit to sit and see if it has long term running issues.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jun 10, 2016, 01:31 pm
well, i just happened to notice the Ethernet shield is discontinued.  :o  :smiley-confuse:

i discovered this as i am in the planning stages of another project needing internet access and it appears the wifi shield is the way to go....


so, i know at least one person had asked me in the past if i can change this to support wifi and i originally said no.

well, that is changing. to support my new project which was going to re-use this same code, i need to make it support wifi.

yes, you heard that correctly, i am re-writing this project to supply support wifi.

there will be two versions of this, both of which i will continue to support, one dedicated to supporting wifi and the other to supporting Ethernet.

seeing as how i do not yet have a wifi shield and i have limited time, it will take probably into the middle of July for me to get the wifi version released.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: mkcinek on Jun 13, 2016, 05:13 pm
Hi,

Great news!!! I think I asked for wifi support, will come back to my project so.

Did you get another reptile, as wondering is it going to be the same or changing to another system ?

What is more, what specific wifi shield is it going to support ?

Appreciate your great system !!!

thank you !!!
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jun 14, 2016, 01:47 am
Hi,

Great news!!! I think I asked for wifi support, will come back to my project so.

Did you get another reptile, as wondering is it going to be the same or changing to another system ?

What is more, what specific wifi shield is it going to support ?

Appreciate your great system !!!

thank you !!!
this new project only needs the web-server portion (which is like 75% of the reptile controller code  8)  ) and internet access. since i have made that already i now need the code to support the current hardware that is available.

i plan to code it to support the new Arduino WiFi 101 shield.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Jun 17, 2016, 05:24 pm
i am waiting for my wifi 101 shield to arrive. since the wifi shield does not have an SD card slot like the ethernet shield did, and i wanted to clean up the physical look of my work, i have used a mega protoshield to hold an SD card board, the RTC, a and all of the headers for my temperature probes.

you can see what i designed here (https://www.dropbox.com/s/b55sng2t9wxgq8y/Visio-Drawing1.pdf?dl=0):

and you can see the result here (https://www.dropbox.com/s/rnk09k2js2tg7ku/IMG_20160616_115648.jpg?dl=0):

you can also see what it looks like when paired with my existing ethernet shield (https://www.dropbox.com/s/edtb7wbqmv89x24/IMG_20160617_102241.jpg?dl=0).

i made sure to use pin 5 for my new protoboard SD chip select pin so it did not interfere with the SD shield.

please note! what i have shown above is electrically not compatible with the ethernet based project unless you edit the pin assignments used by the temperature probes to the following:

Code: [Select]

#define CSG1wirepin 38
#define MSG1wirepin 44
#define HSG1wirepin 42
#define AA11wirepin 46
#define AA21wirepin 48


and change the SD card initialization to the following if you do not want to use the SD card in the ethernet shield:

Code: [Select]
if (!card.init(0, 5)){
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: Thomas499 on Jul 10, 2016, 10:11 pm
Quote
i plan to code it to support the new Arduino WiFi 101 shield.
To save you some time, I know the original wifi shield had a serious firmware problem. I do not know if the 101 shield fixed this, but when you get the wifi shield run the server code example with blink without delay in there so that the led blinks.

Call the server code, and then leave the arduino running overnight and see if it responds the next day. I found that after you call the server code in the old wifi shield 12 minutes later or less the arduino becomes unresponsive.

I just don't want you to waste several days like I did trying to find out why the code you wrote crashes the arduino, when it was really an issue with the firmware of the WiFi shield.

Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: Rextytus on Sep 13, 2016, 11:05 pm
Hello I want to say hello and ask to set mega arduino ethernet shield and I have uploaded webserver ini setting the IP and DNS. Page opens but does not read sd card. It is a message that the card missing. Is there anything else I should set the card to the ethernet shield work?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: nitrof on Sep 14, 2016, 01:04 am
try to have something like:

put the sd pin to high often make some bug when both using sd and ethernet

#define SDC_PIN 4 // pin for sd card

Code: [Select]
  Serial.print("Initializing SD card...");
  pinMode(SDC_PIN, OUTPUT);  //make sure that the default chip select pin is set to output
  digitalWrite(SDC_PIN, HIGH);
  delay(1);
  if (!SD.begin(SDC_PIN)) {
    Serial.println("Card failed, or not present");
    return;
  }
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: Rextytus on Sep 14, 2016, 09:24 pm
Thanks for the information but still nothing. Page data logging adjust  displays Please check SD Card, NO SD CARD FOUND! I am looking for a solution to this problem three days and nothing?Does anyone have any idea.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: Rextytus on Sep 15, 2016, 08:01 pm
Connecting an external card reader can not solve the problem. It looks like a manual block to read data from the card. After uploading the sd card info read works without a problem.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: Rextytus on Sep 15, 2016, 08:19 pm
Maybe I'm doing something wrong. I set ip data file webserverini loaded into the Arduino Mega with ethernet shield W5100. Then, just a change mac Loading a webserver.ino and all that, you may still need to change something.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: nitrof on Sep 16, 2016, 12:27 am
Try formating the sdcard with an external tool. like https://www.sdcard.org/downloads/formatter_4/ (https://www.sdcard.org/downloads/formatter_4/)
(nerver try this particuliary one... just google it...)
Formating with windows tool somethime cause proble. Read the section of arduino sd lib:SDCardNotes (https://www.arduino.cc/en/Reference/SDCardNotes)

There's some good info there, like file format, to use FAT16 formating...

Regards .

Nitrof
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: Rextytus on Sep 17, 2016, 08:49 pm
Unfortunately, still nothing. I format the card with this program and nothing. I want to say that the same card is easily read on the charge sd card info.
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: nitrof on Sep 18, 2016, 08:45 pm
you should try the example from sd card library. if you do not read it.. it is maybe something more complicated... I'm not a pro as well. But at you should also start a new topic about problem reading sd card. there will be more good people that will help you.

Regards.

Nitrof
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: Rextytus on Sep 18, 2016, 08:57 pm
Well, I just checked, and an example of the library sd card works without a problem. The only problem in this sketch. Have you tried this sketch and work for you?
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: nitrof on Sep 19, 2016, 12:58 am
No. I didn't.

Maybe you should check if file use by the sketch is created by it or have to be already present on the sd card...
Title: Re: Automated Reptile Control System(webserver, Data Logging, RTC and much more)
Post by: wallaceb on Sep 23, 2016, 03:21 am
I am not sure what your issue would be. You said everything else works right, like the temp sensors etc?

I know I am using a slightly different approach to SD cards than the default example sketch. Obviously it is something to do with the project or the library implementation.

To my knowledge no one else has complained about SD card issue