You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 17, 2025. It is now read-only.
Im sending data from an Arduino Mega to NodeMCU through Serial port which arrives in the correct way. The problem comes when i try to send that info that im receiving to Firebase, which in some cases the serial read gets stucked and read the same byte again. The conection to with Firebase is working fine.
This passes randomly every 10 - 15 seconds (not exact the same time per iteration). Here's the code:
#include <FirebaseArduino.h>
#include <ESP8266WiFi.h>
#include <SoftwareSerial.h>
// Datos del modulo
String ID = "X";
// Datos de la conexion
char ssid[] = "X"; // Nombre (SSID)
char pass[] = "X"; // Contraseña
// Datos Firebase
#define firebaseURL "X" // BASE DE DATOS FIREBASE
#define authCode "X" // SECRETO FIREBASE
// Variables Firebase
int testInt = 0;
bool sendFire = false;
// Variables globales
SoftwareSerial MegaSerial (4, 5);
String RxBuffer; // Resultado del comando enviado al sensor “=result [name1=arg1]... \r\n”
void setup() {
Serial.begin(9600);
MegaSerial.begin(9600);
delay(100);
// Desconectamos cualquier conexion anterior
WiFi.disconnect();
// Inicializamos el WiFi
WiFi.begin(ssid, pass);
// Esperamos a que el NodeMCU se conecte correctamente a la red
Serial.print("\nConectando a red wifi");
while (WiFi.status() != WL_CONNECTED) {
delay(250);
Serial.print(".");
}
Serial.println("\nConexión establecida");
// Una vez conectados iniciamos Firebase
Firebase.begin(firebaseURL, authCode);
delay(50);
sendDataFirebase();
delay(1000);
}
void loop() {
// Actualizamos las variables desde Firebase
while (MegaSerial.available() > 0) {
testInt = MegaSerial.read();
sendFire = true;
}
if (MegaSerial.available() <= 0) {
if (sendFire) {
sendDataFirebase();
Serial.println(testInt);
sendFire = false;
}
}
void sendDataFirebase() {
Firebase.setInt(ID + "/testInt", testInt);
}
}
I have checked that if i delete sendDataFirebase in the if statement the serial read works fine.
Can anybody help me?
The text was updated successfully, but these errors were encountered:
Hi guys, my first issue here, here's my context.
Im sending data from an Arduino Mega to NodeMCU through Serial port which arrives in the correct way. The problem comes when i try to send that info that im receiving to Firebase, which in some cases the serial read gets stucked and read the same byte again. The conection to with Firebase is working fine.
This passes randomly every 10 - 15 seconds (not exact the same time per iteration). Here's the code:
I have checked that if i delete sendDataFirebase in the if statement the serial read works fine.
Can anybody help me?
The text was updated successfully, but these errors were encountered: