Adventures with the ESP8266

I love the esp8266, as far as I'm concerned it's the embedded processor with the mostest. 

But It does have one or two foibles. I ran into them today as I was trying to improve HullPixelbot reliability. My little robots work fine to start with, but then have an annoying habit of crashing or getting stuck after a while. 

Today I found out why. The HullPixelbot is a two-brained robot. The wheels are controlled by an Arduino Pro-mini device, and the esp8266 does the networking and stuff. The two devices are linked by a serial connection, so that commands received via WiFi can be passed into the motor controller which then makes things happen. 

I'm using the SoftwareSerial library to create a serial port on the esp8266 which then sends commands to the Arduino device. This is a software implementation of a hardware device, fast running code does the same task that is normally performed by a piece of dedicated hardware. 

And therein lies my problem. The SoftwareSerial driver was causing my network code to fail. It works fine sending data, but incoming messages cause interrupts in the esp8266 that seem to upset the  connection. I've changed to using the hardware serial port and everything seems to work a lot better. 

Oh, and one other thing I've discovered about the esp8266. Pin 18 (identified as D3 on the Wemos Pro-Mini board) controls whether or not the device can be flashed with a new program. If this line is held high it can stop your programs from downloading. I've been using D3 as a serial connection and having all kinds of problems. And now I know why.