How to Connect Arduino Uno to the Internet using ESP Module?

Arduino Uno doesn’t have a built-in Wi-Fi module. To make a connection to the server, ESP-01 module can be used as an external Wi-Fi module.
featured image
Tasnim Zotder
Apr 5, 2022
⏱️ 2 Minutes

In Brief

  1. add the library Uno ESP-WiFi Library to your project from GitHub
  2. import the library as #include <UnoESPWiFi>
  3. make an instance with Rx & Tx pins, UnoESPWiFi wifi(2, 3);
  4. set the baud rate as wifi.serialBegin(115200);
  5. connect to the wifi as wifi.connect("ssid", "password");
  6. send server configurations as wifi.serverConfig("server", PORT);
  7. send the data to the server as wifi.writeToServer(data);

Components Required

  • Arduino Uno
  • ESP-01 module
  • Jumper wires (male-to-female and male-to male)
  • Breadboard

Basic Theory

Arduino Uno doesn’t have a built-in Wi-Fi module. So, it can’t directly communicate with the server. To make an internet connection, Arduino Uno needs an external Wi-Fi module. ESP-01 is a viable choice. In this case, Arduino Uno communicates with ESP-01 module with serial communication protocol.
To control the functionalities, AT commands are used. These commands are sent to the ESP-01 module through serial communication. The board shows a positive reply to the AT commands as OK.  These are the few AT Commands -

Command Description
AT Tests AT startup
AT+RST Restarts the module
AT+CWMODE="ssid","password" Connects to an access point

Here, in the Uno ESP-WiFi Library, these commands along with other commands are used to connect Arduino Uno to server.


The ESP-01 module works on 3.3V. More voltage like 5V can destroy the module. Connect the pins of ESP-01 with the pins of Arduino Uno as follows -

ESP-01 Pin Arduino Uno Pin
VCC 3.3V
Tx 2 (Rx)
Rx 3 (Tx)

Demo Code

#include <Arduino.h>
#include <UnoESPWiFi.h>

// create an instance of the class
UnoESPWiFi wifi(2, 3);

void setup() {
	// initialize serial communication

    // initialize wifi with baud rate of 115200

    // connect to wifi network
    wifi.connect("ssid", "password");

    // server config
    wifi.serverConfig("server", 80);

void loop () {
    String data = "hello from another universe!");

    // send data to server (example - thingspeak)
    String data = "GET /update?api_key=";
    data += "API_KEY";
    data += "&field1=";
    data += String(data);
    data += "\r\n\r\n";


Code Explanations

#include <Arduino.h>
#include <UnoESPWiFi.h>

This includes Arduino.h and UnoESPWiFi.h libraries to the project. Arduino.h is required to perform the core functionalities and the UnoESPWiFI.h is to connect the Arduino board to the server.

UnoESPWiFi wifi(2, 3);

This creates an instance of the class UnoESPWiFi which accepts two arguments. The first one is Rx pin and the second one is Tx pin. For these Rx & Tx pins, one can choose any digital pins except D0 & D1.


Serial.begin() initializes the serial communication with Arduino and wifi.serialBegin() initializes the serial communication with ESP-01 module.

wifi.connect("ssid", "password");

This connects the ESP-01 module to the Wi-Fi access point.

wifi.serverConfig("server", 80);

set sets the server configurations like server IP address and PORT number. Here port 80 is for http protocol.


This function sends data to the ESP-01 module which delivers the data to the given server.

  • Blog
  • YouTube
  • Portfolio

© Tasnim Zotder | 2022