Applied Physics Lab( PH-111L)
BS-AI-F-24-B
Lab Report .
Experiment-05:
Using Arduino for
Magnetic Field Measurement with Hall Sensors
Submitted By:
Group C
Group Members:
Ayesha Siddiqa (241419)
Dua Mehmood (241391)
Muattar Imam (241451)
Mahnoor (241453)
Muhammad Waqas ur Rehman (241441)
Sohaib ul hassan (241377)
Sayyam Khalid Satti (241431)
Abdullah Ghaffar (241423)
Submitted To:
Muhammad Farooq Wasiq
Submission Date:
/11/2024
Introduction:
➢ Arduino is an open-source platform widely used
for interfacing with sensors and other hardware
components.
➢ Hall Effect sensors detect and measure magnetic
fields by producing a voltage proportional to the magnetic
field strength.
➢ In this experiment, we used Arduino and a Hall
Effect sensor to measure the magnetic field and analyse its
behaviour at varying distances from a magnet.
Apparatus:
➢ Arduino Uno microcontroller
➢ Hall Effect sensor (.........)
➢ Breadboard
➢ Jumper wires
➢ Laptop with Arduino IDE
➢ Multimeter (for current measurement)
Circuit Diagram:
Procedure:
We will set up all of the circuit and things according to our code so firstly let me show you our code:
Program Code:
// Magnetic Field Measurement Using Hall Effect Sensor
const int sensorPin = A0; // Analog pin connected to Hall sensor
const float sensorSensitivity = 1.3; // Sensor sensitivity in mV/G (for A1302)
const float VCC = 5.0; // Arduino supply voltage in volts
const int ADCResolution = 1024; // 10-bit ADC resolution
void setup() {
Serial.begin(9600); // Initialize serial communication
}
void loop() {
int sensorValue = analogRead(sensorPin); // Read analog value
float sensorVoltage = (sensorValue * VCC) / ADCResolution; // Convert to voltage
float baselineVoltage = VCC / 2; // No magnetic field baseline voltage
float voltageDifference = sensorVoltage - baselineVoltage; // Change in voltage
float magneticFieldStrength = (voltageDifference * 1000) / sensorSensitivity; // Gauss
Serial.print("Magnetic Field: ");
Serial.print(magneticFieldStrength);
Serial.println(" G");
delay(500); // Delay for 0.5 seconds
}
Explanation:
Circuit Setup:
➢ We connected the VCC pin of the Hall Effect sensor to the 5V pin on the Arduino.
➢ The GND pin of the sensor was connected to the GND pin on the Arduino.
➢ The OUT pin of the sensor was connected to analog input pin A0 on the Arduino.
Voltage Control:
➢ We varied the voltage applied to the Hall Effect sensor. For this experiment, the
applied voltage was controlled by adjusting the input power supply.
Code:
➢ We wrote a program in Arduino IDE to read the sensor's analog output and calculate
the magnetic field strength in Gauss (G) based on the sensor's voltage.
Data Collection:
➢ We changed the voltage supplied to the Hall Effect sensor at different points and recorded the
corresponding current and magnetic field values.
Applied Voltage (V) Current (mA) Magnetic Field (G)
2.50 0.0 0.0
2.60 10.0 76.9
2.80 20.0 153,8
3.00 30.0 230.8
3.20 40.0 307.7
3.40 50.0 384.6
3.60 60.0 461.5
3.80 70.0 538.5
Verification:
We can verify these answers manually as well using these formulas
➢ Current (mA):
The current is calculated using Ohm’s Law, assuming a fixed resistor in the circuit. The
current increases as the applied voltage increases. In this setup, the current is directly related
to the voltage change.
I=V/R
➢ Magnetic Field (G):
To calculate the magnetic field inside a solenoid,we will use the formula:
B=μ0 N I /L
Where
μ0 is is the permeability of free space (4π×10−7 T.m/A)
N is the number of turns of the coil
L is the length of the solenoid (in metres)
And now to convert that magnetic field in Gauss (G) to Tesla (T)
B(G)=B(T)×10,000
And through it we verified that the calculated magnetic field values were accurate, and the
experiment was successful in determining the magnetic field strength inside the solenoid.
Graph:
Conclusion:
This experiment successfully told us how to measure the magnetic field using an Arduino and Hall
Effect sensor. We found that Higher Voltage results in Higher Current (if resistance remains
constant), and Higher Current leads to a Stronger Magnetic Field.