hello , débutant, je bloque sur un problème (désolé si c'est peut etre qu'une bétise )mais je ne trouve pas la solution (apres des heures de recherches )
mon matériel : Nodemcu et esp8266 wifi
voici mon code récupéré de ce site avec 2-3 modif au niveau du Wifi
mon but : arrivé à me connecter à firebase, quand j'y serai arrivé, faire ce 1er projet sonde température
ex: Send Real-Time Sensor Data to Google Firebase with ESP8266
merci pour votre aide
1er problème, quand il ne trouve pas le wifi, il ne tente pas un nouvelle connection
2eme problème, quand il se connecte au wifi, j'ai ce message d'erreur
"13:41:48.364 -> Connexion WiFi etablie
13:41:48.364 -> => Addresse IP :
13:41:48.364 -> (IP unset)
13:41:52.943 -> Firebase ok
13:41:54.161 -> FAILED
13:41:54.161 -> REASON: not found
13:41:55.427 -> FAILED
13:41:55.427 -> REASON: not found"
voici mon code (repris d'un site
#include <Arduino.h>
#if defined(ESP32)
#include <WiFi.h>
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#endif
#include <Firebase_ESP_Client.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"
// Insert your network credentials
#define WIFI_SSID "WiFi-xxx2C9"
#define WIFI_PASSWORD "AD5xxxD"
// Insert Firebase project API Key
#define API_KEY "AIzaSyBxxxxxxxxxxxqk_cU5gD0"
// Insert RTDB URLefine the RTDB URL */
#define DATABASE_URL "console.firebase.google.com/project/nodemcu-26629/database/nodemcu-26629-default-rtdb/data/~2F"
//Define Firebase Data object
FirebaseData fbdo;
FirebaseAuth auth;
FirebaseConfig config;
unsigned long sendDataPrevMillis = 0;
int count = 0;
bool signupOK = false;
void setup(){
Serial.begin(115200);
delay(2000);
Serial.print("Connexion a ");
Serial.println(WIFI_SSID);
delay(3000);
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
delay(4000); // mini 4000 !!
if (WiFi.status() != WL_CONNECTED){
Serial.println("Connexion WiFi etablie ");
Serial.println("=> Addresse IP : ");
Serial.println(WiFi.localIP());
delay(3000);
}
else
{
Serial.println(" Pas de Connexion WiFi - Reconnexion ");
delay(5000);
}
/* Assign the api key (required) */
config.api_key = API_KEY;
/* Assign the RTDB URL (required) */
config.database_url = DATABASE_URL;
/* Sign up */
if (Firebase.signUp(&config, &auth, "", "")){
Serial.println("Firebase ok");
signupOK = true;
}
else{
Serial.printf("%s\n", config.signer.signupError.message.c_str());
}
/* Assign the callback function for the long running token generation task */
config.token_status_callback = tokenStatusCallback; //see addons/TokenHelper.h
Firebase.begin(&config, &auth);
Firebase.reconnectWiFi(true);
}
void loop(){
if (Firebase.ready() && signupOK && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)){
sendDataPrevMillis = millis();
// Write an Int number on the database path test/int
if (Firebase.RTDB.setInt(&fbdo, "test/int", count)){
Serial.println("PASSED");
Serial.println("PATH: " + fbdo.dataPath());
Serial.println("TYPE: " + fbdo.dataType());
}
else {
Serial.println("FAILED");
Serial.println("REASON: " + fbdo.errorReason());
}
count++;
// Write an Float number on the database path test/float
if (Firebase.RTDB.setFloat(&fbdo, "test/float", 0.01 + random(0,100))){
Serial.println("PASSED");
Serial.println("PATH: " + fbdo.dataPath());
Serial.println("TYPE: " + fbdo.dataType());
}
else {
Serial.println("FAILED");
Serial.println("REASON: " + fbdo.errorReason());
}
}
}