the current sensor AC712

hi ,
can you give me the code for the program AC712 current sensor?
I create this program but it still shows always in monitor serial =1023

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);


  

  Serial.println(sensorValue);
  delay (1000);
}

can you give me the code for the program AC712 current sensor?

Can YOU provide a LINK to this sensor? Can YOU provide a schematic showing how YOU wired it?

saobpc2:
hi ,
can you give me the code for the program AC712 current sensor?
I create this program but it still shows always in monitor serial =1023

void setup() {

// initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);

Serial.println(sensorValue);
  delay (1000);
}

saobpc2:
hi ,
can you give me the code for the program AC712 current sensor?
I create this program but it still shows always in monitor serial =1023

void setup() {

// initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);

Serial.println(sensorValue);
  delay (1000);
}

Did What is the current rating of the sensor, this should be on the data sheet

saobpc2:
hi ,
can you give me the code for the program AC712 current sensor?
I create this program but it still shows always in monitor serial =1023

void setup() {

// initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);

Serial.println(sensorValue);
  delay (1000);
}

Did you define the pin as analog.??

I have some test code to read a similar sensor but it does not use 'analogRead()',
it uses :#define AMPS 1
:(read_adc(AMPS)

You also have to scale the output to get the actual current, the info should be on the sensor sheet, depends on the current rating of the sensor.

PaulS:
Can YOU provide a LINK to this sensor? Can YOU provide a schematic showing how YOU wired it?

I just bought some of these, but all assembled on a pc board.

They come in different current ratings so you need to scale accordingly.

Data sheet:
http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CCIQFjAA&url=http%3A%2F%2Fwww.allegromicro.com%2F~%2Fmedia%2FFiles%2FDatasheets%2FACS712-Datasheet.ashx&ei=T_FjVYuBK-q1sASF44HYBQ&usg=AFQjCNEsuWeWEOng-Vn4AXDUAjxAgXNkjg&bvm=bv.93990622,d.cWc

Unit I bought:

hth. mike.

If you have wired it correctly, the device should output an analog signal which has half of the supply voltage ( probably 2.5V ) when there is no current in the load circuit.

If there is actual flowing current in the load circuit, the output voltage will be greater than 2.5 V if it is flowing in one direction, and less than 2.5 V if it is flowing in the other direction.

If you are getting 1023 all the time from the analog input, which means your analog input A0 has 5V on it, this means either you have a large current flowing all the time, or you wired up the sensor wrongly.

Did you define the pin as analog.??

Since when are you supposed to "define the pin as analog" ?

michinyon:
Since when are you supposed to "define the pin as analog" ?

.?? I am new to this, was not sure if the pin could be defined as analog or digital.

I just happen to have bought some of these for a solar charger project.

I am experimenting with these, and a i2c 4*20 display, a bmp180, and some other stuff with a nano.

[C:\Users\user\Desktop\capteur courant_2.png](http://C:\Users\user\Desktop\capteur courant_2.png)

saobpc2:
[C:\Users\user\Desktop\capteur courant_2.png](http://C:\Users\user\Desktop\capteur courant_2.png)

A link to a drawing on the desktop of your computer, is not useful.

You probably have not connected the device correctly.

Is the device you have, the same as binzer's device ?

https://www.google.tn/search?q=circuit+arduino+et+ac712&espv=2&biw=1024&bih=633&source=lnms&tbm=isch&sa=X&ei=DQhkVcfqA4riUenKgOgI&ved=0CAYQ_AUoAQ&dpr=1#imgrc=MOmQjSQXIxGmYM%253A%3BIDB7hATyLH1yOM%3Bhttp%253A%252F%252Fwww.elecrow.com%252Fimages%252FProducts%252Farduino_ACS712.jpg%3Bhttp%253A%252F%252Fwww.elecrow.com%252Facs712-current-sensor-20a-p-708.html%3B490%3B401

https://www.google.tn/search?q=circuit+arduino+et+ac712&espv=2&biw=1024&bih=633&source=lnms&tbm=isch&sa=X&ei=DQhkVcfqA4riUenKgOgI&ved=0CAYQ_AUoAQ&dpr=1#imgrc=MOmQjSQXIxGmYM%253A%3BIDB7hATyLH1yOM%3Bhttp%253A%252F%252Fwww.elecrow.com%252Fimages%252FProducts%252Farduino_ACS712.jpg%3Bhttp%253A%252F%252Fwww.elecrow.com%252Facs712-current-sensor-20a-p-708.html%3B490%3B401

If you have one of the "modules" for the device, you connect your load circuit to the two large terminals.

The three small terminals, you connect to the arduino.

One is a ground wire, you connect the GND of the device to GND of the arduino.
One is a power supply, usually labelled VCC, connect it to a 5V output on your arduino.
The third is the analog signal wire from the device, connect to your arduino A0 analog input.

The first thing you should do, is connect the three wires to the arduino without any load circuit connection.

The device should give you about 2.5V on the analog signal wire and the code you originally posted should work, and should return an integer value around 511.

If you only have the AC712 chip, mounting it is a bit more complicated, you need to allow for the high current path on your PCB, read the datasheet for the chip carefully.

Hi,

If you use REPLY rather than QUICK REPLY, you will find an ATTACHMENT facility to put your files.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Can you post a picture of you project so we can check your wiring?
Tom.... :slight_smile:

The circuit and code are correct on paper - you need to check with a multimeter
that the sensor is getting its 5V supply and that the pin-out is correct. You can
check the output voltage with the multimeter too. Should be about 2.5V with
no current flowing and 5V supply.

Reading only zeroes strongly suggests you have shorted A0 to ground by mistake.

That is similar to what I have.
I did not have one setup but just added it to my breadboard.
I connected as per the silk screen on board, 5v,gnd,and signal lead to A0 on my nano.
I got what I expected, a reading of center scale as I have no current draw (raw data of 511).
To convert the raw data to actual current you need the scale factor provided on the data sheet, it is different for each unit depending on the current spec.

Read adc channel to get raw data, multiply raw data by scale factor to get actual current in amps.