Data Logging

I am using the APM2.5 as a data logger.  I am learning the code hoping to be able to make changes.

I eventually need 10 analog channels being recorded to Dataflash.  In the meantime, I plan on using the 8 channels available: Two rangefinders, Airspeed, RSSI, and the two Battery Voltages and currents.

I am recording Airspeed, Battery Voltage & Battery Current as they were designed, all is good.

I am recording an analog signal using the Rangefinder1 setup.  It shows up in the dataflash file as SONR.  I have assigned pin 6 for RNGFND2_PIN, but I do not see it in the dataflash file!  Does anyone know if the code has the second rangefinder data being written to dataflash?

When I assigned a pin # to BATT2.VOLT_PIN & BATT2_CURR_PIN the CURR line in the dataflash added a column of VOLT2, but no CURR2!  Does anyone know if the code missed adding the second current?  Where in the code would I find it?  I have looked in DataFlash_APM2.cpp.

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

Join diydrones

Email me when people reply –


  • Hi John,

    I have used both the APM and Pixhawk for processing/logging data from external sensors. I am just getting into another project doing the same. I have only just looked at the latest version of the code and it seems that there are a few changes so it is hard for me to offer you any specific advice right now. What you want to do should be quite achievable. Although both the Pixhawk and APM have a number of analog/digital inputs, I have always used an external arduino to read sensor and exchanged info via serial. If you look up my previous posts you will get an idea of what I have done and how I went about it.



    • Hi James. I wonder if you can help me a little bit on the project that I'm working now? I was assigned to create a system to do yield map during the almond harvest. I used a GPS module with arduino before, and integrate the position data with load cells that measure the almond weight. 

      The new challenge now is to use pixhawk to determine the positioning of the collector machine, instead of using arduino due to pixhawk ability to interface with other sensors and camera easily afterwards. But I will still process the almond weight data using arduino. My questions are:

      1) how can I combine the data from my arduino to include with the gps data from my pixhawk? I've read some posts on this but I could not entirely understand them because I'm pretty new to this pixhawk thing.

      2) What would be the best way to integrate data from both parts? Is it by sending serial output from arduino to pixhawk and save them on pixhawk, do the post analysis there. Or by sending gps data from pixhawk to arduino and arduino will process both data.

      Please note that if I manage to integrate both information from arduino and pixhawk, I will generate the yield map using the google fusion drive where I will save the data as csv file format which is the kind of format needed for google fusion to understand. I may prefer the data to be saved and processed on pixhawk because I believe that through telemetry download on pixhawk I can easily convert and save the data in csv file on my PC. 

      I really appreciate any kind of response from you James. 

      • Hi Edwin,

        Sounds like an interesting project! I have used pixhawk/APM in a similar way a number of times. Sending data from an external Arduino via a serial port and having it logged along with the other Ardupilot data is fairly straight forward. I have a couple of examples posted where I do this. Using the likes of Mission Planner you can download the data file and produce a .log file. This file is basically a CSV file from which you can extract the information you require - including the weight data that you sent from the Arduino.

        To undertake this task you will need to become familiar with the Ardupilot code (I use copter). Please check out and download the compiler and source code and work through the process of compiling and uploading the code yourself. Once this is done I can point you in the right direction for what you need to achieve your goals.



        • Hi James. I have downloaded the compiler and followed some tutorials on it (still a noob though). So what should I do next? Can you explain the detailed procedures how can I logged arduino data together with ardupilot data?

          I have purchase another cable to connect the Arduino to Pixhawk, I reckon you'll suggest to connect them through pixhawk telemetry port? I am using telemetry 1 for the radio comm between pixhawk and mission planner on my laptop. So I suppose I should use telemetry 2 port for the arduino? Please correct me if I wrong. By the way do you need to see my Arduino code for the weight measurement with load cells? I can email it to you if you dont mind.

          Could not thank you more James. 

          Best regards,


          • Hi Edwin,

            So you have managed to compile the code and upload it to the Pixhawk? If you send me the code you are using to measure weight with the Arduino it will help - I will private message you my email address. You can use the Telem2 or the Serial 4/5 port so if you have a cable/connector that will fit these that will be good.
            • Hi James,

              I think I have managed to compile the code by now. But how to actually know whether I have successfully managed to upload the firmware into pixhawk? I have uploaded an Ardurover firmware when I first got the board a month ago through mission planner. Will I have any trouble with that? Or it will automatically erased the older firmware when I'm uploading a new one from eclipse? Sorry for the beginner question :-)

              Btw, I have emailed you the Arduino code and the image of the telemetry cables that I'm planning to use to connect pixhawk and arduino. Wondering if you have received the email. Thanks James.



              • Hi Edwin,

                If you have successfully compiled the code then you will have an ArduXXXX.px4 file in your build directory. To upload this to your Pixhawk you can select 'load custom firmware' in Misson Planner and select this file. Loading previous firmware will not affect this process at all and the new firmware will overwrite the old. Parameters are generally preserved but can change between versions. Parameters are different between Copter/Plane/Rover etc. I use copter for all my 'non flying' projects but only because it is what I am most familiar with.

        • Hi James,

          Yes it is indeed an interesting project but to be honest I don't have any idea on how to do such thing at the beginning, as I never use pixhawk before. I will do everything that you told and try to study everything to get a clearer picture. I'm really keen to learn this new stuff. Its good if I can have someone who can guide me. Really appreciate this buddy. 

This reply was deleted.


Neville Rodrigues liked Neville Rodrigues's profile
Jun 30
Santiago Perez liked Santiago Perez's profile
Jun 21