Go Down

Topic: Magnetic Sensor (Read 6423 times) previous topic - next topic

bryantdc

Hey Everybody,

Im pretty new to the arduino, and I was looking for any insight into using a hall sensor to simply detect a magnet with the arduino.  I would also like to visualize any output with an LCD, 7 segment display, or LED.  Any help with coding and circuitry would be greatly appreciated!

liudr

Welcome! A hall sensor is not hard to use. Take a look at this one:

http://www.sparkfun.com/products/9312

You should try to break down your project into pieces such as understanding the hall sensor, understanding an LCD, and then putting them together.

sample code:
void setup()
{
  Serial.begin(19200);
  pinMode(2,INPUT);
  digitalWrite(2,HIGH);
}

void loop()
{
  Serial.println(digitalRead(2));
  delay(200);
}

bryantdc

Thanks! Ill definitely get started

bryantdc

How would I connect the arduino with the sensor?

Grumpy_Mike

Take the output of the sensor and connect it to one of the pins. Make sure the sensor's ground is connected to the arduino's ground as well.

robtillaart


check - http://www.arduino.cc/playground/Code/HallEffect
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

liudr

Observe the type of sensor that you use. One type of sensors only switch from High to Low when magnet's polarity is swapped and you may want the other type, where it goes from High to Low when the magnet is removed. But it doesn't responds to the opposite magnetic pole.

GH

I've been using an allegro 1302eua hall effect sensor as part of a rover we're building in our school.  It's not the latching sort, so it returns a voltage proportionate to the magnetic strength it's detecting.  Baseline output is 1/2 supply (2500mV on a 5V supply) and a N pole increases the voltage and a S pole decreases it.

I borrowed a pretty rubbish magnet from the physics department and the sensor picked it up from a good 70mm away.

The supplier I used in the UK sells them for about £1.35 plus postage.

Grumpy_Mike

Just for reference there are many types of hall sensors:-

1) Liner sensors - give an output proportional to the field, used in current detectors and such.

2) Switch - outputs zero or one.
    a) In the presence of a specific magnetic field direction- non latching unipolar.
    b) In the presence of any magnetic field - non latching bipolar.
    c) Reflecting the last field seen - latching.

liudr

In addition, if you got the old non-ic sensor, just to Hall probe, you need to flow current through the sensor and monitor voltage across it. The voltage could get negative and gets very big if you move your magnet too fast. This type of sensor is not very fit for arduinos. The ones we talk about are mostly 3-pin TO-92(?! right?) ones.

pluggy

Personally I'm a fan of old fashioned reed switches, cheap and simple.......
http://pluggy.is-a-geek.com/index.html

liudr


Personally I'm a fan of old fashioned reed switches, cheap and simple.......


Definitely vote for Reed switches, no power is needed to drive the sensor and it can pass a moderate amount of current to power a device. On the other hand, Hall sensors can be made more sensitive with internal gains and much smaller packages.

retrolefty

However, some reed switches tend to have some amount of contact bounce you have to deal with.

pluggy

A capacitor and resistor takes care of the contact bounce ;)
http://pluggy.is-a-geek.com/index.html

bryantdc

Thanks everybody for the help! But I havent gotten anything to work yet...Im still confused as to how exactly I need to set everything up...I have a breadboard, resistors, wiring my arduino and my sensor...am I missing something? If anyone had a diagram for a simple magnetic sensor, it would help greatly!

Go Up