Hi Everyone,

I am looking for a way to log readings from an external custom sensor circuit with the APM logs. For hardware, I can use either the APM unit or an external Arduino to wire the sensor circuits and then read this value out into the APM. Once figuring this out, there is the additional challenge of getting this data into the APM logs in order to have precise location information for each sensor sample.

Does anyone know how I could do this???

Cheers,

Adam

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

Join diydrones

Email me when people reply –

Replies

  • I am also doing the same project can anyone help me.
  • Hi Adam, &  Everyone!

    Nice post.  I am trying something similar. but the connection is from pixhawk to an odroid xu4, mounted on a 3dr x8.  The connection is using the USB-UART cable. The odroid successfully displays voltage readings based on gas sensing..I have a CO2 sensor.

    Is there any sample code that I could refer to,  to have the drone navigate to the source of a leak (in this case CO2).

    I need to do path planning and eventual localization of a source of the gas leak.

    Any ideas ? Thank you in advance

    Thanks

  • I made it work with an i2c splitter, so you keep the magnetometer installed.

    •  Did you have to do some kind of fault checking code because there were two devices on i2c bus?

      • Now I prefer to output some APM data to my external electronic device handling sensors rather than logging sensors data to the APM logs.

        Anyway, it is the same about i2c protocol. You have to use AP_HAL::Semaphore to avoid errors.

        What is working for me is to do something like this in the user code:

         AP_HAL::Semaphore* _i2c_sem = hal.i2c->get_semaphore();

        if (!_i2c_sem->take(5))

        {
        //error check
         }

        if(hal.i2c->write(2,sizeof(DataToSend), DataToSend) !=0)
        {//gcs_send_text_P(SEVERITY_LOW,PSTR("writing error"));
        }

        _i2c_sem->give();

        The function gcs_send_text_P is nice for debugging (text only), you get the message in Mission planner last tab.

        One last thing when playing with user code before flying your copter: arm it without props, and play with it. Download dataflash logs and check PM messages about slow loops. I had an issue which was making the APM running very slow which was not good when flying...

        • Excuse me, Can data from external sensors incorporated into other applications , while flight mission took place to collect the data which is stored in the log APM ?  for example I have a program that can automatically realtime plotting external sensor data and geo tagging of logs apm
  • Hi Adam, a lot is possible if you don't mind coding it yourself. What sort of signal are you looking to monitor? What frequency do you need to record at? If you are just after a 'quick fix' then perhaps you could substitute your signal for either the voltage or current inputs currently monitored by the apm? Obviously you would have to disable any battery failsafes. If you do want to custom code a solution then you'll have to get familiar with the development tools/environment. I added the ability to log rssi to a version of arducopter, logging one of the inputs shouldn't to big a deal.
    • Hi James, I'm looking to monitor environmental conditions from small sensors wired to an Arduino. I would have about 6 different sensors outputs, so maybe PWM is the way to go? The frequency should be minimally 5 Hz. It sounds like custom code will be the way to go and I may even need a Pixhawk for the added memory space. What is everyone using currently to develop on Pixhawk's STM32F4?

      • If you are already using an Arduino to read the sensors then you could look at connecting it to the APM as an i2c slave device. The i2c port on the APM is where you attach the external magnetometer so you would need to get or make a 'Y' cable if you already use one of these (the i2c port supports connecting multiple devices in parallel, each individually addressable) There are plenty of Arduino i2c examples around on the net to follow but you can start here: http://arduino.cc/en/Tutorial/MasterReader The APM is already configured as the i2c master so you will have to code your Arduino as the slave device as in this example.

        There are already 'user hooks' set up in the APM code to allow you to run your custom code at specified intervals (1, 3.3, 10, 50 and 100 Hz loops) If you strictly need 5Hz then you will have to use the 10Hz loop and perform your operations every 2nd call. It will be up to you to decide how you are going to format the data that is transferred to the APM and how you will format it in the log.

        If you have not done so already, you should download and get familiar with the ArduXXX code and the development tools for your platform. Check out http://dev.ardupilot.com/. Once you can compile and run your own code on the APM, you will be a big step along the path to your goal. 

        If you have any further questions along the way, I am happy to help as best I can.

        • Excellent, thank you James!

This reply was deleted.

Activity

DIY Robocars via Twitter
RT @chr1sa: Just a week to go before our next @DIYRobocars race at @circuitlaunch, complete with famous Brazilian BBQ. It's free, fun for k…
17 hours ago
DIY Robocars via Twitter
How to use the new @donkey_car graphical UI to edit driving data for better training https://www.youtube.com/watch?v=J5-zHNeNebQ
Nov 28
DIY Robocars via Twitter
RT @SmallpixelCar: Wrote a program to find the light positions at @circuitlaunch. Here is the hypothesis of the light locations updating ba…
Nov 26
DIY Robocars via Twitter
RT @SmallpixelCar: Broke my @HokuyoUsa Lidar today. Luckily the non-cone localization, based on @a1k0n LightSLAM idea, works. It will help…
Nov 25
DIY Robocars via Twitter
@gclue_akira CC @NVIDIAEmbedded
Nov 23
DIY Robocars via Twitter
RT @luxonis: OAK-D PoE Autonomous Vehicle (Courtesy of zonyl in our Discord: https://discord.gg/EPsZHkg9Nx) https://t.co/PNDewvJdrb
Nov 23
DIY Robocars via Twitter
RT @f1tenth: It is getting dark and rainy on the F1TENTH racetrack in the @LGSVLSimulator. Testing out the new flood lights for the racetra…
Nov 23
DIY Robocars via Twitter
RT @JoeSpeeds: Live Now! Alex of @IndyAChallenge winning @TU_Muenchen team talking about their racing strategy and open source @OpenRobotic…
Nov 20
DIY Robocars via Twitter
RT @DAVGtech: Live NOW! Alexander Wischnewski of Indy Autonomous Challenge winning TUM team talking racing @diyrobocars @Heavy02011 @Ottawa…
Nov 20
DIY Robocars via Twitter
Incredible training performance with Donkeycar https://www.youtube.com/watch?v=9yy7ASttw04
Nov 9
DIY Robocars via Twitter
RT @JoeSpeeds: Sat Nov 6 Virtual DonkeyCar (and other cars, too) Race. So bring any car? @diyrobocars @IndyAChallenge https://t.co/nZQTff5…
Oct 31
DIY Robocars via Twitter
RT @JoeSpeeds: @chr1sa awesomely scary to see in person as our $1M robot almost clipped the walls as it spun at 140mph. But it was also awe…
Oct 29
DIY Robocars via Twitter
RT @chr1sa: Hey, @a1k0n's amazing "localize by the ceiling lights" @diyrobocars made @hackaday! It's consistently been the fastest in our…
Oct 25
DIY Robocars via Twitter
RT @IMS: It’s only fitting that @BostonDynamics Spot is waving the green flag for today’s @IndyAChallenge! Watch LIVE 👉 https://t.co/NtKnO…
Oct 23
DIY Robocars via Twitter
RT @IndyAChallenge: Congratulations to @TU_Muenchen the winners of the historic @IndyAChallenge and $1M. The first autonomous racecar comp…
Oct 23
DIY Robocars via Twitter
RT @JoeSpeeds: 🏎@TU_Muenchen #ROS 2 @EclipseCyclone #DDS #Zenoh 137mph. Saturday 10am EDT @IndyAChallenge @Twitch http://indyautonomouschallenge.com/stream
Oct 23
More…