Strange behavior using ESP32 and hall effect sensor

Hi all,
I have an ESP32 Wroom and when i try to plug a thumb throttle on pin 13 and a push button on pin 27 everithing work fine i succeed to read the hall value but when i press the button the signal of the hall is incorrect it pass to full (10 bit => 4095).
Do you have an explanation on what wrong with my code or my electrical schema? I tried to change the input mode as well but not working also. Every answer is appreciated.

pinMode(27, INPUT);

void loop()
{
   LectureEntree();
}

void LectureEntree()
{
  int sensorValue = 0;
  int i=0;
  for (i=0;i<=20;i++){
   sensorValue =  sensorValue + analogRead(13); 
  }
  throttleIn =(int)(sensorValue/20); 
  Serial.print("Signal of the hall: ");
  Serial.println(throttleIn);
}

VCC

Post your complete code.

Pin 27 is floating.
Try putting a resistor (+- 10k) pin 27 to GND.

20 * 4096 is too much to fit into an int. It will rollover.
0 to <=20 is 21 readings.
Leo..

unsigned int sensorValue = 0;
for (int i = 0; i < 20; i++) sensorValue += analogRead(13);
throttleIn = sensorValue / 20; 
Serial.print("Signal of the hall: ");
Serial.println(throttleIn);

Thank you, you are right. It not change my issue but it will certainly correct another one :stuck_out_tongue:

In fact yesterday i change the pin of the hall entry to the 34 pin (ADC1) and it working fine. I don't get why i have this kind of behavior on pin 13

GPIO13 can't be used when WiFi is used.
GPIO34 is input only, and doesn't have internal pull up.
You should read this page (click).
Leo..

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.