Magnetic Field Strength Measurement

Introduction

This experiment shows how to measure magnetic field strength using a Hall effect sensor.

Hall Effect Sensor

Components Needed

Circuit Setup

  1. Connect the Hall effect sensor's VCC to 5V on the Arduino.
  2. Connect the sensor's output to a digital input pin (e.g., D2) on the Arduino.

The Hall sensor detects the magnetic field and sends a signal to the Arduino.

Hall Effect Circuit Setup

Code for Magnetic Field Strength Measurement

Upload the following code to your Arduino to measure magnetic field strength:


const int hallPin = 2;

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

void loop() {
  int fieldStrength = digitalRead(hallPin);
  if (fieldStrength == HIGH) {
    Serial.println("Magnetic Field Detected!");
  } else {
    Serial.println("No Magnetic Field");
  }
  delay(500);
}
            

Explanation

The Hall effect sensor generates a voltage in the presence of a magnetic field, which is read by the Arduino to detect and measure the strength of the magnetic field.

Troubleshooting