Combining 2 code ESP32 -need help

#include <WiFi.h>
#include <Firebase_ESP_Client.h>
#include "addons/TokenHelper.h"
#include "addons/RTDBHelper.h"
#include <ACS712.h>

#define WIFI_SSID ""
#define WIFI_PASSWORD ""

#define DATABASE_URL ""
#define API_KEY ""
FirebaseData fbdo;
FirebaseAuth auth;
FirebaseConfig config;

#define RELAY_A_PIN 2
#define RELAY_B_PIN 0
#define RELAY_C_PIN 32
#define RELAY_D_PIN 33

unsigned long sendDataPrevMillis = 0;
bool signupOK = false;
String prevValue = "";

// Relay states
int relayStateA = LOW;
int relayStateB = LOW;
int relayStateC = LOW;
int relayStateD = LOW;

// ACS712 variables
ACS712 sensor(ACS712_30A, 4);

void setup() {
Serial.begin(115200);
sensor.calibrate();
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to Wi-Fi");

while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(300);
}

Serial.println();
Serial.print("Connected with IP: ");
Serial.println(WiFi.localIP());
Serial.println();

/* 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("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);

pinMode(RELAY_A_PIN, OUTPUT);
pinMode(RELAY_B_PIN, OUTPUT);
pinMode(RELAY_C_PIN, OUTPUT);
pinMode(RELAY_D_PIN, OUTPUT);

}

void loop() {
if (Firebase.ready() && signupOK && (millis() - sendDataPrevMillis > 15000 || sendDataPrevMillis == 0)) {
sendDataPrevMillis = millis();
if (Firebase.RTDB.getString(&fbdo, "relay")) {
if (fbdo.dataType() == "string") {
String stringValue = fbdo.stringData();
Serial.print("Received value from Firebase: ");
Serial.println(stringValue);
if (stringValue != prevValue) { // Check if value changed
prevValue = stringValue; // Update previous value
updateRelays(stringValue);
}
} else {
Serial.println("Invalid data type received from Firebase");
}
} else {
Serial.println("Error reading from Firebase");
Serial.println(fbdo.errorReason());
}
}

float I = sensor.getCurrentAC();

// Update Firebase with watts value

Serial.println(I);
delay(1000); // Delay added for stability
}

void updateRelays(String value) {
if (value == "1") {
relayStateA = HIGH;
relayStateB = LOW;
relayStateC = LOW;
relayStateD = LOW;

} else if (value == "2") {
relayStateA = LOW;
relayStateB = HIGH;
relayStateC = LOW;
relayStateD = LOW;

} else if (value == "3") {
relayStateA = LOW;
relayStateB = LOW;
relayStateC = HIGH;
relayStateD = LOW;

} else if (value == "4") {
relayStateA = LOW;
relayStateB = LOW;
relayStateC = LOW;
relayStateD = HIGH;

} else if (value == "5") { // Adding condition for new relay state
relayStateA = LOW;
relayStateB = LOW;
relayStateC = LOW;
relayStateD = LOW;

} else {
// Invalid value, turn off all relays
relayStateA = LOW;
relayStateB = LOW;
relayStateC = LOW;
relayStateD = LOW;

Serial.println("Invalid value, turning off all relays");

}

// Update relay states
digitalWrite(RELAY_A_PIN, relayStateA);
digitalWrite(RELAY_B_PIN, relayStateB);
digitalWrite(RELAY_C_PIN, relayStateC); // Control the new relay pin
digitalWrite(RELAY_D_PIN, relayStateD);
}

-the code works if separated but when combined the acs712 out is
200.09

200.09

200.09

200.09

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.