Connecting Arduino WiFi to the Cloud Using ESP8266

9,972

3

10

About: IoT Maker, co-founder of asksensors.com

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
  • ESP RX to Arduino pin 11
  • ESP VCC to Arduino 3V3
  • ESP CH_PD to Arduino 3V3
  • ESP GND to Arduino GND

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.

Share

    Recommendations

    • Backyard Contest

      Backyard Contest
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Classroom Science Contest

      Classroom Science Contest

    10 Discussions

    0
    None
    uiop90216

    5 weeks ago

    I did everything as instructed, with my arduino uno. In serial monitor it is showing failed as result. what should i do?

    64668.jpg64669.jpg
    1 reply
    0
    None
    mynewy3

    2 months ago

    warning and constructive criticism:
    warning: this instructable is NOT beginner-friendly at all!!!
    constructive criticism: the tutorial can be followed then one would try to connect to the internet , only to fail and not know why! the lack of code explanation and commentary doesn't allow one to understand what's happening or how to troubleshoot.

    1 reply
    0
    None
    mynewy3

    2 months ago

    got these messages after going through all the steps,
    only to wonder, no sensor is connected...what data is this supposed to be reporting to the website ?

    err.PNG
    1 reply
    0
    None
    askSensorsmynewy3

    Reply 2 months ago

    Hello,
    It looks like you have an issue of connection between your Arduino and ESP8266, this could be a reason why the AT command failed.
    Concerning the data sent to AskSensors: you can notice at the end of the URL "module1=..". This shows an example of random data that you can replace later by your sensor data as well.

    0
    None
    SheetalT3

    3 months ago

    I did everything as instructed, with my arduino mega. In serial monitor it is showing failed as result. what should i do?

    1 reply
    0
    None
    askSensorsSheetalT3

    Reply 3 months ago

    Hello,
    could you please describe the way you connect your arduino to the ESP8266 ? (schematic or photo).

    0
    None
    ThugL1

    Question 6 months ago on Step 6

    can you leave a link to the code? i am having trouble reading the image

    1 answer