[SOLVED] ACS712 - Having second load is reducing the watt instead of adding it

Load: Two Fan (Fan A = 20W & Fan B = 25W)
Sensor: 5A ACS712 Chip
Microcontroller: Atmega328P

Trying to measure my wattusage device with 2 load (both fan) but here's the problem.

Measuring just one load (any of those fan) nothing bad happen. Current and wattusage is all fine. But when i added a second fan, the other fan reduced the watt usage (under 5W) instead of adding it to 40W. It's like First Fan - Second Fan instead of First Fan + Second Fan

Pict of single load
image

Pict of having two loads
image

My full codes:

#include <lorawan.h>
#include <ACS712.h>

const char *devAddr = "xxxxxxx"; //Device Address SLALORA_11
const char *nwkSKey = "xxxxxxxxxxxxxxxx0000000000000000";
const char *appSKey = "0000000000000000xxxxxxxxxxxxxxxx";

const unsigned long interval = 30000;   //Message Uplink Interval
const int analogIn = A0;                 //ACS712 Pinout
const int relay = 3;                     //Relay Pinout
const int led = 13;                      //LED Pinout
unsigned long previousMillis = 0;
unsigned long led_millis = 0;

char myStr[50];
byte outStr[255];
byte recvStatus = 0;
int port, channel, freq;
bool newmessage = false;
bool LedState = false;
String RelayStatus;

//RFM Pinout
const sRFM_pins RFM_pins = {
  .CS = 10,
  .RST = 4,
  .DIO0 = 7,
  .DIO1 = 8,
};

//ACS712 Setup
ACS712 ACS(A0, 5.0, 1024, 185); //ACS712(uint8_t analogPin, float volts = 5.0, uint16_t maxADC = 1023, uint8_t mVperA = 66/100/185);

void setup() {
  //Setup Device
  Serial.begin(115200);
  Serial.println("Starting...");
  pinMode(analogIn, INPUT);
  pinMode(relay, OUTPUT);
  pinMode(led, OUTPUT);
  delay(5000);

  //Setup ACS712
  Serial.println("Setting Up ACS712 Current Sensor...");
  delay(2000);
  ACS.setMidPoint(512); //Max ADC/2
  Serial.print("MidPoint = ");
  Serial.println(ACS.getMidPoint());

  ACS.setNoisemV(70);
  Serial.print("Noise mV = ");
  Serial.println(ACS.getNoisemV()); //Noise = 21mV based on Datasheet
  delay(1000);

  //Setup RFM95W
  Serial.println("Setting Up LoRa RFM95W...");
  delay(2000);
  if (!lora.init()) {
    Serial.println("RFM95 Not Detected");
    return; //Device Stopped
  }
  else  {
    Serial.println("LoRa Initialization Success.");
  }
  
  lora.setDeviceClass(CLASS_A);   //Set LoRaWAN Class change CLASS_A or CLASS_C
  lora.setDataRate(SF10BW125);    //Set Data Rate
  lora.setFramePortTx(5);         // Set FramePort Tx
  lora.setChannel(MULTI);         // Set Channel
  lora.setTxPower(15);            // Set TxPower to 15 dBi (max)
  
  // Put ABP Key and DevAddress here
  lora.setNwkSKey(nwkSKey);
  lora.setAppSKey(appSKey);
  lora.setDevAddr(devAddr);
}

void loop() {
  int mA = ACS.mA_AC(); //ACS712 Current
  float Watt = ((220*mA)/1000.0*-1);
  char daya[6];

  //Uplink to Antares
  if (millis() - previousMillis > interval) {
    previousMillis = millis();

    dtostrf(Watt, 6, 2, daya);
    sprintf(myStr, "ACS Current(mA)= %d. Watt Usage(W)= %s", mA, daya);
    Serial.println("Sending to Antares... ");
    Serial.println(myStr);
    lora.sendUplink(myStr, strlen(myStr), mA);
    
    port = lora.getFramePortTx();
    channel = lora.getChannel();
    freq = lora.getChannelFreq(channel);
    Serial.print(F("Port: "));  Serial.print(port);     Serial.print(" ");
    Serial.print(F("Ch: "));    Serial.print(channel);  Serial.print(" ");
    Serial.print(F("Freq: "));  Serial.print(freq);     Serial.println(" ");
  }
  // Check Lora RX
  lora.update();
}

Needed help to fix on how is this happening. Thank you in advance!

Show your schematic for one and two fans

Hello panduh31
Keep it simple and stupid.
Run a tutorial to the hardware selected.
If you are happy with the results of the tutorials you can merge these to the project by using control structures.
Have a nice day and enjoy coding in C++.

Sorry, i changed to topic to Here
Since it's more likely about programming.

no, its more likely about circuit

I was measuring a watt usage device using a single load (22W Fan) and it works just fine, below is the measurements result:
image

Then i measured my second fan (20W Fan) and here's the result:
image

And here's when i used both fan as the loads.
image

Wierdly, the image show the watt is not working normally. I used Wattmeter device for comparison and it shows 40Watt but the ACS seems not working normally. Tried with other load too and there goes the same problem again.

Here's the code i used for calculating the Ampere and the Watts

  int mA = ACS.mA_AC(); //ACS712 Current
  float Watt = ((220*mA)/1000.0);
  if(Watt < 0){
    Watt = Watt*-1;
  }
  dtostrf(Watt, 4, 2, daya);
  sprintf(myStr, "ACS Current(mA)= %d. Watt Usage(W)= %s", mA, daya);

You already asked about this here just a few hours ago.

Please do not duplicate posts.
By doing this, you make it difficult for those who would like to help

I already answered you in the last topic - give a schematic of your connections

Yes. I've forwared the topic here just now. Since it's more likely about my programming codes.

Yes, this is the connections im using on the ACS712

I do not see the fans in the circuit

Your two topics on the same or similar subject have been merged.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

your calculation overflows the int.
try
float Watt = ((220L*mA)/1000.0);

1 Like

Thanks for the information and reminder. Will keep that in mind.

Yes, because im using a table fans not a DC Fans. The Table Fans connected to an electrical terminal which is controlle by my device.

It works! Thanks for the help!
image
Used 4 Loads that is Phone 10W and Laptop charger 45W, 22W fan, and 500W electrical teapot. The rest is fluctuation around 10-15W.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.