Most cases we need to interface 5V (TTL) logic level devices with ESP8266. For this you can simple use 1N4148 diode and one pull-up resistor.
The above circuit working can be understood using below figure.
- When we give logic 1 i.e. 5V to TXD diode becomes reverse bias and ESP 3.3V RXD pin gets supply of 3.3V (Logic 1) from pull-up.
- When we give logic low 0V to TXD pin the diode becomes forward bias and the voltage at its anode terminal drops below 0.7V i.e. logic zero.
- For TXD pin of ESP we don’t need any circuit as we can read 3.3V as logic 1 and 0V as logic 0 using any 5V controller.
5V TTL Serial Communication with ESP8266
For serial interface you have two options go with 3.3V USB to Serial converter or use above circuit to do level conversion and use 5V serial converter.
Serial interface is required to program the ESP flash.