Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for ESP32 #220

Open
proppy opened this issue Nov 1, 2016 · 27 comments
Open

add support for ESP32 #220

proppy opened this issue Nov 1, 2016 · 27 comments
Milestone

Comments

@proppy
Copy link
Collaborator

proppy commented Nov 1, 2016

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

@Ahmed-Talaat
Copy link

are there any updates on that?

@proppy
Copy link
Collaborator Author

proppy commented Apr 21, 2017

@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.

@danielcrowley
Copy link

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

@proppy
Copy link
Collaborator Author

proppy commented May 2, 2017

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

@bestpika
Copy link

bestpika commented Jun 7, 2017

I got an error.

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

@proppy
Copy link
Collaborator Author

proppy commented Jun 7, 2017

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

@bestpika
Copy link

bestpika commented Jun 13, 2017

@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...

@sivakornb
Copy link

sivakornb commented Jul 24, 2017

@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);

^
<

@gepd
Copy link

gepd commented Sep 26, 2017

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?

@davidvasicek
Copy link

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

@davidvasicek
Copy link

@proppy
could you help us? Please.

@proppy
Copy link
Collaborator Author

proppy commented Oct 17, 2017

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

@blotfi
Copy link

blotfi commented Oct 20, 2017

@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

@proppy proppy mentioned this issue Oct 20, 2017
@blotfi
Copy link

blotfi commented Oct 20, 2017

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

@proppy
Copy link
Collaborator Author

proppy commented Oct 20, 2017

@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.

@blotfi
Copy link

blotfi commented Oct 20, 2017

@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

@proppy
Copy link
Collaborator Author

proppy commented Oct 20, 2017

@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.

@blotfi
Copy link

blotfi commented Oct 20, 2017

@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
Copy link

blotfi commented Oct 25, 2017

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

@blotfi
Copy link

blotfi commented Nov 19, 2017

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

@blasco
Copy link

blasco commented Dec 10, 2017

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

@proppy
Copy link
Collaborator Author

proppy commented Jun 15, 2018

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.

@Curclamas
Copy link

@proppy any news regarding ESP32 support?

@proppy
Copy link
Collaborator Author

proppy commented Sep 3, 2018

@Curclamas I'd welcome some more testing on #353 if you want to give it a try.

@lucianoracing
Copy link

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"

@robertomap
Copy link

Worked just fine! Thanks lucianoracing!

@a-ma-n
Copy link

a-ma-n commented Oct 28, 2022

can you please translate instructions into english?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests