Arduino Advent Calendar Day 17 - Hall Effect Sensor

Need help for the Arduino Advent Calendar Day 17 Guide? Just post on this thread and our highly trained team of Arduino ninjas will be able to help you in no time!

HI, I am enjoying the course very much.I had a problem with this one. The magnet turned on the LED but no red light appeared on the sensor. Also, the LED did not switch off once the magnet was removed. I tried adding a delay of 500 at the end of the sketch but this did not work. Do you think the component is faulty?

Check the jumper cables carefully; what you said happened can happen from electrostatic field of your hand if pin 10 on the Arduino has nothing connected, or if the other end of the jumper is not connected to the sensor, or if the sensor has a faulty “S” pin.

Temporarily test the code works properly by disconnecting pin 10 on the Arduino, and then briefly connecting pin 10 to either;

  • 5V, or
  • GND.

Also check that the 5V and GND jumper cables go to the correct pin on the sensor. If you got it around the wrong way, the sensor could be now damaged, and that could explain why it does not light up.

Thank you for the help.I replaced the cables and checked them, no change. I connected pin 10 to ground nothing happened. What was supposed to happen? I could not try 5V as it is being used.

I see someone in the comments on the bottom of the instructions says it does not work.I have ordered another of this component in case I fried it.

I connected pin 10 to ground nothing happened. What was supposed to happen?

The LED D13 and the LED on the breadboard should have turned off.

I could not try 5V as it is being used.

As this is a temporary test, you should stop it being used during the test. However, you can also use the 3.3V or 3V3 pin for this test.

I see someone in the comments on the bottom of the instructions says it does not work.

Following the link to the question thread shows the sensor module they have has a reversed output polarity; but in your case the LED on the module did not come on, and you could not get the LED on the breadboard to change at all?

I redid it and this is what happened.

When all is plugged in as per original and I put the magnet on the sensor the LED and the LED on the arduino light up and stay on, there is no light on the sensor.
When I unplug the wire on pin 10 the LED and the LED on the arduino switch off.

When I connect a wire from pin10 to the 3.3v pin the LED and the LED on the arduino light up and stay on. There is still no light on the sensor,

Thanks. Taking your observations in reverse order;

When I unplug the wire on pin 10 the LED and the LED on the arduino switch off.
When I connect a wire from pin10 to the 3.3v pin the LED and the LED on the arduino light up and stay on.

Good, the Arduino, program and the two LEDs are working.

When all is plugged in as per original and I put the magnet on the sensor the LED and the LED on the arduino light up and stay on, there is no light on the sensor.

Bad;

  • the LED on the sensor should change in response to whether a magnet is nearby (roughly less than 5cm) or not,
  • the Arduino LEDs should change in response.

Your sensor is not working, possibly faulty, or there is faulty wiring on the sensor module or the jumper wires.

If I were there I’d measure the voltages with a digital multimeter, set for DC volts, with the black probe attached to an Arduino GND pin, and the red probe touched carefully to each of the hall effect sensor wires and the back of the header pins. The numeric results would give me a fairly good idea of where the fault might be found.

I took the multimeter readings and this is what I measured:

Hall Effect Sensor Wire , s 2.4 , middle .4 , - pin 5.04
Back of Header pin , s 2.4 , middle 5.04 , - pin .5

also tried to resolder all joints on the sensor but it makes no difference

Thanks for the multimeter test.

At 2.4V, the level is very close to the middle of the 5V range, so the result may be uncertain when using digitalRead(). (From the datasheet of the processor, at 25C at 5V supply, the ATmega328P I/O pin Input Threshold Voltage is around 2.6V for HIGH, around 2.2V for LOW, Hysteresis is 0.55V, so 2.4V is in the dodgy area; and could be anything.)

I don’t know exactly which hall effect sensor it is, so I can’t check the datasheet. I don’t know if 2.4V is a correct output for the sensor.

You might try seeing if that 2.4V changes with a magnet nearby.

You might try using analogRead() and A5 instead of pin 10. See my untested gist.

Perhaps either;

  • the Arduino Uno or sensor have been damaged by electrostatic discharge, or;
  • the available stock of the Arduino Unos or the sensors have a wide threshold variance and you got a bad combination.

A fascinating problem.

Thanks for your reply, with the original setup, bringing the magnet close changed the reading from 2.4 to 2.5.
Unfortunately using the A5 pin and modified sketch did not work at all the LED did not light up.
I have a new arduino and sensor coming from Little bird ,when it comes I will redo the circuit

No worries. With a reading like that, the modified sketch wouldn’t work, and it is likely the sensor module is faulty.