WCS1700 Noise problem

Hi. I have this hall sensor module . How can I reduce noise in this sensor?
when there is no current sometimes the sensor give -0.015 or 0.015.

#define wcs1700 A0

float vpp = 0.0048828125;
float sensitivity = 0.032;

void setup() {
  pinMode(wcs1700, INPUT);
  Serial.begin(9600);
  Serial.println("CLEARDATA");
  Serial.println("LABEL,Computer Time,Amps");
}

void loop() {
  int counts = analogRead(wcs1700) - 7;
  float voltage = counts * vpp;
  voltage -= 2.5;
  float amps = voltage / sensitivity;

  Serial.print("DATA,TIME,");
  Serial.println(amps);
  delay(1000);
}
 :o  :o

Hi,
Welcome to the forum.

Can you post a link to data/spec of the WCS1700 please?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.... :slight_smile:

And, perhaps, read: How to use this Forum

If you measure a 140Amp sensor (+70, -70) with a 10-bit A/D (1024 values),
then don't expect a resolution of two decimal places.
Two decimal places would require at least 14000 counts.

This seems to be a ratiometric sensor, in which case the datasheet is wrong (and so is your code).
This sensor sems to outputs VCC/2 with zero current. That might be 2.500volt on a 5.00volt supply.
But an Arduino 5volt supply is never exactly that.
The code should use an A/D value of 512 as zero reference, not 2.5volt.

All you need is this line.
float current = (analogRead(wcs1700) - 512) * 0.1386;
Then print to one decimal place.
Serial.println(current, 1);

const byte wcs1700 = A0;
float zero = 511.5; // zero calibrate
float span = 0.1386; // max Amp calibrate
float current;

void setup() {
  Serial.begin(9600);
}

void loop() {
  float current = (analogRead(wcs1700) - zero) * span;
  Serial.print(current, 1);
  Serial.println(" Amp");
  delay(1000);
}

Smoothing code (multiple reads and averaging) might still be needed.
Leo..

Hall sensors are always noisy, your only recourse is low-pass filtering to average the
readings over a longer time period, or use a better technology.

Note that that device has no accuracy specification at all in the datasheet! Not very
encouraging. Its sensitivity depends strongly on supply voltage too.

MarkT:
Hall sensors are always noisy, your only recourse is low-pass filtering to average the
readings over a longer time period, or use a better technology.

Note that that device has no accuracy specification at all in the datasheet! Not very
encouraging. Its sensitivity depends strongly on supply voltage too.

Datasheet mentions a 10-100n cap across the analogue input.
And yes, snoothing code could improve noise.
There could be another problem. We don't know what OP is measuring.

Looks like someone took a standard C-core, put a standard hall sensor in the gap, and encapsulted it in plastic.
I think one hall sensor is much the same as another.

The ratiometric code I posted compensates for that varying sensitivity.
Leo..

There are three sorts of hall sensor I know of:

ACS712 and similar that have a copper strip running over an isolated hall chip all potted in a single package.

Ferrite core with a gap and a hall chip in the gap

Ferrite core with a gap and a hall chip in the gap and a secondary winding which is actively driven to
keep the magnetic field zero. The secondary current is related to the primary current by the turns
ratio and the hall chip can be much more sensitive, so superior sensitivity and lower noise is possible.

Thanks for all the reply

Wawa:
If you measure a 140Amp sensor (+70, -70) with a 10-bit A/D (1024 values),
then don't expect a resolution of two decimal places.
Two decimal places would require at least 14000 counts.

This seems to be a ratiometric sensor, in which case the datasheet is wrong (and so is your code).
This sensor sems to outputs VCC/2 with zero current. That might be 2.500volt on a 5.00volt supply.
But an Arduino 5volt supply is never exactly that.
The code should use an A/D value of 512 as zero reference, not 2.5volt.

All you need is this line.
float current = (analogRead(wcs1700) - 512) * 0.1386;
Then print to one decimal place.
Serial.println(current, 1);

const byte wcs1700 = A0;

float zero = 511.5; // zero calibrate
float span = 0.1386; // max Amp calibrate
float current;

void setup() {
  Serial.begin(9600);
}

void loop() {
  float current = (analogRead(wcs1700) - zero) * span;
  Serial.print(current, 1);
  Serial.println(" Amp");
  delay(1000);
}



Smoothing code (multiple reads and averaging) might still be needed.
Leo..

Hi, where is the span value came from?

70 / 512 = 0.1386

Your math is wrong using 511.5. Use the simplified code Wawa posted in #3.

Thanto:
Hi, where is the span value came from?

33mV/A and a bi-directional 70A sensor (140A range) is 0.033volt*140= 4.62volt span on a 5volt supply.
4.62/5 of the range of the Arduino A/D (1024), or ~946 A/D values for 140Amp.

140/946 = 0.14799

Seems I was a bit off.
Change that 0.1386 to 0.14799
Still wise to calibrate if you have the means.
Leo..

WattsThat:
Your math is wrong using 511.5.

Sensors like that output about VCC/2 with zero current through the sensor.
511.5 is exactly in the middle of the range of a 10-bit A/D, but it might need calibrating.
A zero current calibration value of anything between ~510.0 and ~513.0 could be needed.
Leo..