Arduino and ESP8266 - TCP Communication

Hey guys,

Recently I bought an Arduino UNO R3 and an ESP8266 and wanted to start a project. For this project I need to send a string from a webserver to the Arduino. Therefore I'm looking for a way to receive a package via TCP/IP, but since I'm pretty new in working with the Microcontroller I wanted to ask if anyone can help?

Basically I need to to program the Arduino to receive those TCP packets with the ESP8266.

I tried to use the ESP8266WiFi library to get started but already here I got stuck.
(Link to the Library: Arduino/libraries/ESP8266WiFi at master · EdwinNe/Arduino · GitHub)

I always get this error message:

In file included from /Users/Edwin/Documents/Arduino/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h:28:0,
from /Users/Edwin/Documents/Arduino/libraries/ESP8266WiFi/src/ESP8266WiFi.h:34,
from /Users/Edwin/Documents/Arduino/TCP-Communication/TCP-Communication.ino:1:
/Users/Edwin/Documents/Arduino/libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.h:27:22: fatal error: functional: No such file or directory
#include

It seems something didn't install correctly.
Isn't that one included in the EPS8266 core for Arduino? I don't recall having to install it separately myself. There's a lot included in the core libraries.
Also you shouldn't bother with receiving TCP packages. Just use http GET requests to poll the server, and get the data. Or if you need push data to your ESP maybe an MQTT server can help.

Thanks for the fast reply!

Yeah maybe there are better solutions for exchanging data than TCP/IP. In my case, I want to control a motor with the Arduino trough a website. So the Arduino shouldn't poll the server, it rather should wait for an incoming message.

MQTT might help to solve my problem, but I don't know how to program my Arduino to get these MQTT messages.

There's an example called Blynk which should give you some idea on how that works. No experience myself.

You could also simply host the web site itself on the ESP8266 so any button clicks and so go directly to it to handle.

I want to control the Motor when I‘m outside of the home-network. By using the Esp as a server I might get security problems since everyone can acces the server in my network.

The ESP supports https (to at least a certain degree: I've been able to open https links with it), and you should at least add some form of a password to your request, and without that password the ESP shouldn't be doing anything.

Your hardest problem is likely to access the ESP from outside of your home network, unless you have a fixed IP and can port forward http(s) traffic to your ESP.

I think the best protocol for your project is MQTT. Setup mosquito on your Webserver. Just make your Arduino subscribe to a topic and let your web server publish your packets to the same topic.