How do I fix my hall sensor?

Hi, I am working on a project with an esp32 and a KY-035 hall sensor. When I connected my circuit to my computer for the first time the hall sensor was working fine however, when I finally uploaded the code to the esp32 the sensor stopped working. I think the sensor is not broken because every time I connect the circuit to my computer the small light in the sensor blinks just for a moment, but I don't know how I can make it go back to how it was working in the past. Here is the code I uploaded:

int analogPin = 4;

void setup() {
  pinMode(analogPin, INPUT); 
  Serial.begin(9600);
}

void loop() {
  int analogVal = analogRead(analogPin);
  Serial.println(analogVal);
  delay(100);
}

Please post a diagram showing all connections. You can draw one by hand and post a picture

2 Likes


It looks something like this

Check the label on your board; is it what you’re showing? For instance, I have an ESP8266 that looks very similar, but at least its pins are numbered. Keep in mind that "ESP32" has become a generic term used for many different boards, each with unique configurations.

To help us assist you, please:

  1. Post links to the specific hardware items you’re using.
  2. Provide a detailed, annotated schematic that includes all power, ground, and power sources.
  3. Clearly label all lines, pins, and connections in your schematic.
1 Like

"Something like" is not good enough. We need to know exactly what it is along with pin numbers and details of what sort of hall effect sensor is on that breakout board.

2 Likes

Hi, @spiderfm4

Can you please post some images of your project?
So we can see your component layout.

What do you mean?

Do you have a DMM? (Digital MultiMeter)

Can you measure the voltage supplied to the sensor module?

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

You "circuit" tells us nothing about what pins you are connected to.
Not all ESP32 boards are the same.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

2 Likes

I am using these hall sensor: KY-035 Bihor magnetic sensor - SensorKit
Also, is this schematic good enough? :


I ended drawing the place in which the D4 pin placed wrong, however here is the original pinout of my ESP32:

Sure, here is a photo of the project (sorry if the angle and the quality of the photo is bad):


I don't have a DMM or can measure the voltage supplied to the sensor module, but I will try buyiung a DMM if it helps!

A inexpensive meter is better then none. They can be gotten for less then the cost of two packs of cigarettes. Hint do not use the mA or Amps until you have more experience.

// No need to set pinMode for analog input, it's automatic for analogRead
pinMode(analogPin, INPUT); 

This code can be removed. It appears you are connected to GPIO16 which is not an analog pin.

Hi, @spiderfm4

Replace all your 3 leads, it is possible you have an open circuit wire.


What is the part number printed on the PCB.

These cheap modules PCB are used for a lot of sensors and the pinouts can be wrong.

Make sure the sensor is soldered in the correct way.

Tom... :smiley: :+1: :coffee: :australia:

  • BTW, unless you need an analog sensor output, suggest you buy the digital version.

Hi,
Also this device is open collector.

So you need a pullup resistor between the output and supply.

What voltage are you supplying the hall device, it has to be 4.5V or higher.

Tom.. :smiley: :+1: :coffee: :australia:

1 Like
  • I know that's true for the digital version, not sure about the analog version :thinking:

Hi,

OP definitely needs an economy DMM.

Tom..

1 Like

Am I the only one seeing that OP put the sensor in a power rail?

  • Maybe, but will give them the benefit of a doubt.
    Appears it’s ahead of the red power rail marking.

Yeah, there's little chance the pins are bent towards the back of the Pcb, but who knows =)

You forget you are using a 5V signal to drive into an ESP processor that has a maximum input voltage of 3V3.

Therefore you need to cut down the 5V signal you sensor gives you to a 3V3 signal with a potential divider.

Use this circuit to do this where the sound sensor is actually your hall effect sensor, and the GPIO pin is the one you want to use as the input.

From here
https://sensorkit.joy-it.net/en/sensors/ky-035
The BIHOR magnetic sensor module uses the AH49E Hall-effect sensor, which can detect magnetic fields. If no magnetic field is present, the sensor outputs a voltage that is approximately half the supply voltage.
and here
https://www.diodes.com/assets/Datasheets/AH49E.pdf
Supply Voltage VCC 3.0 6.5 V