How to connect Arduino mega and esp8266 to firebase

how to connect Arduino mega and esp8266 to firebase
please help me
At first, I changed the AT_firmware for esp8266 as shown in the picture

image

and then I connected the MFRc522 and ultrasonic with the Arduino Mega and it worked fine, but when I used it with the firebase, the following errors appeared to me

In file included from C:\Users\MASADER\Desktop\sketch_feb22a\sketch_feb22a.ino:5:0:
C:\Users\MASADER\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseHttpClient.h:4:10: fatal error: string: No such file or directory
#include
^~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino Mega or Mega 2560.

The code is

#include "WiFiEsp.h"
#include <SPI.h>
#include <MFRC522.h>
#include <ArduinoJson.h>
#include <FirebaseHttpClient.h>
#include <FirebaseArduino.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// ********************************************************* DEFINITIONS *********************************************************
char ssid[] = ""; // your network SSID (name)
char pass[] = "
"; // your network password
int status = WL_IDLE_STATUS; // the Wifi radio's status

const int trigPin1 = 8;
const int echoPin1 = 9;

const int trigPin2 = 10;
const int echoPin2 = 11;
String CustomerUid;

#define SS_PIN 53
#define RST_PIN 49
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.

#define FIREBASE_HOST ""
#define FIREBASE_AUTH "
"

// set the LCD address to 0x27 for a 20 chars 4 line display
LiquidCrystal_I2C lcd(0x27,16,2);

// ********************************************************* INITIALIZE *********************************************************
void setup() {
Serial.begin(115200); // initialize serial 0 for debugging
Serial1.begin(115200);
pinMode(trigPin1, OUTPUT);
pinMode(echoPin1, INPUT);
pinMode(trigPin2, OUTPUT);
pinMode(echoPin2, INPUT);

lcd.init();
// Print our characters on the LCD
lcd.backlight(); //Backlight ON if under program control
lcd.setCursor(3,0); //Start at character 3 on line 0
lcd.print("Hello, world!");
delay(1000);
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522

// initialize serial 1 for ESP module
WiFi.init(&Serial1); // initialize ESP module
if (WiFi.status() == WL_NO_SHIELD) { // check for the presence of the shield
Serial.println("WiFi shield not present"); // If shield not present, don't continue
while (true);
}
while ( status != WL_CONNECTED) { // attempt to connect to WiFi network
Serial.print("Attempting to connect to WPA SSID: "); // Print message to serial monitor
Serial.println(ssid); // Print SSID to serial monitor
status = WiFi.begin(ssid, pass); // Connect to WPA/WPA2 network
}
Serial.println("You're connected to the network"); // Print success message to serial monitor
// connect to Firebase.
//Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
//delay(1000);
//Firebase.setString("park/park1/car","1");
//delay(1000);
}

// ********************************************************* MAIN LOOP *********************************************************
void loop()
{

// Look for new cards

if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
CustomerUid = "";
for (byte i = 0; i < mfrc522.uid.size; i++)
{
CustomerUid.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
CustomerUid.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println(CustomerUid);
// Halt PICC
mfrc522.PICC_HaltA();
// check the network connection once every 10 seconds
Serial.println();
//printCurrentNet();
//printWifiData();
Serial.println(getDistanceCm(trigPin1, echoPin1));
delay(1000);
Serial.println(getDistanceCm(trigPin2, echoPin2));

}

// ********************************************************* FUNCTION DEFINITIONS *********************************************************
// Print WiFi data to serial Monitor --------------------------------------------------------
void printWifiData()
{
// *** print your WiFi shield's IP address
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);

// *** print your MAC address
byte mac[6];
WiFi.macAddress(mac);
char buf[20];
sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X", mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]);
Serial.print("MAC address: ");
Serial.println(buf);
}

// Print WiFi connection details to serial Monitor --------------------------------------------------------
void printCurrentNet()
{
// *** print the SSID of the network you're attached to
Serial.print("SSID: ");
Serial.println(WiFi.SSID());

// *** print the MAC address of the router you're attached to
byte bssid[6];
WiFi.BSSID(bssid);
char buf[20];
sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X", bssid[5], bssid[4], bssid[3], bssid[2], bssid[1], bssid[0]);
Serial.print("BSSID: ");
Serial.println(buf);

// *** print the received signal strength
long rssi = WiFi.RSSI();
Serial.print("Signal strength (RSSI): ");
Serial.println(rssi);

}

int getDistanceCm(const int trigPin, const int echoPin){
int distanceCm;
long duration;

digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);// Returns the duration in microseconds or gives up and returns 0 if no complete pulse was received within the timeout.
distanceCm = duration*0.034/2;
if(distanceCm <= 2)
return 0;
else
return distanceCm;
}

Hello, do yourself a favour and please read How to get the best out of this forum and modify your post accordingly (including necessary documentation for your ask).


tons of example on line, tell us why it does not work for you

here is one (first google hit): https://create.arduino.cc/projecthub/pulasthi-Narada/connecting-esp8266-to-firebase-to-send-receive-data-4adf66

Post has been modified

These steps are for the Arduino UNO to connect only to FireBase, but you cannot connect several other components with it

which platform is WiFiEsp.h designed for?
which platform are you trying to compile code for?

--
please edit your first post and add code tags. Looks like a mess at the moment

I want to read MFRC522 and save the result on Firebase as well as read Ultrasonic by connecting them with Arduino Mega + esp8266

You want the MEGA to read MFRC522 card and then you want the MEGA to ask the ESP8266 to send the data to firebase

what's running on the ESP8266 ?

what's the platform used for FirebaseHttpClient.h ?

share links to all the libraries you have in the code

#include "WiFiEsp.h"
#include <SPI.h>
#include <MFRC522.h>
#include <ArduinoJson.h>
#include <FirebaseHttpClient.h>
#include <FirebaseArduino.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

PS: no more answer from me until post #1 is fixed and code tags added.

attachments:
https://drive.google.com/drive/folders/1SALtCNiXaEMIW4ED1SGKlrrLJ1GeLw40?usp=sharing

what's running on the ESP8266 ?
upload AT_firmware on it as shown in the figure above
what's the platform used for FirebaseHttpClient.h ?
Not used

hello anybody here

so why do you have

#include <FirebaseHttpClient.h>

in the code you posted? the compiler complains about this

C:\Users\MASADER\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseHttpClient.h:4:10: fatal error: string: No such file or directory

FirebaseArduino.h not work WiFiEsp.h but when we select from Tools>Boar:>Generic ESP8266 Module works well and no error .

sorry I don't get what you say

when you select ESP8266 Board from Tools menu, Firebase works will

but you are not compiling for an ESP8266 Board

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.