APM 2.5 Analog Inputs

I'm trying to add 2 analog sensors to my APM2.5 system, both are 5v potentiometers.

This is the essential code that I have added to the system:

static int read_alpha(void)
  int alpha;
  alpha = analogRead(7); //initially on 6, switch to 7
  return alpha;

I am calling this at 10Hz inside the medium loop, although would prefer to read it at 50 Hz. Unfortunately it looks as if I am not reading data properly, something is going on with the hardware or software that I do not fully understand. Attached are plots showing the logged data at 10 Hz with weird drops back to a static value.

Any help is greatly appreciated.3690985996?profile=original


You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –


  • I´m trying to exactly the same? Any suggestion?

      Thanks! :-)

  • Are you planning to add this functionality to an aircraft?

    If not, I am not certain that the programming of all the subsections of the APM may be compatible to your goal.

    True that it is an Arduino. More to the point is that it has been specialized in purpose and the support chips have firmware that has been written to the purpose.

    Are you familiar with the Eagle files for APM?


  • Ok I will bite. Where are you adding the sensor inputs to?

    Are you using the current and voltage inputs? Other pins?

    Is there a schematic of this added circuitry -- though it only sounds like you added potentiometers.

    I think we need more information to discuss this. It almost sounds like you are using the APM as a data-logger front end.


This reply was deleted.


Shivchand Jaysaval liked Shivchand Jaysaval's profile
Aug 25