How to connect esp8266 or esp32 as wifi shield with arduino uno r3 for blynk project setup

Dear pros,
I want to connect my esp8266 board not shield with my arduino uno r3. This case my arduino will be the main board and esp8266 will work as internet connector. I repeat , I want to use esp8266 board not wifi shield. How I can do this?

Your NodeMCU needs to be running AT firmware (which it might have installed as standard when it arrives).
Then the process is the same as using an ESP-01 as the WiFi modem.

But, connecting an Uno to a NodeMCU is a bit like connecting a trailer to a Ferrari.

The NodeMCU is far more powerful than the Uno, so why not use it as a standalone board?
If it doesn’t have enough GPIOs or Analog inputs then use a standalone ESP32 instead?

Pete.

1 Like

Thanks for your reply. I used esp8266 as a standalone board. But in my case, the nodemcu is not working properly standalone. I don’t why. my nodemcu can not power up the relay properly showing garbage value to the lcd etc.
See my project video: https://youtu.be/lP0vamAeSeE
Circuit diagram:

Code:

    #define BLYNK_TEMPLATE_ID "blank for community"
    #define BLYNK_DEVICE_NAME "blank for community"
    #define BLYNK_AUTH_TOKEN "blank for community"
    #define BLYNK_PRINT Serial

    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    #include <NewPing.h>
    #include <LiquidCrystal_I2C.h>
    #include <Wire.h> 

    // Set the LCD address to 0x27 for a 16 chars and 2 line display
    LiquidCrystal_I2C lcd(0x3F, 16, 2);

    int n = 0, n1 = 0; // n and n1 are used for notifications
    int dis, dis1, f1 = 0, f2 = 0;  // f1 and f2 are flag variables
    float t = 9, t1 = 9; // initialized tank one depth in inches and initialized tank two depth in inches

    #define relay D0
    #define relay1 D3
    #define TRIGGER_PIN D5
    #define ECHO_PIN D5
    #define TRIGGER_PIN1 D6
    #define ECHO_PIN1 D6
    #define MAX_DISTANCE 50 // max distance the sensor will return

    NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // declare a NewPing object
    NewPing sonar1(TRIGGER_PIN1, ECHO_PIN1, MAX_DISTANCE); // declare a NewPing object
    char auth[] = BLYNK_AUTH_TOKEN;
    char ssid[] = "blank for community";
    char pass[] = "blank for community";

    BLYNK_WRITE(V2)
    {
      f1 = param.asInt(); // here we read the pump one system on or off given by user
    }
    BLYNK_WRITE(V3)
    {
      f2 = param.asInt(); // here we read the pump two system on or off given by user
    }

    void setup()
    { pinMode(relay, OUTPUT); pinMode(relay1, OUTPUT); // initialize pin as OUTPUT

      lcd.begin();
      lcd.backlight(); 
      Serial.begin(115200);
      Blynk.begin(auth, ssid, pass);    
    }

    void loop()
    {
      Blynk.run();  delay(1000);  lcd.clear();
       
      dis = sonar.ping_in();  dis1 = sonar1.ping_in(); // taking distance in inches from sonar sensor
      
      Serial.print("Ping: ");  Serial.print(dis);
      Serial.println(" in ");
       
      Serial.print("Ping1: ");  Serial.print(dis1);
      Serial.println(" in ");

      int s, s1;  s = (100.00 / t) * dis; s1 = (100.00 / t1) * dis1; s = 100 - s;  s1 = 100 - s1;
      if (s < 0) s = 0;
      if (s1 < 0) s1 = 0;
      Serial.print("S ");  Serial.print(s);  Serial.print("  S1  ");  Serial.println(s1);
      Serial.print("N ");  Serial.print(n);  Serial.print("  N1  ");  Serial.println(n1);
      Serial.println((String)" F1 " + f1);  Serial.println((String)" F2 " + f2);

      lcd.setCursor(0, 0);
      
      // For Tank one
      
      if (f1 == 0) {
        lcd.print("P1 sys is off");
        Serial.println(" c1 ");

        Blynk.virtualWrite(V4, s);    Blynk.virtualWrite(V0, 0);
        digitalWrite(relay, HIGH);
      }
      else if(dis > t || dis < 1) {
        if (n) {Blynk.logEvent("tank_one_full");}
        n = 0;
        lcd.print("T1:");    lcd.print(s);    lcd.print("%,P1:off");
            
        Serial.println(" c2 ");    
        Blynk.virtualWrite(V4, s);    Blynk.virtualWrite(V0, 0);
        digitalWrite(relay, HIGH);
      }
      else if (s < 20){
        if (n == 0) {
          Blynk.logEvent("tank_one_empty");
        }
        n = 1;
        lcd.print("T1:");    lcd.print(s);    lcd.print("%,P1:on");

        Serial.println(" c3 ");    
        digitalWrite(relay, LOW);    
        Blynk.virtualWrite(V4, s);    Blynk.virtualWrite(V0, 1);
      }
      else if(n)
      {
        lcd.print("T1:");    lcd.print(s);    lcd.print("%,P1:on");

        Serial.println(" c4 ");    
        digitalWrite(relay, LOW);    
        Blynk.virtualWrite(V4, s);    Blynk.virtualWrite(V0, 1);        
      }
      else if (n == 0) 
      {    
        lcd.print("T1:");    lcd.print(s);    lcd.print("%,P1:off");

        Serial.println(" c5 ");    
        digitalWrite(relay, HIGH);    
        Blynk.virtualWrite(V4, s);    Blynk.virtualWrite(V0, 0);    
      }
      
      lcd.setCursor(0, 1);

      // For Tank two
      
      if (f2 == 0) {
        lcd.print("P2 sys is off");
        
        Serial.println(" h1 ");  
        Blynk.virtualWrite(V5, s1);    Blynk.virtualWrite(V1, 0);
        digitalWrite(relay1, HIGH);  
      }
      else if(dis1 > t1 || dis1 < 1) {
        if (n1) {Blynk.logEvent("tank_two_full");}
        n1 = 0;
        lcd.print("T2:");    lcd.print(s1);    lcd.print("%,P2:off");
        
        Serial.println(" h2 ");  
        Blynk.virtualWrite(V5, s1);    Blynk.virtualWrite(V1, 0);
        digitalWrite(relay1, HIGH);
      }
      else if (s1 < 20 && s > 50) { 
        if (n1 == 0) {
          Blynk.logEvent("tank_two_empty");
        }
        n1 = 1;
        lcd.print("T2:");    lcd.print(s1);    lcd.print("%,P2:on");
        
        Serial.println(" h3 ");  
        Blynk.virtualWrite(V5, s1);    Blynk.virtualWrite(V1, 1);
        digitalWrite(relay1, LOW);
      }
      else if(n1 && s > 50)
      { 
        lcd.print("T2:");    lcd.print(s1);    lcd.print("%,P2:on");
        
        Serial.println(" h4 ");  
        Blynk.virtualWrite(V5, s1);    Blynk.virtualWrite(V1, 1);
        digitalWrite(relay1, LOW);   
      }
      else if(s1 < 20 || n1) 
      {        
        lcd.print("T2: T1 is empty");    
        
        Serial.println(" h5 ");  
        Blynk.virtualWrite(V5, s1);    Blynk.virtualWrite(V1, 0);
        digitalWrite(relay1, HIGH);
      }
      else if (n1 == 0)
      {
        lcd.print("T2:");    lcd.print(s1);    lcd.print("%,P2:off");
        
        Serial.println(" h6 ");  
        Blynk.virtualWrite(V5, s1);    Blynk.virtualWrite(V1, 0);
        digitalWrite(relay1, HIGH);
      }
      
      Serial.println(" "); 
    }```

@MojahidMahin 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 symbol on your keyboard.

Pete.

1 Like

done

Well, you’re powering 5v relays with a 3.3v supply, which is coming via the NodeMCU’s onboard voltage regulator. That isn’t going to work well, regardless of whatever board you use.

The LCDs backlight needs quite a bit of current, and your 5v supply probably isn’t up to the job of powering that and the other devices.

Then there’s your void loop!!
You should read this…

Pete.

1 Like

I powered up the relay with other sources and lcds with usb adapters 5v and, also I powered up my ultrasonic with 5v from other sources, in these cases lcd is fully blank; nodemcu does not give any output; and, in the serial monitor ultrasonic sensors data shows always 0 , also my relay is active low, so when power up with 5v then nodemcy 3.3 v can not active the relays. but all these things works when I powered them from the nodemcu voltage. what’s the issue? I have esp32 board will it solve my issues?
or arduino will be a good option to solve these issues?

Did you connect all your grounds together?

That won’t be the case if you wire everything correctly and have shared grounds. It makes no difference if the relays are active LOW or active HIGH, they will still work with a NodeMCU if they can be triggered by a 3.3v signal, which is almost certainly the case.

Most likely a lack of common grounds.

No, you’ll have the same issues if you power them as your diagram shows, or with multiple power supplies that don’t share a common ground.

Pete.

I use this board for power and the marked pins

If I power my lcd and ultrasonic from a single usb adapter power cable, will it solve the issue? And how can I power the 5v relay and how it will work with 3.3 v nodemcu signal?

I don’t think you’ve properly read my previous response, and understood the cause of your issues.

Pete.

I connect the relays with 3v and gnd and, 5v components with vusb and gnd of my above expansion board.

This is bit not clear to me.
Now do you want to tell me that I need to connect the components with common ground? can you please elaborate what do you mean by common ground? or can you give common gnd related docs?

The ground (negative supply wires) of all your power sources need to be connected together, and also to the GND pin of your NodeMCU.

Pete.

1 Like

Ok now I understand. Thanks a lot for your help. I already searched about common ground in the community. Now I am implementing it.