This week we are making an electronics circuit with WiFi using a ESP8266 (2.6 GHz Wi-FI) chip.
Once you've milled and soldered the electronics component like you see in the beautiful picture above, the next step is to do something. You'll need miniterm.py, which is part of the pyserial package. Here's a script to clone the pyserial repo and run the miniterm on your electronics. Like I've mentioned before, you can figure out the filepath of the electronics component by tab completing /dev/cu.
git clone firstname.lastname@example.org:pyserial/pyserial.git cd pyserial/serial/tools/ miniterm.py /dev/cu.usbserial-XXX 115200
If you want to try out a UDP connecty, you have to enter ESP8266 commands, which you can find here.
AT+RST AT AT+GMR AT+CWJAP="MIT","" AT+CIFSR AT+CIPMUX=1 AT+CIPSTART=1,"UDP","220.127.116.11",1234,1234,0
The next step would be to run the node server in a separate terminal window. Type cmd-d in the terminal to split the terminal screen into two terminal screens and run the following.
curl http://academy.cba.mit.edu/classes/networking_communications/socket/udpsnd.js > udpsnd.js curl http://academy.cba.mit.edu/classes/networking_communications/socket/udprcv.js > udprcv.js node udpsnd.js 18.104.22.168 1234 "hello" && node udprcv.js 1234
And this works, but the first time I did it something went wrong... here's a video trying to do it without the code to connect to the wifi
. Just as a comment, the tutorial video doesn't connect to the wifi and you need to connect to the wifi.
So, without the wifi connection, when I try to do
AT+CIPSTART=1,"TCP","fab.cba.mit.edu",80 , I get a DNS Fail error. Likewise, when I host a server
AT+CIPSERVER=1,80 and try a telnet connection, I don't see any feedback.
So, I posted an issue on Gitlab. And Caroline suggested checking out this tutorial. Here's the code (that you enter into the terminal) to get it working:
git clone email@example.com:guyz/pyesp8266.git cd pyesp8266 python2 esp8266server.py /dev/tty.usbserial-FTAP8P1F 115200 'MIT' ''
And voila, if you keep the code as is and curl the IP address or enter it in your browser, you'll get
GOT IT! (2018-12-05 10:40:10.716597). If you're so inclide you could change the code in
process_request to do something different. For example, you could imagine you tweet something every time someone pushes a button on the board. This board doesn't have a button. But it could!