Page 2 of 2

Re: Esp 32 using HC-SR04 PROBLEM

Posted: Tue Apr 22, 2025 1:42 pm
by Viktor74
Hello, everyone! Could you please tell me what I'm doing wrong? The compiler gives an error. In the simulator it works fine.

Re: Esp 32 using HC-SR04 PROBLEM

Posted: Tue Apr 22, 2025 2:07 pm
by medelec35
Hello.
Thank you for the bug spot, it looks like there is a sharing violation of timer 0 when there should not be.
To get your project to work you have two options.
1. change timer interrupt from 0 to Timer 2 for example.
Or
2. Change properties of HC-SRO4 to Use Timer Interrupt = Yes.
Change the timer interrupt from 0 to 1 or 2 for example, then change Use Timer Interrupt back to No

I will look into fixing this component .

Re: Esp 32 using HC-SR04 PROBLEM

Posted: Tue Apr 22, 2025 4:07 pm
by Viktor74
Thank you Martin! Yes, it really works great on Timer2.

Re: Esp 32 using HC-SR04 PROBLEM

Posted: Tue Apr 22, 2025 4:11 pm
by medelec35
Thanks Viktor.
I fing using the timer interrupt for HC-SR04, the results are more accurate.
I'm glad your project is know working.
Thanks for letting us know.