How to make Rx TX of ESP8266 as normal GPIO?

Submitted by amelia on Thu, 07/04/2019 - 17:54

hi, i want extra gpio's in my project. is it possible to make use of Rx Tx of the esp8266 into a normal gpio pins. This will add two extra pins if it can be done. 

hie amelia,

you can do this by adding some lines of code in the begining of your code i.e. it can be addeed in the setup() function. Add these below lines in the beginning of setup() function.  

/////////////////change pin to gpio////////
//GPIO 1 (TX) swap the pin to a GPIO.
pinMode(1, FUNCTION_3); 
//GPIO 3 (RX) swap the pin to a GPIO.
pinMode(3, FUNCTION_3); 
///////////////////////

keep in mind that since you are changing the function of Rx Tx pin, this means that you cannot access serial monitor after this. also if you want to flash the esp8266 then it can be done in the flash mode of gpio which converts the gpio back in to rx and tx and when you boot the esp8266 in normal mode it will take rx tx as gpio. 

if you want to revert to normal rx tx function then replace  above lines wwith following one.

////////////////change pin to rx tx again//////////
//GPIO 1 (TX) swap the pin to a TX.
pinMode(1, FUNCTION_0); 
//GPIO 3 (RX) swap the pin to a RX.
pinMode(3, FUNCTION_0); 
/////////////////////////

  Joined January 21, 2019      42
Monday at 12:12 PM

thank you i will try and let you know

  Joined September 25, 2018      2
Tuesday at 06:21 PM

do let me know about the success. 

  Joined January 21, 2019      42
Monday at 12:12 PM

For swapping the serial communication pins into GPIOs, we have to make some changes in our firmware, for that we have to use some special function keyword for changing property of pin, in the library. Here I recommend you to get further support about IoT based projects from SSLA, the company which has IoTs based products & services. I have tried their product EFB-IoT in one of my project.

  Joined April 09, 2020      55
Thursday at 02:40 PM