Qtr8 library for esp32 c programming

hello i am willing to build a line follower robo using qtr8 sensor with pololu library and esp32 microcontroller…
but the current library seem to not work with esp32 since the analog inpurt of the esp is between 0 and 4095…
so i am not able to get values of each sensor between 0 and 1000 and get a correct line position

anyone can help please ?

We have not tested our Arduino library for the QTR sensors with the ESP32, but if that is the only issue that’s stopping it from working, you might try calling analogReadResolution(10) at the start of your code so it uses 10-bit readings.

Alternatively, you could try modifying the library by changing the _maxValue variable on line 13 of QTRSensors.cpp from 1023 to 4095.

Brandon

Thank you BrandonM
i made both changes… i’ve added analogReadResolution(10) and modified maxValue to 4095 and i started getting some reasonable values…

but still couldn’t reach good reading of line position, i am using a line having 2cm of width…
the minimum value didn’ t reach 0 and max didn’ t reach 7000 even when line is under both first and last sensors
here some values i am getting

calibration
Capture d'écran 2023-12-02 230100

maximum line position value i 've reached

minimum line position value i’ve reached

any advices ?

Hello.

Jus to clarify, you should not do both of the suggestions I made in my previous post at the same time; so, if you are calling analogReadResolution(10), you should leave the _maxValue variable set to 1023.

When your robot is going through the calibration process, can you verify that each of the sensors is being passed completely over the line as well as being exposed to the surrounding surface? Also, if you are physically moving the robot over the line manually, please make sure you are not lifting the sensors away from the surface (ideally it should be calibrating in the same situation it will be used in).

Brandon