I am making a project that involves AC current measurement from the Mains. I have done a bit of research and have found that the ACS712 can do this.

I would like to know the correct way of using this module so that it outputs analog data that my microcontroller can read(I would like to get the total WATTS) .

I read somewhere that capacitors are needed. Please tell me how, and why. Also tell me if the ground pin needs to be connected from the ground of the mains

The two screws go in series with the load (ie, imagine cutting one of supply wires, and putting one of the cut ends into each screw)

Ground pin does not need to be connected to line ground.

That board already has two caps on it though - it may already have whatever caps you need (don't know off the top of my head what you need other than bypass cap, which is present on the board)

The output at 0A is Vcc/2. So if you are using a 5V Arduino, 0A will give you a count of about 511 on an analogRead.

The output will be the same waveform as the AC current. So you can't just take one reading at random, or you will get some random value equal to or less than the peak current. It is helpful to have some indication of zero crossing. You can simply look for the zero crossings (ie, data is at 511 or so) every half cycle. Take regular measurements and then take the readings between two full cycles and take the root-mean-square.

You might want to just take the peak current and divide by the square root of two, but that only works for a sine wave. And the current is very likely -not- a sine wave.

Square each measurement, add them together. Divide the sum by the number of measurements. Then take the square root of that number.

It is important that it be an integer number of full cycles, and that it be a fair number of samples. Enough so you are capturing at least 3 or 4 samples at the highest frequency content.

I almost forgot - before you do any squaring and square rooting, you must convert the analogRead value into a floating point number and subtract 511 or whatever your zero point is. Or the math won't work.