I am making a project with an Arduino Uno and a wifi shielf. It is an indoor environment control project where the Arduino takes in Outdoor Temperature (and pollution), Indoor Temperature and Temperature Setting and decides about a combination of opening the window, turning on a fan and/or turning on an air conditioner.
The Arduino gets the outdoor temperature from a Smart Citizen Kit (SCK, Arduino based product) buy making an internet based request to the SCK. This request part of the sketch pretty much exactly follows the Arduino example program “WifiWebClient”. In that code an object is created:
WiFiClient client;
A request is made like:
client.println("Host: http://api.smartcitizen.me"");
And the response is recorded like:
char c = client.read();
Now, I also need the Arduino to act like a server in order to receive the Temperature Setting. An android app will send a “command” to the Arduino to move Temperature Setting up or down, much like an air conditioner. My project partner is doing the Android App, but I need to be able to receive a command from the app over wifi and respond to that command by raising or lowering the temperature setting. I believe that would be a “server” type behavior. I looked over the example program “WifiWebServer” and the server object is created like:
WiFiServer server(80);
So my question is:
Is there a problem with having both a client and a server in the same sketch? Any tips or things to watch out for?
Thanks,
Drew