Im working on a school project, the project is a weather station that is supposed to show the current temperature on a webpage. I already programed the arduino so it displays the temperature, but i need to capture the temperature date and save it to a database each 30 seconnds for example, then i m goin to take the date from the database and display it on the webpage. I just need the code to capture the temperature and save it to the database. Im new to arduino, so if anyone could help me i would appreciate so much.
thanks.
You need a program running on your computer for logging the temperature. I suggest using processing to write it, as it will feel familiar to you, coming from Arduino.
You need to establish a serial connection between the program running on your arduino, and the program you will write in processing. If you look at the tutorials, you will find everything you need.
Once that is done, you need to figure out how to print the values to a text file. Search in the processing documentation - I remember there is already a predifined function which does this for you.
---> www.processing.org
save it to the database
Any database in particular? Or just logging to a flat file?
Alternatively, if you don't want to write your own client application, you could use Gobetwino (on Windows) to execute an SQL query to write your data to the database.
i will use sqlite
i will use sqlite, then from the web page o alreaady created i will get the last temperature registered, i already did this. I just need to capture the arduino data to the database
Probably more trouble than it is worth you could use an Ethernet shield to make requests against your server and use a server-side script on the server to log it to the database. As an example, the Arduino could GET http://127.0.0.10/logtemp.asp?temperature=12.5 where 127.0.0.10 is your web server on your network and logtemp.asp is a quick and dirty ASP page (or CGI page or whatever) that reads the get parameter temperature and writes the value to the sqlite database. You could have the client pass a client ID and have the server log data from multiple arduinos this way too (e.g. GET http://127.0.0.10/logtemp.asp?temperature=12.5&station=1) with one additional column on your table.
starship:
i will use sqlite
In that case, and assuming you're running Windows on the PC, you could use Gobetwino to run an sqlite3 command to execute the SQL query that saves your data to the database.