I am working on a dashboard for a motorcycle. I created a Qt application on my raspberry pi 4 on a raspberry pi os lite.
I have configured one of my GPIO as interrupt using the wiringPi library.
wiringPiSetup();
pinMode(m_pin,INPUT);
pullUpDnControl (m_pin, m_pud) ;
wiringPiISR(m_pin, INT_EDGE_RISING, isrInput);
and in my interrupt handler I am incrementing an attribute.
void Capteur_Input::isrCallback()
{
increment_impulsion();
qDebug()<<"nombre d'impulsion"<<get_impulsion()<<"le nombre de tour est "<<(get_impulsion())/4;
}
my sensor is an inductive sensor , each turn it generates 4 pulses. I tested this and it is working fine.
But when putting the sensor on the axis of the motor wheel and running the engine, it shows random values even if the wheel is fixed and not turning.
is it because of the magnetic field generated by the engine alternator?
even when removing the sensor and just leaving a cable connected to the gpio it shows values.
if I remove every thing the gpio of the raspberry does not detect any thing so the problem comes from the cable. how to isolate this?
it shows that the speed is 40 when the wheel is fixed so it is detecting like 20 pulses/second !
The other gpio that are not interrupt works almost fine even when the engine is running.
can some one please help me!