SurfCoders wrote:Peter Lerup has created a SoftwareSerial library that is compatible with the ESP8266.
It should be noted that although this code does disable interrupts during transmission and reception of each character, non-maskable interrupts may still occur and such interrupts
might affect the bit timing periodically. With that in mind, it would be better to choose a lower baud rate rather than a higher one because the time disturbance of NMI servicing would represent a smaller percentage of a bit time at a lower baud rate. On the other hand, higher baud rates are preferred because the shorter bit time requires interrupts to be disabled for shorter periods of time.
From reading the code I believe that the range of supported baud rates is 2000 to 200,000 baud. Since the code uses micros() to realize the timing, the resolution of the bit timing is 1uS. (This could be improved by using the tick count of RTC Timer2 directly since it has a resolution of 200nS.) For a point of reference, the bit time at 115.2Kbaud is 8.68uS. The code uses round() to compute the bit time in uS so it uses 9uS for 115.2Kbaud - this represents a 3.7% error. The 1uS resolution can result in a smaller error at lower baud rates (e.g. 0.2% at 38400 baud).