Closed PanduHalimie31 closed 2 years ago
Warning: never post an image of code as those are pretty hard to run on a computer (I cannot test it).
your code is wrong. Debug it.
Oops wrong button.
if mA == 218 how can Watt become 17.58 ? Follow the math you do with paper and pencil
Then try this variation
int mA = ACS.mA_AC();
float Watt = mA * (220 / 1000.0);
Yes, there's some miscalculations on the codes.
But i fixed it already with the help of Arduino Forum by using
float Watt = ((220L*mA)/1000.0);
instead.
Thanks for answer and time sir!
What output do you get now?
The solution of the forum is not 100% optimal.
float Watt = mA * (220 / 1000.0);
The compiler will optimize the division compile time so in it will in essence be
float Watt = mA * 0.22;
As multiplications are faster than divisions on most micros, this solution will be slightly faster too.
The forum code will not be optimized and will have both a multiplication and division. (for most projects the difference is not relevant, but for real time it may just make the difference)
Better use the forum for all code problems, there are far more people there to help out. Only when there are problems in the library code itself you should open an issue under a library.
Hello, it's me again but with another problem.
I was measuring the device with a single load (22W Fan) and it works just fine, below is the measurements result:
Then i measured my second fan (20W Fan) and here's the result:
And here's when i used both fan as the loads.
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