Project

General

Profile

Reading states of external hall sensors

Added by Alexander Enzmann over 1 year ago

Hi,

i am not able to read state of hall sensor. I dont know whats wrong here. If I run C-Code programmed with VSCode it s working, so I think my schematic should be fine. I am using 10k pull-up resistor and there is no difference if I connect it to 5V or 3.3V.
I attached a model: It should read hall sensor state at GPIO25 and puts it on GPIO21. It shows always low and it seems like my GPIO25 pulls my hall signal to GND.

It is for a little BLDC project and later it shall read three hall sensors.

Here is my code which works in VSCode (it is for three hall sensors with three 10k pull-up resistors):

...
#define HALL_A 25
#define HALL_B 26
#define HALL_C 27
...
pinMode(HALL_A, INPUT);
pinMode(HALL_B, INPUT);
pinMode(HALL_C, INPUT);
...
hall_sensor_value = gpio_get_level(GPIO_NUM_25) * 4 + gpio_get_level(GPIO_NUM_26) * 2 + gpio_get_level(GPIO_NUM_27) * 1;

Maybe somebody can help me :)


Replies (7)

RE: Reading states of external hall sensors - Added by Parth Maheshwari (พาร์ท) over 1 year ago

Hi Alexander,

Thank you for reaching out.

From what I see in your attached model, you have commented out everything except the Waijung 2 Digital Input and Digital Output blocks. I have tested both these blocks by trying to read states of a push button and also a DIP Switch using your model file. I can successfully read the states of both switches.

Have you tried changing the "pull-mode" in the Digital Input block?

Please let me know.

Sincere regards,
Parth

RE: Reading states of external hall sensors - Added by Alexander Enzmann over 1 year ago

thanks for your quick response. For me it does not work. If I change sample time from digital input block from -1 to 0.1s or if I change pull-up/pull-down/floating...no difference :( dont know whats wrong here. I also tried with a new, fresh model (target-block, digital-in block and digital-out block). Setting an digital-out (GPIO) to low or high is working, but reading state of hall sensor with digital-in and forward it to a digital-out does not. Let me know if you have any ideas :) thanks.

RE: Reading states of external hall sensors - Added by Parth Maheshwari (พาร์ท) over 1 year ago

Have you tried reading the states of a push button or DIP switch with digital-in and forward it to a digital-out? If yes, is that working for you?

Sincere regards,
Parth

RE: Reading states of external hall sensors - Added by Parth Maheshwari (พาร์ท) about 1 year ago

Hi Alexander,

Were you able to make this work?

May I know which ESP32 board / boards you were using to test this?

Please do let me know.

Sincere regards,
Parth

RE: Reading states of external hall sensors - Added by Alexander Enzmann about 1 year ago

Hi,
well, I did not get it run, I still have same problem with the hall sensors. But if I put 5V directly to a GPIO pin (e.g. GPIO25) with a simple switch, it works (it will lead to GPIO21 high).
I am using this board: esp-32-dev-kit-c-v4
https://www.azdelivery.de/en/products/esp-32-dev-kit-c-v4

Just wondering why my setup/hall sensor wiring is working with my little C-Code made in VSCode.

RE: Reading states of external hall sensors - Added by Alexander Enzmann about 1 year ago

seems like the problem is fixed with latest release 23.5a.
thank you - its working now.

RE: Reading states of external hall sensors - Added by Parth Maheshwari (พาร์ท) about 1 year ago

Hi Alexander,

Happy to hear that it's working for you now.

Let me know if there's anything else you need.

Sincere regards,
Parth

    (1-7/7)