Essentially the SDA/SCL reads the I2C values of the accelerometer perfectly fine when no other pin on the pi is active.

I have connected 4 drone propellers and whenever I give thrust to them by writing values to their pins (which have nothing to do with the SDA/SCL pins) for some reason the Gx/Gy values of the accelerometer get affected.

The values seem to have regular spikes in both positive and negative the more I increase the thrust values of the propellers.

I do not think this is a code related issue and more like electronic but just in case here is all the code:

- Main: https://github.com/bkstephen/drone_project_in_python/blob/master/droneLogic.py

- Gyro output: https://github.com/bkstephen/drone_project_in_python/blob/master/gyro.py

  • Hi @Stefanos, Nice to meet you again! (1) Your comment: "SDA/SCL reading I2C values of accelerometer" is a bit confusing. I would say it this way: "The I2C interfaced accelerometer's readings Gx, Gy"....
    – tlfong01
    Jan 11 '20 at 3:51
  • (2) Your comment: "Accelero working perfect if other GPIO pins not 'active'" is a bit confusing for the following reason: If you set a GPIO pin to output mode, it is always 'active" because it always output either High level signal (3V+), or Low level signal (1V-). So I would say something like this: If one or more GPIO pin is set to output mode, and sending out logical levels High level or Low lever', ...
    – tlfong01
    Jan 11 '20 at 4:00
  • (3) Let me describe your problem in more details. (a) I first setup and read the I2C interfaced accelerometer readings Gx, Gy with any problem. (b) Then I connect, say, 4 Rpi GPIO pins to input, say, PWM signal to 4 propeller controllers to adjust thrust. (c) NOW PROBLEM: if I change GPIO pin signal, say PWM duty cycle, then accelerometer readings are no longer stable, say, with some intermittently, unreasonably higher or lower than moving average readings, ....
    – tlfong01
    Jan 11 '20 at 4:13
  • (4) Let me know if I understanding your problem correctly. If not, please correct me, before I move on. Ah I need to leave now to meet a friend for Saturday brunch. See you later. Cheers.
    – tlfong01
    Jan 11 '20 at 4:15
  • Could you add some sample output including spikes to your question.
    – joan
    Jan 11 '20 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.