labreport6
labreport6
labreport6
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
1. 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.
Magnetic field:
A Magnetic field is an invisible force field around magnets or electric currents that exerts
a force on other magnetic materials or moving charges.
The magnetic field (B) is a vector field and can be calculated using the following laws:
Biot-Savart Law:
This law states that the magnetic field at a point due to a small current element is directly
proportional to the current and inversely proportional to the square of the distance.
B=μ0 I/4πr2 B
Ampere’s Law:
This law relates the integrated magnetic field around a closed loop to the current passing through
∮B⋅dl=μ0I
the loop.
-7
Here, μ0=4π×10 is the permeability of free space.
In the case of a solenoid, the magnetic field is created by the electric current flowing
through its coils.
In this experiment, we will use Arduino and a Hall Effect sensor to measure the magnetic field
of solenoid and then we will analyse its behaviour
2.Apparatus:
2.1 Arduino Board
The Arduino board is a small, programmable computer (microcontroller) used to build electronic
projects. It connects to sensors and other small devices allowing them to interact.
Arduino software (IDE) is used to write and upload code to the board, making it easy to control
connected components with simple instructions.
Measuring Range:
The sensor can measure fields between
Conversion Factor:
Based on the sensor’s datasheet, the conversion from voltage (V) to the magnetic field (B) is
given by:
2.5 DMM
4.1Program Code:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4.2 Explanation:
4.2.1 Circuit Setup:
Firstly, 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.
We connected the solenoid to a variable power supply to control the current passing
through it.
4.2.2 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. The code
continuously measured and displayed the magnetic field values in real time.
Plot:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Calculation of μ0:
Using the slope of the graph, μ0 can be determined as:
B=μ0NI/L
Compare the calculated value of μ0\mu_0μ0 with the actual value (4π×10−7 T\cdotpm/A).
4.2 Explanation:
4.2.1 Circuit Setup:
We reuse the same setup from Part (a), ensuring the Hall Effect sensor remains at the
center of the solenoid. The solenoids used in this part were prepared beforehand, with
varying lengths (L) and numbers of turns (N).
4.2.2 Code:
We used the same Arduino code from Part (a) to measure the magnetic field strength, as
the sensor setup and measurement principle remained unchanged.
Length (L) [cm] 1/L [1/cm] n=N/L [1/cm] Voltage (V) Magnetic Field (B) [mT]
Plot 1:
Plot B (y-axis) vs n=N/L (x-axis).
//////////////////////////////////////////////////////////////////////////
Plot 2:
Plot B (y-axis) vs 1/L (x-axis).
//////////////////////////////////////////////////////////////////////////////////////////////////
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
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.