将Arduino Mega连接到ESP8266作为网络服务器

时间:2016-09-09 16:24:09

标签: lua arduino esp8266 nodemcu

我将Arduino Mega作为带有RTC,麦克风和SD卡的数据记录器运行。
我想用ESP8266作为网络服务器远程访问SD卡数据。将ESP8266与Arduino板作为网络服务器连接的最佳方法是什么?

我想到的是从nodeMCU

在ESP8266上运行以下脚本
-- a simple http server
srv = net.createServer(net.TCP)
srv:listen(80, function(conn)
 conn:on("receive", function(sck, payload)
    print(payload)
    sck:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n<h1> Hello,     NodeMCU.</h1>")
 end)
 conn:on("sent", function(sck) sck:close() end)
end)

并在sck:send一行之前插入,以触发Arduino板上的中断并让它从SD卡发送数据。
有没有更简单的方法呢?还有其他想法吗?
ESP8266正在运行nodeMCU但是我可以使用其他代码。
(我看到很多有关编程ESP8266的教程,但是在连接到Arduino板时却没有。 )

0 个答案:

没有答案