help me with current sensor coding

hi, this the code I use. I use 3 current sensor for different load, I already try to connect it with the load and try to OFF and ON the load. but the current shows 10.20Amps, which is not making any sense and all the sensor display the same reading. but i only ON 1 load. supposedly, the other 2 sensor should display 0. I also try to turn it off, but current does not show the value 0 and i check the connection, there is no problem with connection, something off with the coding. hope someone can help me.

/* Part II - Testing CD4051 8-1 analog MUX. 170219 */
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

const char* ssid = "";
const char* password = "";
WiFiServer server(80);                     // Server class Fn Call: set web server port number to 80
unsigned int count=0;     // just for display wait
float Cal=0.01;
int readADC;
float AmpRMS1;
float AmpRMS2;
float AmpRMS3;
int Delta_Count;
int maxValue = 0;          // store max value here
int minValue = 1024;       // store min value here

void setup()
{
Serial.begin(115200);                      // Serial class Fn Call.. set speed
pinMode(16, OUTPUT);                       // CD4051 addr=A
pinMode(5, OUTPUT);                       //  CD4051 addr=B

pinMode(12, OUTPUT);                       // SSR-1
pinMode(13, OUTPUT);                       // SSR-2
pinMode(15, OUTPUT);                       // SSR-3

digitalWrite(12,HIGH);           // SSR-1   on
digitalWrite(13,HIGH);            // SSR-2   on
digitalWrite(15,HIGH);            // SSR-3   on



}    // ..End setup{}                web function call: getting IP from server
void loop()
{
 Serial.println("Writing to MUX addr");
 

//ambil mux 0
digitalWrite(16,LOW);            // MUX chan select
digitalWrite(5,LOW);
delay(100);

{
       readADC = analogRead(A0);
       if (readADC > maxValue)           // see if you have a new maxValue
       {   maxValue = readADC; }         /* record the maximum sensor value */
       
       if (readADC < minValue) 
       {  minValue = readADC;  }         /*record the maximum sensor value*/
    }
    Delta_Count=maxValue-minValue;       // Subtract min from max
    AmpRMS1 = Cal * Delta_Count;
  Serial.print(AmpRMS1);
  Serial.print("  Irms1 ");
     

//ambil mux 1
digitalWrite(16,HIGH);            // MUX chan select
digitalWrite(5,LOW);
delay(100);
{
       readADC = analogRead(A0);
       if (readADC > maxValue)           // see if you have a new maxValue
       {   maxValue = readADC; }         /* record the maximum sensor value */
       
       if (readADC < minValue) 
       {  minValue = readADC;  }         /*record the maximum sensor value*/
    }
    Delta_Count=maxValue-minValue;       // Subtract min from max
    AmpRMS2 = Cal * Delta_Count;
  Serial.print(AmpRMS2);
  Serial.print("  Irms2 ");

//ambil mux 2
digitalWrite(16,LOW);            // MUX chan select
digitalWrite(5,HIGH);
delay(100);
{
       readADC = analogRead(A0);
       if (readADC > maxValue)           // see if you have a new maxValue
       {   maxValue = readADC; }         /* record the maximum sensor value */
       
       if (readADC < minValue) 
       {  minValue = readADC;  }         /*record the maximum sensor value*/
    }
    Delta_Count=maxValue-minValue;       // Subtract min from max
    AmpRMS3 = Cal * Delta_Count;
  Serial.print(AmpRMS3);
  Serial.print("  Irms3 ");

}

Don’t you think telling us what sensors you are using and showing a diagram of how you have it all wired up, including your Arduino, would be of interest to someone trying to help?

Paul

sorry, i forgot to mention. i use nodemcu esp8266 which i connect to multiplexer. and I use ACS712 current sensor.

The ACS712 is a 5volt only current sensor, and needs a ratiometric 5volt A/D. The ESP8266 doesn't have a ratiometric A/D, and works with 3.3volt logic. Curious how you have connected these incompatible devices. Leo..