[SOLVED] Problem with NodeMCU Library

Hi everyone,
I have downloaded the NodeMCU esp8266 library from ubidots example but I can´t able to program with it. It always sends message telling me:
In file included from UbidotsGetValue.ino:1:0:
C:\Users\Marcelo\Documents\Arduino\libraries\ubidots-nodemcu-master/UbidotsMicroESP8266.h:4:25: fatal error: ESP8266WiFi.h: No such file or directory
#include <ESP8266WiFi.h>
^
compilation terminated.

Is there anyone could fix this?

Hey! @Marcelo
How are you?
Did you follow all steps in our documentation? I think that this error is because you forgot to download the ESP8266 boards integration for Arduino, and change from Arduino UNO to NodeMCU 1.0:

http://ubidots.com/docs/devices/nodeMCU.html#requiremets

##steps

  1. Go to the Arduino IDE, click on Files -> Preferences and enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field. You can add multiple URLs, separating them with commas
  2. Open Boards Manager from Tools -> Board menu and install esp8266 platform (and don’t forget to select your ESP8266 board from Tools > Board menu after installation)
  3. Download the UbidotsMicroESP8266 library here
  4. Now, click on Sketch -> Include Library -> Add .ZIP Library
  5. Select the .ZIP file of UbidotsMicroESP8266 and then “Accept” or “Choose”
  6. Close the Arduino IDE and open it again.

If the problem persists let me know and will help you as soon as possible!
Good day!

Hi Metavix
i did this. The problem is in the library that don´t work, saying the ESP8266Wifi isn´t in sketch. I think that something is missing!!!

ESP8266Wifi is a header of ESP8266 borad manager. Is a library of ESP8266. You can check it here:

I have an idea: Try to run this example of ESP8266 library, if you get the same error is a problem of installation of ESP8266 in Arduino Boards manager.

/*
 *  This sketch sends data via HTTP GET requests to data.sparkfun.com service.
 *
 *  You need to get streamId and privateKey at data.sparkfun.com and paste them
 *  below. Or just customize this script to talk to other HTTP servers.
 *
 */

#include <ESP8266WiFi.h>

const char* ssid     = "your-ssid";
const char* password = "your-password";

const char* host = "data.sparkfun.com";
const char* streamId   = "....................";
const char* privateKey = "....................";

void setup() {
  Serial.begin(115200);
  delay(10);

  // We start by connecting to a WiFi network

  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  
  WiFi.begin(ssid, password);
  
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");  
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

int value = 0;

void loop() {
  delay(5000);
  ++value;

  Serial.print("connecting to ");
  Serial.println(host);
  
  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  const int httpPort = 80;
  if (!client.connect(host, httpPort)) {
    Serial.println("connection failed");
    return;
  }
  
  // We now create a URI for the request
  String url = "/input/";
  url += streamId;
  url += "?private_key=";
  url += privateKey;
  url += "&value=";
  url += value;
  
  Serial.print("Requesting URL: ");
  Serial.println(url);
  
  // This will send the request to the server
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" + 
               "Connection: close\r\n\r\n");
  unsigned long timeout = millis();
  while (client.available() == 0) {
    if (millis() - timeout > 5000) {
      Serial.println(">>> Client Timeout !");
      client.stop();
      return;
    }
  }
  
  // Read all the lines of the reply from server and print them to Serial
  while(client.available()){
    String line = client.readStringUntil('\r');
    Serial.print(line);
  }
  
  Serial.println();
  Serial.println("closing connection");
}

Best regards,
Metavix

@Marcelo
By the way, maybe this will work. Try to put in your sketch:

#include "ESP8266WiFi.h"

Before of:

#include "UbidotsMicroESP8266.h"

It is a possible solution, could you try it?
Best regards,
Metavix

1 Like

Thank you Metavix!!!

@flash_os you are welcome!

Hi ! I am currently facing a similar issue…

UbidotsMicroESP8266.h: No such file or directory

I currently have the latest ubidots-esp8266-master library but i am still unable to compile.

I only have the ESP8266 without any other serial connection to any Arduino board.
My board is selected as : ‘Generic 8266 Module’

Hope anyone here can help ! Thank you !

Hi there, please download the latest library version here. According to the examples, the library header is not UbidotsMicroESP8266.h but Ubidots.h, so please review the examples and adapt them to your needs.

All the best

1 Like

Thanks @jotathebest !