-1

I want to send commands to ESP8266 over WiFi from my phone(I'm working on building an App using PhoneGap). I'm new to this module and WiFi. What I'm doing right now is that I communicate with the module by sending GET (or POST) commands. I'm sure there should be a better way but I can't seem to find how. What is the correct way to talk to ESP8266 over WiFi?

  • Could you clarify whether you are using the ESP8266 in the Arduino environment -- that is, you are compiling code (a sketch) that runs directly on the ESP8266 and responses to the GET/POST commands? – jose can u c Feb 15 '17 at 16:28
  • Forgot to mention that. Yes, I'm using Arduino IDE. – ahmadx87 Feb 15 '17 at 20:12
  • You could use websockets, I think there is a library for the ESP8266 around somewhere (I cant remember what its called) – Code Gorilla Feb 16 '17 at 13:15
  • fwiw, i've had better luck with http than sockets and mqtt; fewer resets/freezes, lower ping times, and more bandwidth, provided you keep responses under 4kb... – dandavis Feb 17 '17 at 10:11
3

Depending on what best suits your needs, you could use:

  • http GET/POST commands
  • Websockets over http
  • MQTT protocol
  • Your own TCP or UDP socket protocol
  • etc.

In all cases, what you code into the ESP8266 processor/flash will need to receive and process the commands. The possibilities are near endless, since you are writing the App and the code for the module and can make those design decisions.

  • Thank you for your answer. Currently I'm using http GET/POST commands and on the ESP side I analyse the received string. I don't know how to use the other methods, what is the most common/reliable option? I would appreciate it if you could give me some practical references. – ahmadx87 Feb 15 '17 at 20:16
  • All of those methods listed above use IP (either TCP or UDP), so they are relatively the same reliability. MQTT requires a broker daemon to be running, so you don't talk directly to the ESP device from your app - that's an additional point of failure. I would say there is not a clear winner, however. – jose can u c Feb 15 '17 at 20:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.