Using Arduino > Sensors

Interrupt problem with hall effect sensor

(1/2) > >>

I recently purchased a "Arduino Magnetic switch Hall-speed counting detector Sensor module" from Amazon for what is essentially a speedometer project. When I connect the sensor into a digital pin and read/display the state I get what seems to be the appropriate string of 1s and 0s based on the presence or absence of a magnet. However, when I use either interrupt pin on my Arduino Uno R3 with an interrupt function that does nothing but increment a counter and create a time stamp, I get a counting pattern that doesn't correspond exactly to the number of magnet passes.

When I use FALLING it seems like the interrupt function triggers twice at the exact same time. With RISING or CHANGE I get three responses. Is this a programming issue or a hardware issue?

Thanks ahead of time.

More information about the specific hall sensor used would be useful here; some sense just N or S and some either. If the hall sensor has any numbers on it you should try googling them up.

When the magnet is passing under the sensor it sees the polarity of the face of the magnet but can also see the magnetic flux from the other pole of the magnet when the sensor is near the sides of the magnet. You might be able to counter this simply by moving the sensor further away.

This sensor picks up S on one side and N on the other. I was unable to find a datasheet for this specific complete module, but the datasheet for the hall effect switch is here:

The info on the only other part of the module besides a few resistors and LEDs is here:

The distance from the sensor to the magnet doesn't appear to have an effect on the result.


You get the same counts for RISING and CHANGE? CHANGE should give you the sum of RISING and FALLING. I guess you have to apply a low pass filter to make some "debouncing". Do you have the chance to analyse the signal on an oscilloscope?

Yes, RISING and CHANGE both give three counts per magnet pass. One count occurs when the magnet is placed in front of the sensor and the other two occur when the magnet is removed. To me it seems like this is almost correct for CHANGE except that the FALLING count occurs twice per pass. But I guess I don't have the experience to understand why this same behavior occurs for RISING.

I don't have easy access to an oscilloscope. How important would it be?

Thank you


[0] Message Index

[#] Next page

Go to full version