ECE 110/Equipment/Hall Effect Sensor

From PrattWiki
Revision as of 22:21, 17 August 2022 by DukeEgr93 (talk | contribs)
Jump to navigation Jump to search

$$\newcommand{E}[2]{#1_{\mathrm{#2}}}$$

Pins

  • 1 (left): Supply voltage $$\E{V}{CC}$$, typically 5 V
  • 2 (middle): GND
  • 3 (right): vout between 0 and $$\mathrm{V}_{\mathrm{CC}}$$

Operation

The voltage on the third pin will vary depending on the supply voltage and the magnetic flux density through the Hall effect sensor. If the magnetic flux density is 0 G (where G stands for gauss), the third pin will read

Assuming a 5 V external supply, pin 3's voltage will be between 0 and 5 V. A voltage of 0 V indicates the strong presence of a south pole while a voltage of 5 V indicates the strong presence of a north pole. An output of 2.5 V indicates no magnetic field. The sensitivity is 5 mV/G (where G stands for gauss)

Sample Code

const int Hall_In = 0;
const float VCC = 5.0;

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

void loop() {
  float Hall_Reading = analogRead(Hall_In);
  float Hall_Voltage = Hall_Reading * VCC / 1024.0;
  float Hall_Gauss = (Hall_Voltage - (VCC/2)) / 0.005;
  Serial.print("Analog reading = ");
  Serial.print(Hall_Reading);
  Serial.print(" ");
  Serial.print("Analog voltage = ");
  Serial.print(Hall_Voltage);
  Serial.print(" ");
  Serial.print("Flux density = ");
  Serial.println(Hall_Gauss);
  delay(100);
}