-
Hi im using the enc28j60 module to connect to firebase on esp32 instead of wifi, im using the , examples/ExternalClient/Ethernet examples to try and use ethernet to conenct to firebase but i keep getting the -4 error, i dont under stand what im doing wrong CODE: #include <FirebaseESP32.h>
// Provide the token generation process info.
#include <addons/TokenHelper.h>
// Provide the RTDB payload printing info and other helper functions.
#include <addons/RTDBHelper.h>
#include <EthernetENC.h>
// For the following credentials, see examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino
/* 1. Define the API Key */
#define API_KEY "*********************"
#define DATABASE_URL "********************"
#define USER_EMAIL "u************"
#define USER_PASSWORD "********"
/* 4. Defined the Ethernet module connection */
#define WIZNET_RESET_PIN 26 // Connect W5500 Reset pin to GPIO 26 of ESP32
#define WIZNET_CS_PIN 5 // Connect W5500 CS pin to GPIO 5 of ESP32
#define WIZNET_MISO_PIN 19 // Connect W5500 MISO pin to GPIO 19 of ESP32
#define WIZNET_MOSI_PIN 23 // Connect W5500 MOSI pin to GPIO 23 of ESP32
#define WIZNET_SCLK_PIN 18 // Connect W5500 SCLK pin to GPIO 18 of ESP32
/* 5. Define MAC */
uint8_t Eth_MAC[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
/* 6. Define the static IP (Optional)
IPAddress localIP(192, 168, 1, 104);
IPAddress subnet(255, 255, 0, 0);
IPAddress gateway(192, 168, 1, 1);
IPAddress dnsServer(8, 8, 8, 8);
bool optional = false; // Use this static IP only no DHCP
Firebase_StaticIP staIP(localIP, subnet, gateway, dnsServer, optional);
*/
// Define Firebase Data object
FirebaseData stream;
FirebaseData fbdo;
FirebaseAuth auth;
FirebaseConfig config;
unsigned long sendDataPrevMillis = 0;
int count = 0;
volatile bool dataChanged = false;
EthernetClient eth1;
EthernetClient eth2;
void streamCallback(StreamData data)
{
Serial_Printf("sream path, %s\nevent path, %s\ndata type, %s\nevent type, %s\n\n",
data.streamPath().c_str(),
data.dataPath().c_str(),
data.dataType().c_str(),
data.eventType().c_str());
printResult(data); // see addons/RTDBHelper.h
Serial.println();
Serial_Printf("Received stream payload size: %d (Max. %d)\n\n", data.payloadLength(), data.maxPayloadLength());
dataChanged = true;
}
void streamTimeoutCallback(bool timeout)
{
if (timeout)
Serial.println("stream timed out, resuming...\n");
if (!stream.httpConnected())
Serial_Printf("error code: %d, reason: %s\n\n", stream.httpCode(), stream.errorReason().c_str());
}
void setup()
{
Serial.begin(115200);
Serial_Printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION);
/* Assign the api key (required) */
config.api_key = API_KEY;
/* Assign the user sign in credentials */
auth.user.email = USER_EMAIL;
auth.user.password = USER_PASSWORD;
/* Assign the RTDB URL (required) */
config.database_url = DATABASE_URL;
/* Assign the callback function for the long running token generation task */
config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h
/* Assign the pointer to global defined external SSL Client object */
fbdo.setEthernetClient(ð1, Eth_MAC, WIZNET_CS_PIN, WIZNET_RESET_PIN); // The staIP can be assigned to the fifth param
stream.setEthernetClient(ð2, Eth_MAC, WIZNET_CS_PIN, WIZNET_RESET_PIN); // The staIP can be assigned to the fifth param
// Comment or pass false value when WiFi reconnection will control by your code or third party library
//Firebase.reconnectNetwork(true);
// Since v4.4.x, BearSSL engine was used, the SSL buffer need to be set.
// Large data transmission may require larger RX buffer, otherwise the data read time out can be occurred.
fbdo.setBSSLBufferSize(2048 /* Rx buffer size in bytes from 512 - 16384 */, 1024 /* Tx buffer size in bytes from 512 - 16384 */);
stream.setBSSLBufferSize(2048 /* Rx buffer size in bytes from 512 - 16384 */, 1024 /* Tx buffer size in bytes from 512 - 16384 */);
Firebase.setDoubleDigits(5);
Firebase.begin(&config, &auth);
if (!Firebase.beginStream(stream, "/test/stream/data"))
Serial_Printf("sream begin error, %s\n\n", stream.errorReason().c_str());
Firebase.setStreamCallback(stream, streamCallback, streamTimeoutCallback);
}
void loop()
{
}
and the output on the monitor is : im stuck can some one please help me |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 32 replies
-
Why you post the Serial monitor that is not related to the code? Please check what's wrong. Are you already compile and upload it. |
Beta Was this translation helpful? Give feedback.
-
There is no Ethernet initialization in serial monitor, what you are doing? |
Beta Was this translation helpful? Give feedback.
There is no Ethernet initialization in serial monitor, what you are doing?