firebase-arduino icon indicating copy to clipboard operation
firebase-arduino copied to clipboard

add support for ESP32

Open proppy opened this issue 9 years ago • 27 comments
trafficstars

using the official esp32 arduino core: https://github.com/espressif/arduino-esp32

proppy avatar Nov 01 '16 15:11 proppy

are there any updates on that?

Ahmed-Talaat avatar Apr 21 '17 10:04 Ahmed-Talaat

@Ahmed-Talaat I'm experimenting in that branch: https://github.com/proppy/firebase-arduino/tree/esp32

Got it to compile, but still have TLS issue when making the actual request.

proppy avatar Apr 21 '17 11:04 proppy

Is there anything in particular that we can help with @proppy ?

danielcrowley avatar May 02 '17 12:05 danielcrowley

@danielcrowley sure feel free to try out the branch, and let me know if you also get a TLS error ;)

proppy avatar May 02 '17 17:05 proppy

I got an error.

src/FirebaseArduino.h:22:65: fatal error: third-party/ArduinoHttpClient/src/ArduinoHttpClient.h: No such file or directory

bestpika avatar Jun 07 '17 03:06 bestpika

@bestpika yes, you need to checkout https://github.com/arduino-libraries/ArduinoHttpClient in the third-party directory.

proppy avatar Jun 07 '17 17:06 proppy

@proppy I do it, but got another error (I use example FirebaseDemo_ESP8266 and change #include <WiFi.h>).

FirebaseDemo_ESP8266:43: error: 'Firebase' was not declared in this scope

   Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);

   ^

FirebaseDemo_ESP8266:50: error: 'Firebase' was not declared in this scope

   Firebase.setFloat("number", 42.0);

   ^

'Firebase' was not declared in this scope

So I use WiFiClientSecure to direct send data to <...>.firebaseio.com...

bestpika avatar Jun 13 '17 01:06 bestpika

@proppy My thing is the same Is there a way to fix it?

MacAddress:37: error: 'Firebase' was not declared in this scope

Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);

^ C:\Users\Sivakorn\Documents\Arduino\MacAddress\MacAddress.ino: In function 'void loop()':

MacAddress:45: error: 'Firebase' was not declared in this scope

Firebase.setFloat("number", 42.0);

^ <

sivakornb avatar Jul 24 '17 09:07 sivakornb

There is any update on this?

I've tried to install the branch proposed by @proppy with not luck. There is any way how I could help?

gepd avatar Sep 26 '17 19:09 gepd

did anyone get the right solution? my error is: 'Firebase' was not declared in this scope

davidvasicek avatar Oct 07 '17 18:10 davidvasicek

@proppy could you help us? Please.

davidvasicek avatar Oct 17 '17 09:10 davidvasicek

That should be easier to implement now that they added an HTTPClient w/ SLL in the ESP32 arduino core that is supposed to match the API for the ESP8266: https://github.com/espressif/arduino-esp32/commits/master/libraries/HTTPClient

proppy avatar Oct 17 '17 12:10 proppy

@proppy Could you commit this to your branch https://github.com/proppy/firebase-arduino/tree/esp32 We really need a Firebase access with ESP32 Arduino Thanls

blotfi avatar Oct 20 '17 08:10 blotfi

I had to add extern FirebaseArduino Firebase; at the end of FirebaseArduino.h and there is a problem of EmbeRec:92: error: no matching function for call to 'FirebaseArduino::setString(const char [14], String&)' but it can be solved

but for

C:\Users\xxxx\Documents\Arduino\hardware\espressif\esp32\libraries\firebase-arduino-esp32\src\FirebaseArduino.cpp:36:66: error: no matching function for call to 'HttpClient::HttpClient()'

FirebaseArduino::FirebaseArduino(Client& client) : client_(client) {}

In file included from C:\Users\xxxx\Documents\Arduino\hardware\espressif\esp32\libraries\firebase-arduino-esp32\src\third-party/ArduinoHttpClient/src/ArduinoHttpClient.h:8:0, ..... C:\Users\xxx\Documents\Arduino\hardware\espressif\esp32\libraries\firebase-arduino-esp32\src\third-party/ArduinoHttpClient/src/HttpClient.h:53:5: note: candidate: HttpClient::HttpClient(Client&, const IPAddress&, uint16_t)

HttpClient(Client& aClient, const IPAddress& aServerAddress, uint16_t aServerPort = kHttpPort);

I don't know how to deal with it

blotfi avatar Oct 20 '17 09:10 blotfi

@blotfi I think my branch was using a patched version of ArduinoHttpClient:

diff --git a/src/HttpClient.cpp b/src/HttpClient.cpp
index b46f628..4fb7694 100644
--- a/src/HttpClient.cpp
+++ b/src/HttpClient.cpp
@@ -28,6 +28,17 @@ HttpClient::HttpClient(Client& aClient, const IPAddress& aServerAddress, uint16_
   resetState();
 }
 
+void HttpClient::begin(Client& aClient, const char* aServerName, uint16_t aServerPort)
+{
+  iClient = &aClient;
+  iServerName = aServerName;
+  iServerAddress = IPAddress();
+  iServerPort = aServerPort;
+  iConnectionClose = true;
+  iSendDefaultRequestHeaders = true;
+  resetState();
+}
+
 void HttpClient::resetState()
 {
   iState = eIdle;
diff --git a/src/HttpClient.h b/src/HttpClient.h
index e627b21..6cf21b6 100644
--- a/src/HttpClient.h
+++ b/src/HttpClient.h
@@ -46,10 +46,12 @@ public:
 // FIXME Write longer API request, using port and user-agent, example
 // FIXME Update tempToPachube example to calculate Content-Length correctly
 
+    HttpClient() {};
     HttpClient(Client& aClient, const char* aServerName, uint16_t aServerPort = kHttpPort);
     HttpClient(Client& aClient, const String& aServerName, uint16_t aServerPort = kHttpPort);
     HttpClient(Client& aClient, const IPAddress& aServerAddress, uint16_t aServerPort = kHttpPort);
 
+    void begin(Client& aClient, const char* aServerName, uint16_t aServerPort = kHttpPort);
     /** Start a more complex request.
         Use this when you need to send additional headers in the request,
         but you will also need to call endRequest() when you are finished.

proppy avatar Oct 20 '17 09:10 proppy

@proppy where canI get it so ? or can you put all he stuf on ESP32 dev tree https://github.com/proppy/firebase-arduino/tree/esp32

blotfi avatar Oct 20 '17 09:10 blotfi

@blotfi you need to make the same modification that I linked, but even after than there is still an SSL error we need to solve.

So it's not working yet.

proppy avatar Oct 20 '17 09:10 proppy

@proppy Do you have time to solve the issues? I am in Electrical Engineering / Teacher, so not a really good programmer ;-) I can test of course to help you

blotfi avatar Oct 20 '17 09:10 blotfi

@proppy Hi, do you plan to start again the https://github.com/proppy/firebase-arduino/tree/esp32 Thanks

blotfi avatar Oct 25 '17 10:10 blotfi

@proppy Hi, is there any new dev for ESP32 ? thanks

blotfi avatar Nov 19 '17 16:11 blotfi

Same question, any future support for ESP32? Thanks for all development, I would also be willing to help!

blasco avatar Dec 10 '17 21:12 blasco

One good way to support the ESP32 would be to standardize on the ArduinoHttpClient or the arduino Client interface https://www.arduino.cc/en/Reference/ClientConstructor interface, instead using of using the HttpClient in the esp8266 core.

Tracking this here: #344.

proppy avatar Jun 15 '18 13:06 proppy

@proppy any news regarding ESP32 support?

Curclamas avatar Aug 31 '18 07:08 Curclamas

@Curclamas I'd welcome some more testing on https://github.com/FirebaseExtended/firebase-arduino/pull/353 if you want to give it a try.

proppy avatar Sep 03 '18 03:09 proppy

Ola a todos! Utilisei o seguinte procedimento para logar ao firebase (ESP32 + FIREBASE): Segue um exemplo de contador:


#include <WiFi.h> #include <WiFiClientSecure.h>

const char* ssid = "xxxxxxxx"; // Sua rede WIFI const char* password = "xxxxxxxx"; //Senha do wifi

const char* host = "xxxxxxxxxx.firebaseio.com"; //Login firebase const char* firebase_auth = "xxxxxxxxx"; //Password firebase

String user_path = "usuario";// Usuario cadastrado no firebase database int count = 0;

WiFiClientSecure client;

//********************** void setup() { Serial.begin(115200);

WiFi.begin( ssid, password );

Serial.print( "connecting" ); while ( WiFi.status() != WL_CONNECTED ) { Serial.print("."); delay(500); } Serial.println(); Serial.print( "connected: " ); Serial.println( WiFi.localIP() );

delay(2000); } //********************** void loop() { sendPatchRequest( "text", String( count ) ); count++; if( count > 10 ) count = 0; } //******Firebase Realtime Database ************** void sendPatchRequest( String str1, String str2 ){ if( !client.connect( host, 443 ) ){ Serial.println( "Connection failed!" ); }else{ Serial.println( "Connected to server!" ); String req_url_str; req_url_str = "PATCH /"; req_url_str += user_path; req_url_str += ".json?auth="; req_url_str += String( firebase_auth ); req_url_str += " HTTP/1.1\r\n";

String body = "{\"" + str1 + "\":\"" + str2 + "\"}";

String head;
head = "Host: ";
head += String( host ) + "\r\n";
head += "Connection: keep-alive\r\n";
head += "Content-Length: ";
head += String( body.length() ) + "\r\n";
head += "\r\n"; 

client.print( req_url_str );
client.print( head );
client.print( body );

Serial.println( "####### Solicitação de PATCH HTTP #######" );
Serial.print( req_url_str );
Serial.print( head );
Serial.println( body );

checkServerRespons();

delay(2);
client.stop(); 
delay(2);

} } //*********************************** void checkServerRespons(){ //É importante receber todas as respostas do servidor do Firebase Serial.println("####### Firebase Server HTTP Resposta #######"); while( client.connected() ){ String resp_str = client.readStringUntil('\n'); //Ler a string Serial.println( resp_str ); if( resp_str == "\r" ) { //Linha em branco Serial.println("------------- Cabeçalho da Resposta"); break; } } //Após o retorno do cabeçalho de resposta, a parte do corpo volta while( client.available() ){ char c = client.read(); Serial.print( c ); } Serial.println("\r\n----------- Corpo Recebido"); }


Fonte: https://www.mgo-tec.com No fire base fica assim:

*****FIREBASE Nome_Banco_de_dados usuario text:"0"

lucianoracing avatar Oct 18 '18 12:10 lucianoracing

Worked just fine! Thanks lucianoracing!

robertomap avatar Nov 14 '18 04:11 robertomap

can you please translate instructions into english?

a-ma-n avatar Oct 28 '22 19:10 a-ma-n