今天不知道是不是让我姐挺失望.......很多时候都不知道自己努力的方向对不对,,以后能不能带给家人最美好的期盼......

Init.lua 没啥改变,,就改了一下加载Client.lua

gpio.mode(,gpio.OUTPUT)
gpio.write(,) tmr.alarm(, , , function()
gpio.write(,-gpio.read())
end) tmr.alarm(, , , function()
dofile("Client.lua")
end)

新建了一个Client.lua

wifi.setmode(wifi.STATIONAP)

cfg={}
cfg.ssid="Hellow8266"
cfg.pwd=""
wifi.ap.config(cfg) apcfg={}
apcfg.ssid="qqqqq"
apcfg.pwd=""
wifi.sta.config(apcfg)
wifi.sta.autoconnect() ClientConnectedFlage =
TcpConnect = nil
tmr.alarm(, , , function() if ClientConnectedFlage == then
Client = net.createConnection(net.TCP, )
Client:connect(,"192.168.1.103") Client:on("receive", function(Client, data)
uart.write(,data)
end) Client:on("connection", function(sck, c)
ClientConnectedFlage =
TcpConnect = Client
print("Link OK")
tmr.stop() Client:on("disconnection", function(sck, c)
ClientConnectedFlage =
TcpConnect = nil
tmr.start()
end)
end) if ClientConnectedFlage == then
print("Link Error")
end
end
end) uart.on("data",,function(data)
if TcpConnect ~= nil then
TcpConnect:send(data)
end
end, ) printip =
wifi.eventmon.register(wifi.eventmon.STA_DISCONNECTED, function(T)
printip =
end) wifi.eventmon.register(wifi.eventmon.STA_GOT_IP, function(T)
if printip == then
print("+IP"..T.IP)
end
printip =
end)

现在测试

现在创建服务器

发送数据测试

现在断开连接

第一次没有截到网络调试助手的图,模块就连接上了,,所以又断开了一次

如果用的ESP12系列的可以现在就用这个读取AD的电压值

命令和回复呢咱就这样规定

现在的init.lua

gpio.mode(,gpio.OUTPUT)
gpio.write(,) if adc.force_init_mode(adc.INIT_ADC) then
node.restart()
return
end tmr.alarm(, , , function()
gpio.write(,-gpio.read())
end) tmr.alarm(, , , function()
dofile("Client.lua")
end)

现在的Client.lua

wifi.setmode(wifi.STATIONAP)

cfg={}
cfg.ssid="Hellow8266"
cfg.pwd=""
wifi.ap.config(cfg) apcfg={}
apcfg.ssid="qqqqq"
apcfg.pwd=""
wifi.sta.config(apcfg)
wifi.sta.autoconnect() ClientConnectedFlage =
TcpConnect = nil
tmr.alarm(, , , function() if ClientConnectedFlage == then
Client = net.createConnection(net.TCP, )
Client:connect(,"192.168.1.103") Client:on("receive", function(Client, data)
uart.write(,data)
ReadAd(data)
end) Client:on("connection", function(sck, c)
ClientConnectedFlage =
TcpConnect = Client
print("Link OK")
tmr.stop() Client:on("disconnection", function(sck, c)
ClientConnectedFlage =
TcpConnect = nil
tmr.start()
end)
end) if ClientConnectedFlage == then
print("Link Error")
end
end
end) function ReadAd(data)
if data == "++MD9" then
ad = adc.read()
if TcpConnect ~= nil then
TcpConnect:send("++MDAD="..ad)
end
end
end uart.on("data",,function(data)
if TcpConnect ~= nil then
TcpConnect:send(data)
end
end, ) printip =
wifi.eventmon.register(wifi.eventmon.STA_DISCONNECTED, function(T)
printip =
end) wifi.eventmon.register(wifi.eventmon.STA_GOT_IP, function(T)
if printip == then
print("+IP"..T.IP)
end
printip =
end)

现在测试

对了测试的电压是0-1V    然后分辨率是  1024

我现在接到3.3上

https://www.cnblogs.com/yangfengwu/p/7533845.html

最新文章

  1. stm32GPIO的速度是什么意思
  2. Visual Studio 2010 下 安装RGiesecke.DllExport
  3. 一行代码解决各种IE兼容问题IE8,IE9,IE10
  4. Eclipse如何设置字体
  5. oracle创建job方法
  6. iOS之XIB拖拽scrollView
  7. PHP设计模式之:装饰模式
  8. 怎么设置tomcat管理员的用户名和密码
  9. 转化率最高的16个WordPress 电子商务主题
  10. 【Weblogic】在linux创建domain过慢的解决方法
  11. SQLAlchemy复杂查询
  12. SRM340 VegetableGarden
  13. Terminating app due to uncaught exception 'CALayerInvalid', reason: 'layer <CALayer: 0x7fda42c66e30> is a part of cycle in its layer tree'
  14. 树莓派+花生棒+leanote搭建自己的笔记服务器
  15. 【Myeclipse】用Myeclipse10.5搭建C/C++开发环境
  16. entity framework 时间操作
  17. Spring JdbcTemplate 查询出的Map,是如何产生大小写忽略的Key的?(转)
  18. Cognos11中报XQE-JDB-0004查找驱动程序类错误
  19. OPENSSL编程起步
  20. iOS.Book.Effective Objective-C 2.0

热门文章

  1. django-sql注入攻击
  2. js-redux学习笔记2
  3. Microsoft MVP MSDN Magazine 最新期分享
  4. SVN CentOS7 下配置svn的安装及基础配置介绍
  5. linux svn配置与使用
  6. 记一次寻找appbug的问题
  7. 【转】qt-vs-addin:Qt4和Qt5之VS插件如何共存与使用
  8. 团队项目个人进展——Day07
  9. Unix操作系统监控详解(一)
  10. SQL2005的SSMS连接SQL2012会有问题