firebaseiotgsmesp32sim800

Sending Sensor Data to Firebase using ESP32+Sim800L


I have a TTGO T-CALL ESP32+Sim800L board and I want to send accelerometer data to Firebase. I am using the TinyGSM library which supports SSL/https connections for Sim800L. I am currently sending dummy data to see if it works but it is giving me a failed flag. Why is it not sending data to Firebase?

#define FIREBASE_HOST "https://XXXXXXXXXXXXXXXXXfirebaseio.com/"
#define FIREBASE_AUTH "XXXXXXXXXXXXXXXXXXXXhevKwQ3LALblGclqCk"

FirebaseData firebaseData;

void setup()
{
// Set console baud rate
Serial.begin(115200);
// Set-up modem reset, enable, power pins
pinMode(MODEM_PWKEY, OUTPUT);
pinMode(MODEM_RST, OUTPUT);
pinMode(MODEM_POWER_ON, OUTPUT);
digitalWrite(MODEM_PWKEY, LOW);
digitalWrite(MODEM_RST, HIGH);
digitalWrite(MODEM_POWER_ON, HIGH);

// Set GSM module baud rate and UART pins
SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);
delay(3000);

SerialMon.println("Initializing modem...");
modem.init();

SerialMon.print("Connecting to APN: ");
SerialMon.print(apn);
  if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
    SerialMon.println(" fail");
  }else {
    SerialMon.println(" OK");

    Firebase.begin(FIREBASE_HOST,FIREBASE_AUTH);
    SerialMon.println(" Connection to Firebase Successful");
}
}

void loop()
{
String data = "5";
bool res = Firebase.pushString(firebaseData,"/ax", data);
Serial.println("Data sent");
Serial.println(res); 
Serial.println(firebaseData.errorReason());
delay(1000);

}

This is the output:


Solution

  • I didn't find a lot of resources online, however, I did manage to do this and I made a GitHub repo for anyone who needs help with the same.

    Basically as Firebase accepts only Https requests, it is not possible to formulate that on most microcontrollers and GSM modules. To circumvent this problem, I created a php server to which I can send an HTTP POST request and the script can get the data from it and push it to Firebase with a php firebase library.