从Android设备向ESP8266 Wi-Fi芯片发送数据 [英] Sending data to ESP8266 Wi-Fi chip from Android device

查看:416
本文介绍了从Android设备向ESP8266 Wi-Fi芯片发送数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个连接到微电路的ESP8266芯片。当芯片值200时,灯开始闪烁4次,然后返回100值。我需要使用Java创建一个Android应用程序,它将连接到ESP8266芯片,向其发送数据并获得值100。我不知道应该用什么库来处理它。请帮助我,我该怎么办?我认为这不是最难的问题。

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.

推荐答案

对于你的控制器,你不需要任何Libary。您只需使用串行AT命令: http://www.electrodragon.com/w/ESP8266

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

在设置你的ESP之后:

After setting up your ESP like this:

在你的应用程序中你应该处理TCP套接字: https://de.wikibooks.org/wiki/Googles_Android/_TCP-Sockets

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();

因此,您的ESP是服务器,应用程序是客户端。这应该没有问题。

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

这篇关于从Android设备向ESP8266 Wi-Fi芯片发送数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆