Introduction: Connecting Arduino WiFi to the Cloud Using ESP8266

About: IoT Maker, co-founder of

In this tutorial we will explain you how to connect your Arduino to the IoT cloud through WiFi.

We will configure a setup composed from an Arduino and an ESP8266 WiFi module as an IoT Thing and make it ready to communicate with the AskSensors cloud.

Let's get started!

Step 1: AskSensors Setup

As the first step we have to setup an account on AskSensors IoT platform. AskSensors is an IoT platform providing communication between internet connected devices and the cloud. It offers a free trial account so you don’t even have to open your wallet to get started!

I recommend to follow this getting started guide. This will show you how to create and account and setup a new sensor to send data to.

Step 2: Prepare Hardware

In this demonstration we will need the following hardware:

  1. Arduino, I'm using an Arduino Uno
  2. ESP8266 WiFi Module, I'm using an ESP-01S
  3. Computer running Arduino IDE
  4. Arduino USB cable
  5. Wires and a breadboard

The photo above shows my prototype.

Step 3: Build the Hardware

The connection between Arduino and ESP8266 is as follows:

  • ESP TX to Arduino pin 10, through 1K resistor.
  • ESP RX to Arduino pin 11, through 1K resistor.
  • ESP VCC to Arduino 3V3
  • ESP CH_PD to Arduino 3V3
  • ESP GND to Arduino GND

Note: The ESP8266 GPIOs require 3V3 signals (not 5V tolerent). For quick hack, you can only add a serial resistor of 1K between the Arduino pins and the ESP8266 pins to protect the ESP8266 GPIOs from damage. However, for production, a 5V/3V3 level shifter is needed to guarantee long term circuit reliability. You can check this page to get a 5V/3V3 level shifter module.

Step 4: Write the Code

Now let’s write the code to send a simple data from the Arduino to the AskSensors cloud through WiFi. The Arduino code communicates with the ESP8266 WiFi module using AT commands. Data will be sent to AskSensors over HTTP connection.

We will need to provide the 'Api Key In' that we got previously from AskSensors in order to send Data to the correct Sensor in the cloud.

Ready to Use code:

A ready to use code is provided in the AskSensors github page. Download the code and set the following variables to your setup (WiFi SSID, password and the 'Api Key In'):

String ssid     = "............."; //Wifi SSID 
String password = "............."; //Wifi Password 
String apiKeyIn = "............."; // API Key

Step 5: Run the Code

Now it's time to connect your board.

  1. Connect the Arduino to your computer through USB cable.
  2. Open Arduino IDE and flash the code.
  3. Open a serial terminal. You should see you Arduino handles AT commands with the ESP8266 which performs the connection to WiFi networks and sending data to the AskSensors cloud over HTTP requests.

Step 6: Visualize Your Data

You can visualize your Data using graph. Go to your AskSensors dashboard and open the sensor that you are sending data to. AskSensors allows user to visualize your data in different type of graphs including Line, Gauge, scatter and Bar. The attached image show the case of Line graph.

You may need:

Others functionalities are available such as visualizing data in full graph Live stream, share your graph with external apps and users, export data in CSV files and more!

Step 7: Well Done!

I hope that this tutorial helped you!

Please refer to this list of tutorials if you need support about connecting hardware like Arduino, ESP8266, ESP32, Raspberry Pi to the cloud.