Arthur Vasilyev Arthur Vasilyev - 3 months ago 93
Java Question

Sending data to ESP8266 Wi-Fi chip from Android device

I have a ESP8266 chip which is connected to the microcircuit. When chip gets value "200" the light is starting to blink 4 times and than it returns "100" value. I need to make an Android app using Java which will connect to the ESP8266 chip, send data to it and will get value "100". I don't know what library I should use to deal with it. Please, help me, how can I do that? I think it is not the most hard question here.

Answer

For your Controller you dont need any Libary. You just can use the serial AT Commands: http://www.electrodragon.com/w/ESP8266

After setting up your ESP like this:

In your App you should deal with TCP-Sockets: https://de.wikibooks.org/wiki/Googles_Android/_TCP-Sockets

Try something like this in an async task:

socket = new Socket();
socket.connect(new InetSocketAddress(ip, port), Connect_Timeout);

DataOutputStream DataOut = new DataOutputStream(socket.getOutputStream());
DataOut.writeBytes(message);
DataOut.flush();

socket.close();

So your ESP is the Server and the App the Client. This should work without problems.