HTTP Client Example for ESP8266 to send information to remote location

Project Video
Project Details

This code which has been explained in the video above will send three parameters (below) using HTTP Client to remove location over the WiFi.

  1. User name
  2. Temperature
  3. Type

The link to use in the "preferences" of Arduino IDE
The link which ESP8266 sends data too

Topics shown in video

  • 00:57 Introduction to NodeMCU ESP8266
  • 04:20 Datasheet viewed
  • 06:23 Voltage explained
  • 09:07 Preparing IDE (Arduino)
  • 10:46 Selecting COM port
  • 11:48 LED blink
  • 13:11 GPIO Pins mapping
  • 14:25 Pin mapping (2)
  • 15:38 HTTP client (connecting to WiFi)

Project Code


 *  HTTP Client example modified to send 3 parameters using ESP8266 as HTTP Client
 * Modified by Ahmad Shamshiri for Robojax
 * on August 30, 2019 in Ajax, Ontario, Canada
 Watch the video instruction for this sketch:


Learn Arduino step by step with all library, codes, wiring diagram all in one place
visit my course now

If you found this tutorial helpful, please support me so I can continue creating 
content like this. You can support me on Patreon
or make donation using PayPal

Original code by BARRAGAN 
 * Code is available at

 * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.* 
 * This code has been download from
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see . 






ESP8266WiFiMulti WiFiMulti;
String mainURL ="";
String user="user=ahmad22";
float temperature=45.3;
char type='j';

void setup() {

  // Serial.setDebugOutput(true);


  for (uint8_t t = 4; t > 0; t--) {
    Serial.printf("[SETUP] WAIT %d...\n", t);

  WiFiMulti.addAP("Robojax", "4YouTubegnA&#24Qw~");


void loop() {
  // wait for WiFi connection
  if (( == WL_CONNECTED)) {

    WiFiClient client;

    HTTPClient http;

    Serial.print("[HTTP] begin...\n");
    if (http.begin(client, mainURL+user+"&temp="+temperature+"&type="+type)) {  // HTTP

      Serial.print("[HTTP] GET...\n");
      // start connection and send HTTP header
      int httpCode = http.GET();

      // httpCode will be negative on error
      if (httpCode > 0) {
        // HTTP header has been send and Server response header has been handled
        Serial.printf("[HTTP] GET... code: %d\n", httpCode);

        // file found at server
        if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
          String payload = http.getString();
      } else {
        Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());

    } else {
      Serial.printf("[HTTP} Unable to connect\n");


If you found this Arduino course helpful, please support me so I can continue creating content like this. support me via PayPal