Originally Posted by jpalarchio
This is along the lines of what I'm thinking. The PID algorithm running on the Arduino is going to need more timely updates from the temperature sensors than I need logged. I don't need 5 billion data points logged during a brew session.
I was trying to avoid writing any type of client/server application and instead leverage existing technologies to make it sort of a web app; still doing a lot of reading there.
The single-threaded nature of the Arduino seems like it might squash some of my initial thoughts.
What I need to do on the Arduino is:
Listen For Action Command From Server (via sockets?) -> Get Current Temperatures -> Execute PID -> Upload Data To Server (via sockets?) -> REPEAT
What's not clear to me within this loop is when I'm waiting for actions from the server, how long do I wait and what does the server do as far as sending when I'm at a point where the Arduino is not listening.
What you are trying to do is typically done via socket io select on the server side (like with apache httpd for example)...
I don't know if the Arduino supports io select but you can build a loop that does similar in a serial nature. Basically you will listen on a socket (a tcp port) in a while 1 loop, when a connection is made you read data from the socket and process accordingly (you would have to com up with some type of cmd structure or protocol)
You need to decide who the client is in the conversation: IE who starts the conversation.
So here is a verbal representation of what I like you wan to do.
Arduino = Server
-> Client connects a port on server and sends a command
<- Server reads command, process, returns the process output to client and closes the connection
-> Client receives the data returned and logs it to a database
So something like this
-> open socket port 1234, write Hello World
<- read from socket port 1234, read Hello World , write World Hello
-> read from socket World Hello, write to database World Hello.