Error compiling for board NodeMCU 1.0 (ESP-12E Module)

Hi, I am trying to use firebase to send ultrasonic sensor data to the database I have created there.

I know there are a lot of these types of topics, but I wasn't able to find a solution looking through those examples

I have downloaded the latest esp8266 stuff from boards manager, and also zipped the firebase-Arduino library

Both the code for the wifi and the code for the ultrasonic sensor work separately.

Here is my code

#include "ESP8266WiFi.h"
#include <FirebaseArduino.h>
#define FIREBASE_HOST "https://te***3.firebaseio.com"
#define FIREBASE_AUTH "uVmT***Xi"

#define WIFI_SSID "VM***95"
#define WIFI_PASSWORD "vys***qy"

// Set these to run example.

const char* ssid = "VM***95"; //Enter SSID
const char* password = "vys***qy"; //Enter Password

// defines pins numbers

const int trigPin = 2;  //D4
const int echoPin = 0;  //D3

// defines variables
long duration;
int distance;

void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication


Serial.begin(115200);
// Connect to WiFi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) 
{
delay(500);
Serial.print("*");
}

Serial.println("");
Serial.println("WiFi connection Successful");
Serial.print("The IP Address of ESP8266 Module is: ");
Serial.print(WiFi.localIP());// Print the IP address
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}
// Firebase.setInt("LEDStatus",0);


void loop() {

// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);

// Calculating the distance
distance= duration*0.034/2;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);

// Check for errors {
if (Firebase.failed()) 
Serial.print("setting /number failed:");
Serial.println(Firebase.error());
return;
delay(2500);
}

and this is the error message presented

Build options changed, rebuilding all
In file included from C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/Firebase.h:30:0,

                 from C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseArduino.h:22,

                 from C:\Users\jonat\Documents\year 3\dissertation\nodeMCU_sending_uss_data\nodeMCU_sending_uss_data.ino:2:

C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseObject.h:109:21: error: 'StaticJsonBuffer' was not declared in this scope

     std::shared_ptr<StaticJsonBuffer<FIREBASE_JSONBUFFER_SIZE>> buffer_;

                     ^

In file included from C:\Users\jonat\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.hpp:10:0,

                 from C:\Users\jonat\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.h:9,

                 from C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/Firebase.h:26,

                 from C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseArduino.h:22,

                 from C:\Users\jonat\Documents\year 3\dissertation\nodeMCU_sending_uss_data\nodeMCU_sending_uss_data.ino:2:

C:\Users\jonat\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Object/ObjectRef.hpp:13:69: error: template argument 1 is invalid

   ((NUMBER_OF_ELEMENTS) * sizeof(ARDUINOJSON_NAMESPACE::VariantSlot))

                                                                     ^

C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseObject.h:28:34: note: in expansion of macro 'JSON_OBJECT_SIZE'

 #define FIREBASE_JSONBUFFER_SIZE JSON_OBJECT_SIZE(32)

                                  ^

C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseObject.h:109:38: note: in expansion of macro 'FIREBASE_JSONBUFFER_SIZE'

     std::shared_ptr<StaticJsonBuffer<FIREBASE_JSONBUFFER_SIZE>> buffer_;

                                      ^

In file included from C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/Firebase.h:30:0,

                 from C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseArduino.h:22,

                 from C:\Users\jonat\Documents\year 3\dissertation\nodeMCU_sending_uss_data\nodeMCU_sending_uss_data.ino:2:

C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseObject.h:109:62: error: expected unqualified-id before '>' token

     std::shared_ptr<StaticJsonBuffer<FIREBASE_JSONBUFFER_SIZE>> buffer_;

                                                              ^

In file included from C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseArduino.h:22:0,

                 from C:\Users\jonat\Documents\year 3\dissertation\nodeMCU_sending_uss_data\nodeMCU_sending_uss_data.ino:2:

C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/Firebase.h:86:19: error: 'StaticJsonBuffer' was not declared in this scope

   std::shared_ptr<StaticJsonBuffer<FIREBASE_JSONBUFFER_SIZE>> buffer_;

                   ^

In file included from C:\Users\jonat\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.hpp:10:0,

                 from C:\Users\jonat\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.h:9,

                 from C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/Firebase.h:26,

                 from C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseArduino.h:22,

                 from C:\Users\jonat\Documents\year 3\dissertation\nodeMCU_sending_uss_data\nodeMCU_sending_uss_data.ino:2:

C:\Users\jonat\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Object/ObjectRef.hpp:13:69: error: template argument 1 is invalid

   ((NUMBER_OF_ELEMENTS) * sizeof(ARDUINOJSON_NAMESPACE::VariantSlot))

                                                                     ^

C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseObject.h:28:34: note: in expansion of macro 'JSON_OBJECT_SIZE'

 #define FIREBASE_JSONBUFFER_SIZE JSON_OBJECT_SIZE(32)

                                  ^

C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/Firebase.h:86:36: note: in expansion of macro 'FIREBASE_JSONBUFFER_SIZE'

   std::shared_ptr<StaticJsonBuffer<FIREBASE_JSONBUFFER_SIZE>> buffer_;

                                    ^

In file included from C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseArduino.h:22:0,

                 from C:\Users\jonat\Documents\year 3\dissertation\nodeMCU_sending_uss_data\nodeMCU_sending_uss_data.ino:2:

C:\Users\jonat\Documents\Arduino\libraries\firebase-arduino-master\src/Firebase.h:86:60: error: expected unqualified-id before '>' token

   std::shared_ptr<StaticJsonBuffer<FIREBASE_JSONBUFFER_SIZE>> buffer_;

                                                            ^

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

Apolagies if this is an abovious mistake, I'm quite new to coding in general, thanks in advance.

Did you try compiling any of the examples that came with the firebase-arduino-master library?

PaulS:
Did you try compiling any of the examples that came with the firebase-arduino-master library?

Yes I did, and I am getting the same, 'Error compiling for board NodeMCU 1.0 (ESP-12E Module).'

This error means you're using a version of ArduinoJson library that is not compatible with this code. The ArduinoJson library 6.x.x versions have breaking changes that make them not work with code written for the ArduinoJson 5.x.x versions.

The recommended solution is to roll back to the newest 5.x.x release of ArduinoJson:

  • Sketch > Include Library > Manage Libraries...
  • Wait for the download to finish.
  • In the "Filter your search..." box, type "arduinojson".
  • In the search results, click on "ArduinoJson by Benoit Blanchon"
  • From the dropdown version menu, select "5.13.4".
  • Click "Install".
  • Wait for the installation to finish.
  • Click "Close'. The code should now compile.

The alternative solution is to update the code to work with the 6.x.x versions of ArduinoJson. You will find a guide to this here:

Reference:

pert:
This error means you're using a version of ArduinoJson library that is not compatible with this code. The ArduinoJson library 6.x.x versions have breaking changes that make them not work with code written for the ArduinoJson 5.x.x versions.

The recommended solution is to roll back to the newest 5.x.x release of ArduinoJson:

  • Sketch > Include Library > Manage Libraries...
  • Wait for the download to finish.
  • In the "Filter your search..." box, type "arduinojson".
  • In the search results, click on "ArduinoJson by Benoit Blanchon"
  • From the dropdown version menu, select "5.13.4".
  • Click "Install".
  • Wait for the installation to finish.
  • Click "Close'. The code should now compile.

The alternative solution is to update the code to work with the 6.x.x versions of ArduinoJson. You will find a guide to this here:
Migrating from version 5 to 6 | ArduinoJson 6

Reference:
Redirecting…

Thank you so much it compiles fine. However, now when I try to upload it onto the NodeMCU I get this error message:

Sketch uses 361588 bytes (34%) of program storage space. Maximum is 1044464 bytes.
Global variables use 29772 bytes (36%) of dynamic memory, leaving 52148 bytes for local variables. Maximum is 81920 bytes.
Uploading 365728 bytes from C:\Users\jonat\AppData\Local\Temp\arduino_build_389304/nodeMCU_sending_uss_data.ino.bin to flash at 0x00000000
................................................................................ [ 22% ]
................................................................................ [ 44% ]
................................................................................ [ 67% ]
......................An error occurred while uploading the sketch

It seems like I don't have enough space to upload the code, but I should, shouldn't I? Is there a reason its so large?

joodaa:
Thank you so much

You're welcome.

joodaa:
It seems like I don't have enough space to upload the code

I don't believe that's the problem.

Please do this:

  • File > Preferences > Show verbose output during: > compilation (uncheck) > upload (check) > OK
  • Sketch > Upload
  • After the upload fails you'll see a button on the right side of the orange bar "Copy error messages". Click that button.
  • Paste the error messages in a reply here using code tags (</> button on the forum toolbar).

joodaa:
Is there a reason its so large?

There's a lot of background code in the ESP8266 for the WiFi. That causes even a basic sketch to be huge, when compared to the same sketch compiled for an Uno. Luckily, the ESP8266 also has a lot of memory so it's not such a problem. The worst part of it is that the large size causes compilation and uploads to take a long time, and perhaps make uploads a bit more likely to fail. I grown accustomed to getting an occasional upload error with my ESP8266 boards. I just try uploading again and it almost always works fine on the second try.

pert:
You're welcome.
I don't believe that's the problem.

Please do this:

  • File > Preferences > Show verbose output during: > compilation (uncheck) > upload (check) > OK
  • Sketch > Upload
  • After the upload fails you'll see a button on the right side of the orange bar "Copy error messages". Click that button.
  • Paste the error messages in a reply here using code tags (</> button on the forum toolbar).

There's a lot of background code in the ESP8266 for the WiFi. That causes even a basic sketch to be huge, when compared to the same sketch compiled for an Uno. Luckily, the ESP8266 also has a lot of memory so it's not such a problem. The worst part of it is that the large size causes compilation and uploads to take a long time, and perhaps make uploads a bit more likely to fail. I grown accustomed to getting an occasional upload error with my ESP8266 boards. I just try uploading again and it almost always works fine on the second try.

This is the error message that I copied;

Arduino: 1.8.8 (Windows Store 1.8.19.0) (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled, 4M (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 9600"

Sketch uses 264092 bytes (25%) of program storage space. Maximum is 1044464 bytes.
Global variables use 26824 bytes (32%) of dynamic memory, leaving 55096 bytes for local variables. Maximum is 81920 bytes.
C:\Users\jonat\Documents\ArduinoData\packages\esp8266\tools\esptool\2.5.0-3-20ed2b9/esptool.exe -vv -cd nodemcu -cb 9600 -cp COM4 -ca 0x00000 -cf C:\Users\jonat\AppData\Local\Temp\arduino_build_603405/nodeMCU_uss.ino.bin 
esptool v0.4.13-1-gf80ae31 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
	setting board to nodemcu
	setting baudrate from 115200 to 9600
	setting port from COM1 to COM4
	setting address from 0x00000000 to 0x00000000
	espcomm_upload_file
	espcomm_upload_mem
	setting serial port timeouts to 1000 ms
opening bootloader
resetting board
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	read 0, requested 1
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	espcomm_send_command: receiving 2 bytes of data
	espcomm_send_command: receiving 2 bytes of data
	espcomm_send_command: receiving 2 bytes of data
	espcomm_send_command: receiving 2 bytes of data
	espcomm_send_command: receiving 2 bytes of data
	espcomm_send_command: receiving 2 bytes of data
	espcomm_send_command: receiving 2 bytes of data
	espcomm_send_command: receiving 2 bytes of data
Uploading 268240 bytes from C:\Users\jonat\AppData\Local\Temp\arduino_build_603405/nodeMCU_uss.ino.bin to flash at 0x00000000
	erasing flash
	size: 0417d0 address: 000000
	first_sector_index: 0
	total_sector_count: 66
	head_sector_count: 16
	adjusted_sector_count: 50
	erase_size: 032000
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	setting serial port timeouts to 15000 ms
	setting serial port timeouts to 1000 ms
	espcomm_send_command: receiving 2 bytes of data
	writing flash
................................................................................ [ 30% ]
................................................................................ [ 61% ]
................................................................................ [ 91% ]
.....................An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

This problem is now carrying to other sketches and not just this one, I can't upload anything, even though they compile correctly.

Also, this sketch is different from the one before, because I'm in a different location currently, but I am getting the same message no matter which sketch I try to upload. I'll do the same with the other and post it in a few hours.

The verbose output give some more information, but I don't know whether any of it will be helpful.

I was thinking of suggesting that you try setting Tools > Upload Speed to a lower value, but it looks like you already have it set to the lowest speed of 9600. I wonder if that might be too low? Maybe try some different speeds to see if that helps? Purely a guess, but it's worth a try.

pert:
The verbose output give some more information, but I don't know whether any of it will be helpful.

I was thinking of suggesting that you try setting Tools > Upload Speed to a lower value, but it looks like you already have it set to the lowest speed of 9600. I wonder if that might be too low? Maybe try some different speeds to see if that helps? Purely a guess, but it's worth a try.

Thank you again, you were right it was the upload speed, too slow before

Also, not al micro USB's work with my nodeMCUs, do have any idea why? I currently have three but only 1 works.

You didn't get them with a charger or battery pack by any chance? They don't have data connected in the lead, only power. Fell for that one myself once.

tasmod:
You didn't get them with a charger or battery pack by any chance? They don't have data connected in the lead, only power. Fell for that one myself once.

Unfortunately no, I got two, and they arrived by themselves. Is there any way to know which micro USB's will do the job?

Also, what would you say is the best way to power them without the use of a laptop/computer? Ideally for a few days without the need to replace the battery.

joodaa:
Thank you again, you were right it was the upload speed, too slow before

I'm glad to hear it. I guessed right!

joodaa:
Unfortunately no, I got two, and they arrived by themselves. Is there any way to know which micro USB's will do the job?

The product description when you buy the cable should say something about it being a charging cable if it's one of those annoying ones without the data lines connected. I accidentally bought a couple on eBay that caused me some confusion and the description was very vague. I have also had problems with some very low quality USB cables that do have the data lines connected. I think maybe they use such small gauge wires in these things to save a penny that the voltage drop is too much to the relatively power hungry ESP8266.

pert:
The product description when you buy the cable should say something about it being a charging cable if it's one of those annoying ones without the data lines connected. I accidentally bought a couple on eBay that caused me some confusion and the description was very vague. I have also had problems with some very low quality USB cables that do have the data lines connected. I think maybe they use such small gauge wires in these things to save a penny that the voltage drop is too much to the relatively power hungry ESP8266.

Ok thanks again, I'll buy a few different ones and see what works

sorry if anyone can help me about this problem

Arduino: 1.8.5 (Windows 7), Board: "WeMos D1 R2 & mini, 80 MHz, 4M (1M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 921600"

Build options changed, rebuilding all
C:\Users\bj\AppData\Local\Temp\arduino_modified_sketch_267508\FlashLED.ino:2:29: fatal error: FirebaseArduino.h: No such file or directory

#include <FirebaseArduino.h>

^

compilation terminated.

exit status 1
Error compiling for board Generic ESP8266 Module.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

this is my code

#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>

#define FIREBASE_HOST “saklartest.firebxxxxx.com
#define FIREBASE_AUTH “AIzaSyBLXHZ76IVVpkkJrpNk6xxxxxxxxxx”
#define WIFI_SSID “bexxxx”
#define WIFI_PASSWORD “bexxxxxxx”

int ledState=0;
int LED_PIN =2; //LED internal
int BUTTON_PIN = D1;
int OUT_PIN = D5;

void setup() {
Serial.begin(9600);
pinMode(BUTTON_PIN,INPUT_PULLUP);// tombol
pinMode(LED_PIN,OUTPUT); // LED
pinMode(OUT_PIN,OUTPUT); // output PIN

// connect to wifi.
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print(“connecting”);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(“.”);
delay(500);
}
Serial.println();
Serial.print(“connected: “);
Serial.println(WiFi.localIP());

Firebase.begin(FIREBASE_HOST,FIREBASE_AUTH);
}

void loop() {

// get value
Serial.print(“Nilai Saklar: “);
Serial.println(Firebase.getInt(“saklar”));
ledState=Firebase.getInt(“saklar”);

btnState=digitalRead(BUTTON_PIN);
if (btnState==LOW)
{
ledState = !ledState;
digitalWrite(LED_PIN,ledState);
Serial.print(“Data berubah…”);
}

if (ledState==0)
{digitalWrite(LED_PIN,HIGH);
digitalWrite(OUT_PIN,HIGH);
}
else
{digitalWrite(LED_PIN,LOW);
digitalWrite(OUT_PIN,LOW);
}
// mengirim nilai
Firebase.setInt(“saklar”, ledState);
if (Firebase.failed()) {
Serial.print(“setting /truth failed:”);
Serial.println(Firebase.error());
return;
}

When you see a "No such file or directory" error it almost always means you need to install the library that contains the missing file.

Often the code you're compiling will come with documentation (either a comment or separate document) that tells you where to get the library dependencies.

In other cases the author of the code will not have been so kind and you'll need to go on a hunt for the missing library.

A good place to start is the Arduino IDE's Library Manager:

  • Sketch > Include Library > Manage Libraries...
  • In the "Filter your search..." box, type some keywords you have gleaned from the missing file name.
  • Scroll through the results for the right library. Click on it.
  • Click "Install".
  • Wait for installation to finish.
  • Click "Close".
  • Try compiling your code again.

If you have no luck in Library Manager then load up your favorite search engine and do a search for the missing filename. You will often get multiple results. If you have a lot of results you might add "arduino" as an additional search keyword. I will usually prefer results on github.com since that is where most Arduino libraries are hosted and downloading from there is fast and easy. In some cases there will be multiple libraries that contain the given filename and you'll need to do some evaluation to determine which seems the most appropriate, then try it out. After downloading the library you found you'll need to install it. This requires a different process than the Library Manager installation. You will find instructions here:

OK who is the wise guy using "REPORT TO MODERATOR" to reply.

That is not what the button is for LOL.

Bob.

Thanks a Lot!!!!
Two days having the same problem as joodaa and thanks to this, code compiled!!!

pert:
This error means you're using a version of ArduinoJson library that is not compatible with this code. The ArduinoJson library 6.x.x versions have breaking changes that make them not work with code written for the ArduinoJson 5.x.x versions.

The recommended solution is to roll back to the newest 5.x.x release of ArduinoJson:

  • Sketch > Include Library > Manage Libraries...
  • Wait for the download to finish.
  • In the "Filter your search..." box, type "arduinojson".
  • In the search results, click on "ArduinoJson by Benoit Blanchon"
  • From the dropdown version menu, select "5.13.4".
  • Click "Install".
  • Wait for the installation to finish.
  • Click "Close'. The code should now compile.

The alternative solution is to update the code to work with the 6.x.x versions of ArduinoJson. You will find a guide to this here:
Migrating from version 5 to 6 | ArduinoJson 6

Reference:
Redirecting…