Hi.
I'm trying to make a headlight for my motorcycle that will rotate as bike leans to the side when turning to keep the headlight beam horizontal to the road (so I can see where I'm turning).
So far I designed the whole thing, 3D printed it, and went on couple test rides, but I'm having trouble with reading the angle/lean/roll of the motorcycle when moving.
First I tried MPU-6050 as I had couple on hand but I couldn't get it to work with the engine running (despite mounting the gyro on the foam or rubber pad far away from the engine). I gave up on that gyro probably too fast but the readings were garbage as soon as bike started.
I tried my luck with BNO055 (Adafruit breakout board) and it was better but sensor was randomly losing calibration and having to stop the bike and rotate sensor around makes the whole project pointless. Sometimes it would shift when going in the straight line for longer period of time and standing still (with engine running) would fix it, but where's fun in having to stop every couple minutes?
I also tried WT901 and so far had best results. But if I lean the bike and accelerate/decelerate during the turn then reported angle doesn't match the actual angle of the bike. If I try to keep the speed relatively constant then it kinda works. Problem with this sensor is that I can't find many projects for reference, just some very basic code that pulls data from the sensor.
So what hardware & software should I use to measure the lean of the motorcycle during movement? At this point I'm ready to throw some money on some badass gyro that will do everything for me.
Please advise.
Thanks.








