I've tried four different hall effect sensors. The hookups seem simple. All but one (ID = A1302, 1718743 and OH180U for those three) show the three leads to be VCC, Ground and signal. The fourth has two caps and two resistors, but the result is the same.
All four give me about 0.24 volts out on the signal lead when a magnet is not present. When a magnet is present with the proper pole facing the sensor, signal out voltage drops to 0.0 volts. (Or analog readings on the 0-1024 scale of 16-20 for 0.24 volts and analog reading of 0 for 0.0 volts in.)
With 0.0 or 0.24 volts in to an anolog in pin, I can't get enough difference to properly detect the magnet. There are occasional sporadic readings that indicate the magnet is there when it is not. (At 10 ms between readings, maybe one in 30 readings are above 0.0)
I tried averaging 10, then 20 readings, thinking that if I get ten or twenty zeros in a row, the magnet is there, but that didn't work.
I must doing something wrong, The specs all indicate my signal out lead should vary from 0 to 5 volts, not 0 to 0.24 volts.
Do you have the grounds of the sensor and your board connected together?
--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons
The OH180U has an open colector output and so you need a pullup resistor on the signal wire to set the no magnet present voltage. You can connect it to an anlog inut to see how it performs (also with a pullup resistor), but use of this device is primarily digital (low with magnet present, high otherwise). There is also a hysteresis on the output to support use as a digital indicator or pulse feed depending on application.
The A1302 has an analog output which swings around half the supply voltage. You would connect this to an anlog input and with no magnet present you should see values around 512 (2.5V). When a magnet is present, values will read high or low (compared to 512) depending on polarity and proximity. To use this as digital indicator, you would need to add some logic that triggers on a low/high threshold level.
You may need to show both wiring and code to get more specific help on what your issue might be.
RuggedCircuits: Yes. I ran wires from the Arduino Uno 5V and Gnd lines to a small proto-board where the hall mounts. (So the hall is powered from the board's 5V & Gnd, not a separate source.)
BenF: Didn't think about a pullup resistor. Thanks. I'll do that. Strange that none of the docs on any of the halls mention that...
Strange that none of the docs on any of the halls mention that...
Diagram, page 1:
http://www.datasheetcatalog.org/datasheets2/30/309118_1.pdf