Networking and communications

Have you:

  • Described your design and fabrication process using words/images/screenshots
  • Explained the programming process/es you used
  • Outlined problems and how you fixed them
  • Included original design files and code

Described your design and fabrication process using words/images/screenshots

I decided to use the ESP8266 modules to establish a wireless connection.


Using PCB files we mill two boards, one for the server and one for the client.








Finally, carefully welded components.


Explained the programming process/es you used

Connect a FTDI cable to PCB with the ESP8266 module and send AT messages from a serial terminal.


AT
AT+GMR
AT+CWMODE=1
AT+CWLAP
AT+CWJAP="Minecraft","diegoriv"
AT+CIPMUX=1
AT+CIPSTART=1,"TCP","fab.cba.mit.edu",80
AT+CIPSEND=1,50
GET /test.html HTTP/1.1
HOST: fab.cba.mit.edu
AT+CIPCLOSE=1





After checking the operation of our PCB now we can program it using Lua scripts.
Flash both ESPs with NodeMCU
Connect the FTDI cable to PCB and add connection GPIO 0 to GND.


You have to download the NodeMCU flasher. Download it from Here






Then download ESPlorer IDE to program the server and the client.
Download the code for the server.


-- ESP8266 Server

print("ESP8266 Server")
wifi.setmode(wifi.STATIONAP);
wifi.ap.config({ssid="test",pwd="12345678"});
print("Server IP Address:",wifi.ap.getip())

sv = net.createServer(net.TCP)
sv:listen(80, function(conn)
conn:on("receive", function(conn, receivedData)
print("Received Data: " .. receivedData)
end)
conn:on("sent", function(conn)
collectgarbage()
end)
end)

Download the code for the client.


-- ESP8266 Client

print("ESP8266 Client")
wifi.sta.disconnect()
wifi.setmode(wifi.STATION)
wifi.sta.config("test","12345678") -- connecting to server
wifi.sta.connect()
print("Looking for a connection")

tmr.alarm(1, 2000, 1, function()
if(wifi.sta.getip()~=nil) then
tmr.stop(1)
print("Connected!")
print("Client IP Address:",wifi.sta.getip())
cl=net.createConnection(net.TCP, 0)
cl:connect(80,"192.168.4.1")
tmr.alarm(2, 5000, 1, function()
cl:send("Hello World!")
end)
else
print("Connecting...")
end
end)

Outlined problems and how you fixed them

I had trouble linking the ESP8266 modules with Arduino so used LuaNodeMCU firmware.

Included original design files and code

Code