Unable to connect to Firebase after setting the Wi-Fi credentials OTA. #238
Unanswered
DipanshuSharma1108
asked this question in
Q&A
Replies: 3 comments 2 replies
-
It's not related to library. You should test with HTTPS and ping examples to make sure your device can access to the internet. |
Beta Was this translation helpful? Give feedback.
0 replies
-
When I am running my Arduino code with hardcoded Wi-Fi credentials then I
am able to connect to the Firebase and the data is being sent easily but
after setting the Wi-Fi credentials over the air, I am unable to do so.
…On Sun, Jul 25, 2021, 5:21 PM mobizt ***@***.***> wrote:
It's not related to library.
You should test with HTTPS and ping examples to make sure your device can
access to the internet.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#238 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AP7K3XZCVQW23WU7BUVHCDDTZP3DLANCNFSM5A6O2KPA>
.
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Yeah you are right...I changed the library and used WiFi manager instead.
Now the code is working fine. Thank you.
…On Sun, Jul 25, 2021, 5:55 PM mobizt ***@***.***> wrote:
Library does nothing with WiFi connection. Your device doesn't connect to
internet because your code.
You should test your internet connectivity before using the library.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#238 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AP7K3X2ESPYBFCNPM4V5F2TTZP7FBANCNFSM5A6O2KPA>
.
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have been trying to set my Wi-Fi credentials over the air and I am able to do this but in the process I am unable to connect the NodeMCU to my Firebase Database. I am able to get the reading of my sensors in the void loop function but those readings don't reflect in my Firebase RTDb. Kindly help. Here is my Arduino code.
`#if defined(ESP32)
#include <WiFi.h>
#include <FirebaseESP32.h>
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#include <FirebaseESP8266.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WebServer.h>
#include <EEPROM.h>
#endif
//variable declarations
const int analogInPin =A0;
int moistureValue = 0;
int i = 0;
int statusCode;
const char* ssid = "text";
const char* passphrase = "text";
String st;
String content;
FirebaseData fbdo;
int counterHigh =0;
int counterLow =0;
void sendLowMessage();
void sendHighMessage();
FirebaseAuth auth;
FirebaseConfig config;
unsigned long sendDataPrevMillis = 0;
//
//Function Decalration
bool testWifi(void);
void launchWeb(void);
void setupAP(void);
//Establishing Local server at port 80 whenever required
ESP8266WebServer server(80);
//Provide the token generation process info.
#include "addons/TokenHelper.h"
//Provide the RTDB payload printing info and other helper functions.
#include "addons/RTDBHelper.h"
#define API_KEY "API_KEY"
#define DATABASE_URL ""
#define FIREBASE_FCM_SERVER_KEY " "
#define FIREBASE_FCM_DEVICE_TOKEN_1 ""
//#define FIREBASE_FCM_DEVICE_TOKEN_2 "ANOTHER_RECIPIENT_DEVICE_TOKEN"
#define USER_EMAIL "USER_EMAIL"
#define USER_PASSWORD "USER_PASSWORD"
void setup()
{
Serial.println("Reading EEPROM ssid");
String esid;
for (int i = 0; i < 32; ++i)
{
esid += char(EEPROM.read(i));
}
Serial.println();
Serial.print("SSID: ");
Serial.println(esid);
Serial.println("Reading EEPROM pass");
String epass = "";
for (int i = 32; i < 96; ++i)
{
epass += char(EEPROM.read(i));
}
Serial.print("PASS: ");
Serial.println(epass);
WiFi.begin(esid.c_str(), epass.c_str());
if (testWifi())
{
Serial.println("Succesfully Connected!!!");
return;
}
else
{
Serial.println("Turning the HotSpot On");
launchWeb();
setupAP();// Setup HotSpot
}
Serial.println();
Serial.println("Waiting.");
while ((WiFi.status() != WL_CONNECTED))
{
Serial.print(".");
delay(100);
server.handleClient();
}
//Connect to Firebase
// fbdo.fcm.addDeviceToken(FIREBASE_FCM_DEVICE_TOKEN_2);
}
void loop()
{
if ((WiFi.status() == WL_CONNECTED))
}
else{
Serial.print("Wi-Fi not connected");
}
}
void sendHighMessage()
{
fbdo.fcm.setCollapseKey("MyKey");
fbdo.fcm.addCustomNotifyMessage("tag","MoistureNotification");
}
void sendLowMessage()
{
}
bool testWifi(void)
{
int c = 0;
Serial.println("Waiting for Wifi to connect");
while ( c < 20 ) {
if (WiFi.status() == WL_CONNECTED)
{
return true;
}
delay(500);
Serial.print("*");
c++;
}
Serial.println("");
Serial.println("Connect timed out, opening AP");
return false;
}
void launchWeb()
{
Serial.println("");
if (WiFi.status() == WL_CONNECTED)
Serial.println("WiFi connected");
Serial.print("Local IP: ");
Serial.println(WiFi.localIP());
Serial.print("SoftAP IP: ");
Serial.println(WiFi.softAPIP());
createWebServer();
// Start the server
server.begin();
Serial.println("Server started");
}
void setupAP(void)
{
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
int n = WiFi.scanNetworks();
Serial.println("scan done");
if (n == 0)
Serial.println("no networks found");
else
{
Serial.print(n);
Serial.println(" networks found");
for (int i = 0; i < n; ++i)
{
// Print SSID and RSSI for each network found
Serial.print(i + 1);
Serial.print(": ");
Serial.print(WiFi.SSID(i));
Serial.print(" (");
Serial.print(WiFi.RSSI(i));
Serial.print(")");
Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*");
delay(10);
}
}
Serial.println("");
st = "
";- ";
";for (int i = 0; i < n; ++i)
{
// Print SSID and RSSI for each network found
st += "
st += WiFi.SSID(i);
st += " (";
st += WiFi.RSSI(i);
}
st += "
delay(100);
WiFi.softAP("Sichaai", "123456789");
Serial.println("softap");
launchWeb();
Serial.println("over");
}
void createWebServer()
{
{
server.on("/", {
}
}`
Beta Was this translation helpful? Give feedback.
All reactions