What am I doing wrong - Hall Sensor

All,

I have a hall sensor rigged up - pretty simple. One of these:

Setup: 1 pin to the 5v. Middle pin to ground. Other pin the analog pin on my micro.

Sketch: Analog pin to input mode, analogRead the pin value, Serial the value out, wait 500 millis, repeat.

Results: the values I'm getting fluctuate between 0 and 20 when I'm not doing anything at all. When I hold a rare earth magnet a 1/4" away, the values go up to maybe 40. If I back that off to an inch away, the values just fluctuate like I'm doing nothing. By contrast, if I just grip the jumper leading to the input, I get a value of 500. Yes, I've turned the magnet about and tried it.

I feel like sticking such a powerful magnet so close to a hall sensor should give me something more. Am I doing something wrong? Or are these just that weak and I was expecting too much?

Thanks!
Matt

Datasheet shows a Hall switch with open collector output.

Only two logic states are possible from a switch-type hall sensor.
Connect this sensor to a digital input with pull up enabled in pinMode.
Leo..

There are many different Hall devices. You want a linear Hall sensor, not a Hall switch.

The linear sensor has a direction that it measures field strength in. The switch might as well.

Wawa:
Datasheet shows a Hall switch with open collector output.

Only two logic states are possible from a switch-type hall sensor.
Connect this sensor to a digital input with pull up enabled in pinMode.
Leo..

That makes sense, but when I try connecting it to a digital GPIO and using digitalRead, I just get a constant read of zero.

Hi,
Have you tried turning the magnet around?
Do you have a DMM to measure the voltages at the Hall Device?

Can you please post your test code.

Thanks.. Tom.. :slight_smile:

Well, OK, scratch that last bit from me...I had it on a GPIO without a pull-up. When I put it on a pull up, I get a good read of ones/zeroes.

But, the root problem is still that I don't get a read much further than 1/2 to 1 inch away. Is that normal? Do I just need a larger hall switch/sensor or larger magnet?

Final question: do they even make larger hall switches? All I can find are these tiny ones like the 3144.

I want to be able to detect from a few inches away but worry about using a gigantic magnet (those things can be dangerous)

You won't do this with a hall switch.

You might with a linear device - especially if you put some soft iron, or better still permalloy or mumetal in front or behind or both to intensify the field. Mild steel might do - but does partially magnetise easily.

Permeability of air = 1.
At low magnetising forces ( < 0.1 Tesla) Iron/ steel about 2000. Permalloy/mumetal up to 20-100,000.

Allan

allanhurst:
You might with a linear device

Can you point me towards what you mean by a linear device?

google 'Allegro' and look at their range of products.

Allan

The A1318 might do what you want.
It has a typical output of 1.35-5mV/G

The A3144 you have can be between 70 and 350G to turn on (see datasheet).
Leo..

Hi,
What is the application?
At what distance do you want a magnet detected?

Thanks.. Tom.. :slight_smile:

The switches are mostly made for security purposes where you don't want a window or door to open much without notice.

Have you tried pointing the magnet pole at the switch from all sides of the switch? Hall Effect is directional.

Magnet field strength falls off at cube of distance.

Thanks everyone! I think I'm going to end up using an ultrasonic sensor for this project after all :frowning: Much appreciate the help!

A linear Hall sensor is an instrument sensor to measure magnetic fields with. It's not limited to ON/OFF and will detect fields farther away than the security switch. They cost less than $1 too.

You are trying to measure a distance or position? If you had a long magnet that moves alongside a linear Hall that would tell you where along the magnet the sensor is, would that do? Because if you put a magnet on an iron nail, the nail will be magnetic.