Issue in esp8266 while using all GPIO

Issue in esp8266 while using GPIO as digital input using Rx Tx as GPIO 1,3 as I want to use GPIO 0 and 2 as output and while GPIO 1 and 3 as input , I d’not want to leave input and output in floating condition that’s why I used PULLUP function for both input and output BUT the problem is that when esp8266-01 boots up it makes GPIO 3 digitalWrite low I interchange GPIO 0 with GPIO 3 But the problem is same for input. This time GPIO 2 goes digitalWrite LOW So, I am unable to use two INPUTs in Esp 01 help me to solve my problem
Example code is Written below

//#define BLYNK_PRINT Serial
#include <BlynkSimpleEsp8266.h>
//#include <EasyBlynk8266.h>
#include <ESP8266WiFi.h>
//#include <WidgetRTC.h>
//#include <TimeLib.h>
//#include <SPI.h>
const int swPin = 3; //Rx as GPIO
const int wapPin = 1; //Tx as GPIO
const int slPin = 2;  
const int genPin = 0; 

 byte swState = HIGH;
 byte slState = HIGH;

char ssid[] = "Meeaaaaow";
char pass[] = "Messey007";
char auth[] = "xxxxxxxxxxx";

void setup()
{ 
  pinMode(swPin, OUTPUT);
  pinMode(slPin, OUTPUT);

  pinMode(wapPin, FUNCTION_3);
  pinMode(swPin, FUNCTION_3);
  
  pinMode(wapPin,INPUT);
  pinMode(genPin,INPUT);
  
  pinMode(wapPin,INPUT_PULLUP);
  pinMode(genPin,INPUT_PULLUP);

  digitalWrite(swPin, HIGH);
  digitalWrite(slPin, HIGH);

  

  Blynk.begin(auth, ssid, pass, IPAddress(192,168,0,101), 8080);
 }
  void loop() 
 {Blynk.run();
  }
                 ```

@ShahMir please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct character on your keyboard.

Pete.

thanks @PeteKnight , Ihave Edited my post

Please Help me to solve my problem

First of all, there is no point in having multiple pinMode definitions for the same pin. Only the last one processed will define the current mode for the pin.

I’m surprised that these two lines of code compile at all:

The clue is in the name here, INPUT_PULLUP defines a pin as an INPUT and enables the internal pullup resistors so that it is HIGH by default…

There is no equivalent for the output pins, as they need to be defined as OUTPUT and their state controlled via a digitalWrite command, so there is really no such thing as a floating output pin.

I suspect that the problem you are experiencing is because you have widgets in the app that are attached to these pins digital pins, rather than using virtual pins in the app.
Read this for more info on using virtual pins:

Pete.

I have issue with the INPUT pin as my pin goes LOW when esp boots up while I have defined GPIO as INPUT_PULLUP in my code

@PeteKnight
I have issue with the INPUT pin as my pin goes LOW when esp boots up while I have defined GPIO as INPUT_PULLUP in my code

@PeteKnight I have removed

  pinMode(swPin, FUNCTION_3)```

but the problem is same
here is edited code

```//#define BLYNK_PRINT Serial
#include <BlynkSimpleEsp8266.h>
//#include <EasyBlynk8266.h>
#include <ESP8266WiFi.h>
//#include <WidgetRTC.h>
//#include <TimeLib.h>
//#include <SPI.h>
const int swPin = 3; //Rx as GPIO
const int wapPin = 1; //Tx as GPIO
const int slPin = 2;  
const int genPin = 0; 

 byte swState = HIGH;
 byte slState = HIGH;

char ssid[] = "Meeaaaaow";
char pass[] = "Messey007";
char auth[] = "xx";

void setup()
{ 
  pinMode(swPin, OUTPUT);
  pinMode(slPin, OUTPUT);
  
  pinMode(wapPin,INPUT);
  pinMode(genPin,INPUT);
  
  pinMode(wapPin,INPUT_PULLUP);
  pinMode(genPin,INPUT_PULLUP);

  digitalWrite(swPin, HIGH);
  digitalWrite(slPin, HIGH);

  

  Blynk.begin(auth, ssid, pass, IPAddress(192,168,0,101), 8080);
 }
  void loop() 
 {Blynk.run();
  }```

Why are you doing this…

Do you mean that it momentarily goes LOW on boot-up, or it goes LOW and satays that way?

What widgets do you have connected to these pins in the app?

Pete.

it goes low and stays there

i am using digital inpit at this pin from another circuit

That doesn’t answer my question about app widgets, and needs more explanation about the external circuit.

Pete.

I am using the output of the comparator at this pin to get logic to control my cct
here is the brief code


#define BLYNK_PRINT Serial
#include <BlynkSimpleEsp8266.h>
//#include <EasyBlynk8266.h>
#include <ESP8266WiFi.h>
#include <WidgetRTC.h>
#include <TimeLib.h>
#include <SPI.h>
//#include "ZMPT101B.h"

//ZMPT101B voltageSensor(A0);

BlynkTimer timer;
WidgetRTC rtc;

const int swPin = 3; //Rx as GPIO
const int wapPin = 1; //Tx as GPIO
const int slPin = 2;  
const int genPin = 0; 

byte swState = HIGH;
byte slState = HIGH;

int i;
int autom; 

int blynkslond;
int blynksloffd;

unsigned long previousmillis = 0;

void clockDisplay();

char ssid[] = "Meeaaaaow";
char pass[] = "Messey007";
char auth[] = "xxx";

void setup()
 {Serial.begin(9600);
 
  pinMode(swPin, OUTPUT);
  pinMode(slPin, OUTPUT);

//  pinMode(wapPin, FUNCTION_3);
//  pinMode(swPin, FUNCTION_3);
  
//  pinMode(wapPin,INPUT);
//  pinMode(genPin,INPUT);
  
  pinMode(wapPin,INPUT_PULLUP);
  pinMode(genPin,INPUT_PULLUP);

  digitalWrite(swPin, HIGH);
  digitalWrite(slPin, HIGH);

  //digitalWrite(genPin, HIGH);

  Blynk.begin(auth, ssid, pass, IPAddress(192,168,0,101), 8080);

  // Serial.println("Calibrating... Ensure that no current flows through the sensor at this moment");
  // delay(100);
  // voltageSensor.calibrate();
  // currentSensor.calibrate();
  // Serial.println("Done!");
  
 //
 
 setSyncInterval(10 * 60);                  // Sync interval in seconds (10 minutes)

  timer.setInterval(1000L, clockDisplay);
  }   // Display digital clock every 10 seconds

void loop() 
 {Blynk.run();
  timer.run();}  

BLYNK_CONNECTED() 
  {rtc.begin();
   Blynk.syncVirtual(V6);     // Switch Pin
   Blynk.syncVirtual(V7);     // Self Pin
   Blynk.syncVirtual(V10);}

BLYNK_WRITE(V6)
 {int sw = param.asInt();
  if (autom == 0)  
     {if (sw == 0)
         {digitalWrite(swPin, LOW);
          if (digitalRead(swPin) == LOW)
             {Blynk.virtualWrite(V2, 0);}}
      else
         {digitalWrite(swPin, HIGH);
          if (digitalRead(swPin) == HIGH)
             {Blynk.virtualWrite(V2, 255);}}}}
          
BLYNK_WRITE(V7)
 {int sl = param.asInt();
  if (autom == 0)
     {if (sl == 0)
         {digitalWrite(slPin, LOW);
          if (digitalRead(slPin) == LOW)
             {Blynk.virtualWrite(V3, 0);}}
      else
         {digitalWrite(slPin, HIGH);
          if (digitalRead(slPin) == HIGH)
             {Blynk.virtualWrite(V3, 255);}}}}

BLYNK_WRITE(V8)
 {blynkslond = param.asInt();}                   // Blynk self on duration
BLYNK_WRITE(V9)
 {blynksloffd = param.asInt();}                  // Blynk self off duration              
BLYNK_WRITE(V10)
 {autom = param.asInt();} 

void clockDisplay()
 {String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + " " + month() + " " + year();
  Serial.print("Current time: ");
  Serial.print(currentTime);
  Serial.print(" ");
  Serial.print(currentDate);
  Serial.println();
  
  Blynk.virtualWrite(V0, currentTime);
  Blynk.virtualWrite(V1, currentDate);

 /*unsigned long currentmillis = millis();
  unsigned long onduration = blynkon*1023UL;
  unsigned long offduration = blynkoff*1023UL;
  if (autom == 0)
  {if (testled == HIGH)
      {if (currentmillis -  previousmillis >= onduration) 
          {Blynk.virtualWrite(V6, 255);
           testled = LOW;
           previousmillis = currentmillis;}}
   else if (testled == LOW)
       {if (currentmillis -  previousmillis >= offduration) 
           {Blynk.virtualWrite(V6, 0);
            testled = HIGH;
            previousmillis = currentmillis;}}}*/
  if (autom == 1)         
     {if (digitalRead(wapPin) == LOW && digitalRead(genPin) == HIGH)
         {digitalWrite(swPin, HIGH);                                         // Switch off
          if (digitalRead(swPin) == HIGH)
             {Blynk.virtualWrite(V2, 0);}                                    // Switch light off
          digitalWrite(slPin, HIGH);                                         // Self off
          if (digitalRead(slPin) == HIGH)
             {Blynk.virtualWrite(V3, 0);}                                    // Self light off
          if (digitalRead(wapPin) == HIGH)
             {Blynk.virtualWrite(V4, 255);}                                  // Wapda light on
      
          time_t stoppedat = now();
          Blynk.virtualWrite(V14, stoppedat);}
  
      else if (digitalRead(wapPin) == HIGH && digitalRead(genPin) == HIGH)
          {if (digitalRead(wapPin) == LOW)
              {Blynk.virtualWrite(V4, 0);                                // Wapda light off
               Blynk.notify("Alert! Wapda is down");}
           
           digitalWrite(swPin, LOW);                                     // Switch on
           if (digitalRead(swPin) == LOW)
              {Blynk.virtualWrite(V2, 255);}                             // Switch light on
           delay(500);
           
           for (i=0; i<=2; i++)
               {digitalWrite(slPin, LOW);                                // Self on
                if (digitalRead(slPin) == LOW)
                   {Blynk.virtualWrite(V3, 255);}                        // Self light on
                delay(500);
                digitalWrite(slPin, HIGH);                               // Self off
                if (digitalRead(slPin) == HIGH)
                   {Blynk.virtualWrite(V3, 0);}                          // Self light off
                delay(500);}} 
  
  else if (digitalRead(wapPin) == HIGH && digitalRead(genPin) == LOW)
          {if (digitalRead(genPin) == HIGH)
              {Blynk.virtualWrite(V5, 255);                              // Generator light on
               Blynk.notify("Genertor is running");}
               
           digitalWrite(swPin, LOW);                                     // Switch on
           if (digitalRead(swPin) == LOW)       
              {Blynk.virtualWrite(V3, 255);}                             // Switch light on
           digitalWrite(slPin, HIGH);                                    // Self off
           if (digitalRead(slPin) == HIGH)
              {Blynk.virtualWrite(V3, 0);}                               // Self light off
               
           // string startedat;
           // breakTime(tin, startedat);
           time_t startedat = now();
           Blynk.virtualWrite(V13, startedat);} 
          
  else if (digitalRead(wapPin) == LOW && digitalRead(genPin) == LOW)
          {if (digitalRead(wapPin) == HIGH)
              {Blynk.virtualWrite(V4, 255);                              // Wapda light on
               Blynk.notify("Wapda is Up");}
           delay(2000);   
           digitalWrite(swPin, HIGH);                                    // Switch off
           if (digitalRead(swPin) == HIGH)       
              {Blynk.virtualWrite(V3, 0);}                               // Switch light off
           digitalWrite(slPin, HIGH);                                    // Self off
           if (digitalRead(slPin) == HIGH)
              {Blynk.virtualWrite(V3, 0);}                               // Self light off
               
           // string startedat;
           // breakTime(tin, startedat);
           time_t startedat = now();
           Blynk.virtualWrite(V13, startedat);}}
 }
  // if (digitalRead(wapPin) == LOW || digitalRead(genPin) == LOW)      {i = 0;}}*/

  /*// if (ana)     
    // float U = voltageSensor.getVoltageAC();
    // float I = currentSensor.getCurrentAC();
    // float P = U;
    // Serial.println(String("U = ") + U + " V");}
    // Serial.println(String("I = ") + I + " A");
    // Serial.println(String("P = ") + P + " Watts");*/

If you think that clarifies anything, then you’re wrong.

I’ll try one more time…
Do you have any widgets in your app connected to digital pins 1 and 3?

Pete.

No, there is no widget connected with digital pins 1 and 3

@PeteKnight

Sir, Please Help Sir