Esp-01 setup error while compilation

Success sir This lil bit of explanation worked :slight_smile:

And was required because you don’t take heed of the advice and information you have already been given!


Looks like it’s not finished yet… :frowning:
I’m running into trouble in mega. I have connected Rx and Tx to 18 & 19 to mega respectively. The code is getting compilation error it says Serial1 is not declared in the scope. Please help.

#include <Arduino.h>
// #include <BlynkSimpleStream.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "ygTs5I9cg_";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "No Network";
char pass[] = "nopassword";

//Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial1

// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

int G=8;
int buttonstate1=0;

ESP8266 wifi(&EspSerial);

void setup()
  // Debug console
  // Serial.begin(9600);
  // Set ESP8266 baud rate
  pinMode(G, OUTPUT);
  pinMode(13, OUTPUT);

  Serial.Println("This is working");  

  Blynk.begin(auth, wifi, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, wifi, ssid, pass, "", 80);
  //Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8080);

  buttonstate1 = param.asInt();

  if(buttonstate1 == 1)
  digitalWrite(G, HIGH);

  digitalWrite(G, LOW);

void loop()

  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!

Uno doesn’t have a Serial1 port.


This is not uno. This is now connected to mega as I mentioned above… It was working fine in uno using software serial.

I repeat…


Sorry for that. I actually forgot to change the board. It’s working now but I’m unable to use Serial.println.

Have you ever heard the phrase “There are none so blind as those who will not see”?


I would rather prefer a direct answer. But later realized it was a caps P.

Yep, and the compiler even asked you - twice - “did you mean ‘println’”, but you didn’t bother to pay attention to that.



So this doesn’t support Wifi.status()? How can I print it? My wifi is getting connected and now it’s time to debug. But first I wanna know wifi status whenever it gets connected or disconnected

That’s one of the reasons why I said…

The BlynkSimpleShieldEsp8266.h library is acting as a wrapper, and translates communication calls in your sketch into AT commands that are passed to the ESP-01’s AT firmware. It also takes the responses from the AT firmware, translates them, and passes them back to the sketch.
The AT command set is limited, and to keep the library small, BlynkSimpleShieldEsp8266.h doesn’t expose all of the AT commands anyway.

Your WiFi object isn’t called WiFi anyway, it’s called wifi

You can use commands like wifi.getLocalIP() which provide a simulated version of the WiFi.getLocalIP()but from memory I think that's about as far as that goes - but you could try wifi.status()`

You could also try turning-on debugging in your Blynk sketch, but that may or may not provide any useful data.


That’s a very nice explanation sir. But the reason I didn’t choose ESP’s bcoz of the limitations of GPIO pins. As far as getting the Wifi status I tried the same getLocalIP() but this is still having limitations as I won’t be able to use !=connected conditions in my sketch…

I would also like to know more about debugging. If you have any links or threads please share them.

And The OTA thing that you were talking about is similar to this- Enter Blynk Credentials Over the Air in ESP32 or NodeMCU board | ESP32 projects | ESP8266 projects - YouTube? Is this not possible in the Arduino mega case?

What limitations are those exactly, how many digital and analogue pins does your project require?

I think you misunderstood what I was saying - try re-reading my previous post.

Too lazy to search yourself?
Okay, here you go - this time…

I think the clue is in the title of the YouTube video… “Enter Blynk Credentials Over the Air in ESP32 or NodeMCU board | ESP32 projects” and I already told you that you can’t do OTA with a Uno or Mega.


I require 22 pins atleast. This is not possible in the case of esp. Also in future I might go with the GSM module instead of Wifi.

I’m also planning to build a tech stack based on aws. I’m not sure though, still working on it. I’m open to tech advice.

Analogue or digital?


Need digital pins

You could potentially do it with an ESP32 at a push, depending on how many needed to be inputs and how many are outputs, and whether you needed to add a GSM module as well.

It’s also quite simple to do with either an ESP8266 or ESP32 and one or two low cost MCP23017 I/O expansion boards…

However, I have to say that I question the logic of your approach.
In my experience, there are very few situations where you need a single MCU to have that many GPIOs, unless you’re going for a centralised hub topology and even then you’d be better having multiple MCUs for redundancy.
For most complex control systems, you’re better-off going for a dispersed topography, with small, relatively low powered MCUs controlling a small number of local devices/sensors.

For example, my home automation system has around 20 separate MCUs, mostly based on NodeMCUs or ESP8285 embedded devices such as Sonoff S20’s or Shelly1’s. These are all located exactly here I need them - close to the object to be controlled or in the location where data needs to be gathered. This removes the necessity to hard-wire all of these devices back to a central physical hub location, and simply requires power to be available at the location where the device is being located.
Because OTA is used, it’s very simple to update any individual device if I identify a bug, or if I want the device to work in a different way.

Also, although I want each of these devices to be individually controllable by Blynk, I don’t run Blynk code on any of these devices. Instead, I use MQTT messaging and control all of the devices from a centralised software hub which gives me the Blynk integration as well as integration with other services such as Amazon Alexa, Zigbee cloud services etc.


Wow that’s nice… I’m looking to build a node based stack which consists of both centralised hub as well as independent devices vis-a-vis they are moving or non-moving device. But as you have suggested, I will read more about MCP23017 board and will try to leverage it. Also I want to know what kind of centralised software hub you use ? Most part of my project will be based on API management so I was thinking to build whole tech stack on aws ecosystem.

Node-Red and Mosquitto as my MQTT broker.

This article hasn’t been updated for a while, and only covers my set-up in Spain. I have a similar setup in the UK which has moved-on quite a bit during lockdown…

Node-Red makes calling APIs very easy with the HTTP(s) response nodes, but in practice there are lots of contributors who develop their own nodes to integrate directly with various systems (like the Blynk websockets node) so API calls often aren’t needed.


1 Like

Doesn’t matter even if it’s not updated… I’ll look into this. It will take time for me to get through all of this and make a final decision. :slight_smile: Thanks a lot for your support.