I have Two Arduinos, One with the help of sensors it will dynamically updates in to my server database. Other Arduino, reads the stored contents from the server database and sends sms to phones.
Now, I have a text file in my server which updates dynamically for every 5 min - 10 min. I am trying to read that text file contents.
I want my server to be always connected, So It must be in setup()
function.
I want update only to my text file which dynamically changes, so it must be loop()
function.
How to implement this ? Any Suggestion ?
1 Answer 1
It's difficult to answer without details of how your server works.
If your arduino is simply connected to the server, the server could open the arduino serial port (e.g.: COM5: or /dev/ttyUSB0) and simply read data. The arduino would only need to serialWrite() data for the server to parse and store.
If your arduino is not connected but has ethernet support you could do a HTTP request to your server, and pass the data as a parameters to the request, e.g.:
http://your.server.ip/send_data?param1=10.3¶m2=5.6¶m3=foo
When your server processes this HTTP request, it appends param1, param2, param3 to that text file.
The arduino could also beam data back to your server via IR, or bluetooth, etc.
There's lots of ways to do this.
setup()
and Inloop()
I want to updated only current content in the text file. How to update theclient.print("GET /current.txt");
dynamically inloop()