[SOLVED] ESP8266_Serial_HardSer won't compile

I am frustrated and would really appreciate any help you might be able to offer!

When I try the ESP8266_Serial_HardSer example,I cannot get it to compile, getting the error shown at the bottom of this post.


  • I have an ethernet shield project up and running (was pretty easy…no major issues).

  • I have reloaded the latest Blynk library from GitHub: Blynk_v0.3.1

  • I am using Arduino IDE version 1.6.7 (with an Uno)

  • Since I am not yet even getting compiled, the points below are probably not relevant, but just in case…

  • I believe I should be using the Hardware Shield example (since I am running wires from 2 pins of the Arduino over the 8266 little board.

  • The chip responds to AT commands just fine, giving:


AT version: 8 2015 14:45:58)
SDK version:1.3.0
Ai-Thinker Technology Co.,Ltd.
Build: Sep 11 2015 11:48:04

  • The code (unchanged from File:Examples:Blynk:BoardsAndShields:ESP8266_Serial_HardSer:

  • List item The error message when I compile:

    ESP8266_Shield_HardSer:35: error: ‘Serial1’ was not declared in this scope

    #define EspSerial Serial1


    C:\Users\RRRRRR\AppData\Local\Temp\arduino_4d91a8ce770984b54ba0636d603cfa1c\ESP8266_Shield_HardSer.ino:37:14: note: in expansion of macro ‘EspSerial’

    ESP8266 wifi(EspSerial);


    C:\Users\RRRRRR\AppData\Local\Temp\arduino_4d91a8ce770984b54ba0636d603cfa1c\ESP8266_Shield_HardSer.ino: In function ‘void setup()’:

    ESP8266_Shield_HardSer:35: error: ‘Serial1’ was not declared in this scope

    #define EspSerial Serial1


    C:\Users\RRRRRR\AppData\Local\Temp\arduino_4d91a8ce770984b54ba0636d603cfa1c\ESP8266_Shield_HardSer.ino:49:3: note: in expansion of macro ‘EspSerial’


    exit status 1
    ‘Serial1’ was not declared in this scope

My Arduino code for the above post (unchanged from the example) is:

 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 * This example shows how to use ESP8266 Shield via Hardware Serial
 * (on Mega, Leonardo, Micro...) to connect your project to Blynk.
 * Note: Ensure a stable serial connection to ESP8266!
 *       Firmware version 1.0.0 (AT v0.22) or later is needed.
 *       You can change ESP baud rate. Connect to AT console and call:
 *           AT+UART_DEF=115200,8,1,0,0
 * Change WiFi ssid, pass, and Blynk auth token to run :)
 * Feel free to apply it to any other example. It's simple!
//#define BLYNK_DEBUG
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266_HardSer.h>
#include <BlynkSimpleShieldEsp8266_HardSer.h>

// Set ESP8266 Serial object
#define EspSerial Serial1

ESP8266 wifi(EspSerial);

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

void setup()
  // Set console baud rate
  // Set ESP8266 baud rate

  Blynk.begin(auth, wifi, "ssid", "pass");

void loop()

Hi @joelrsails,
If you are using the Arduino Uno, you should change from #define EspSerial Serial1 to #define EspSerial Serial

On the other hand, I think 115200 is too much for Hardware serial, try using 19200


1 Like

@joelrsails as @psoro points out you don’t have a Serial1 port on an Uno (Mega’s + Leonardo do) so it needs to be just Serial. You can ‘create’ another serial port by going down the soft serial route but it’s not recommended.

If you’re using Arduino UNO, you should probably use Software Serial and baud 9600… This connection method is hard to make right!

1 Like

Sure enough, using the Software Serial Blynk example @ 9600 baud works great! Just had to use the “AT+CIOBAUD=9600” command to change the baud rate of the wifi chip.

Thanks all for the help!

I follow your instruction, and then it works, that change to " #define EspSerial Serial", my baudrate is 9600 for all