Easy ESP8266 WiFi Debugging With Python
Easy ESP8266 WiFi Debugging With Python
Living
Outside
Play
Technology
Workshop
Table of Contents
Easy ESP8266 WiFi Debugging with Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Step 2: Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
http://www.instructables.com/id/Easy-ESP8266-WiFi-Debugging-with-Python/
Author:jimk3038
www.ph-elec.com
Founder of Powerhouse Electronics.
For more info goto: www.ph-elec.com
Image Notes
1. 5V LED comes on whenever the USB cable is jacked in.
2. ESP8266 Red LED comes on when the Mic regulator is enabled.
3. MSOP parts are hard to work with. This is really ugly but it works. I should add a wad of epoxy over the tiny wires before they get broken.
4. The copper PCB acts like a heat-sink for the regulator.
http://www.instructables.com/id/Easy-ESP8266-WiFi-Debugging-with-Python/
Image Notes
1. Pin #1
2. ESP8266 WiFi Module
Step 2: Software
There are three bits of Python code for this Instructable.
1) "tcp_server.py" -> This Python code provides a TCP server that the ESP8266 can connect to. Simply edit the code so that the IP number in the source code matches
the IP number of the machine your running this on. The server simply allows a client to make a TCP connection, accepts some data, and sends back some junk data.
That's it. The server just starts up and then waits in an endless loop for clients to connect.
2) "tcp_client.py" -> This Python code provides a way to test "tcp_server.py" is working correctly. So, with the server code running on one machine, run "tcp_client.py" on
another computer on your network. Run the client as "tcp_client.py Some data to send goes here." The client app sends whatever is given on the command line. In this
case, the client would send "Some data goes here." to the server. Both the server and the client will show some output that indicates a successful transfer.
3) Finally, "Test_ESP8266.py" can now be used to test for a TCP connection to the Python server. If all goes well, the server and "Test_ESP8266.py" will show some
output that indicates a successful transfer. Once again, before running "Test_ESP8266.py" edit the code so that the IP numbers match. Run as "Test_ESP8266.py
MySSID MyPasscode" - the SSID and passcode must match your WiFi settings.
Using the Python Test_ESP8266 code I learned a couple things about the module. After getting everything working and verified with the server I simply tried using a bad
passcode, as a test to see what would happen. Everything appeared normal until the actual command to form the TCP connection. The command that failed was
"AT+CIPSTART='TCP','192.168.1.130',9999". However, I would have expected the command "AT+CWJAP?" to fail first. The "AT+CWJAP?" command returns the SSID
and RSSI of the AP the ESP8266 is connected to. With a bad passcode it should not have been able to connect.
Goofing with the code I think I've discovered a trick. After connecting to the AP, ask for the ESP8266 IP number. Even with a good passcode it may return "ERROR". No
worries, just dwell a couple seconds and ask again. With a good SSID and passcode the ESP8266 will eventually return the IP number. After a good IP number is
returned the TCP connection command always seems to work.
Another trick, if a bad passcode is used the ESP8266 module gets stuck! Regardless of the command sent the module returns "buzy now ...". Even the "AT+RST" (reset)
command is ignored. The work around is to use the regulator to cycle power to the module. Using the RTS pin on the FTDI USB-to-Serial converter - which connects to
the regulator enable pin - the regulator 3.3Vdc output can be switched off. An off time of 10 seconds seems to work well.
Well, that's is. Hope this helps,
Jim
BTW: For the latest and greatest updates please visit my web site: www.ph-elec.com
http://www.instructables.com/id/Easy-ESP8266-WiFi-Debugging-with-Python/
File Downloads
tcp_server.py (1 KB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'tcp_server.py']
Test_ESP8266.py (3 KB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'Test_ESP8266.py']
Related Instructables
Use ESP8266 to
Internet enabled
AC Appliances
by shinteo
ESP8266 WiFi
ESP8266 WiFi
temperature and relay switch by
humidity sensor EasyIoT
by EasyIoT
ESP8266 WiFI
water leak
sensor by
EasyIoT
A newbie's
guide to setup
ESP8266 with
Arduino Mega
2560 or Uno by
shinteo
An inexpensive
IoT enabler
using ESP8266
by
gopinath.marappan
Advertisements
Comments
7 comments
Add Comment
doctek says:
doctek says:
jimk3038 says:
http://www.instructables.com/id/Easy-ESP8266-WiFi-Debugging-with-Python/
The latest Energia software has a bunch of examples just for the CC3200 board. One of the examples measured the internal temperature sensor that is
internal to the micro. After the measurement is made the WiFi connection is used to upload the data to a cloud service. The cloud service charts and
plots the data to either a web page or your smart phone real-time!
Truly amazing to be able to take a new board and have it connected to the cloud in about 10 minutes. Most of that time consumed with downloading and
installing Energia. Running the demo only takes 30 seconds.
I was really impressed - and no, I have no ties to TI,
Jim
Silent_Shadow says:
jimk3038 says:
OK, I'm over ranting about loosing my work to bugs. Step three now has real comments.
http://www.instructables.com/id/Easy-ESP8266-WiFi-Debugging-with-Python/