Accessing analog sensor data through Python API

Firmware/software/electronics/mechanics
Post Reply
gtmtg
Beginner
Posts: 5
Joined: Mon Dec 30, 2013 8:54 pm

Accessing analog sensor data through Python API

Post by gtmtg » Mon Dec 30, 2013 9:03 pm

Hi,

I'm trying to use an analog distance sensor with my CrazyFlie. For reference, it's a Sharp GP2Y0A21YK0F sensor. Would it be possible for me to access the sensor data (from the ADC pins on the expansion header) through the Python API? I'm thinking I would need to add a log variable--how would I start?

Thanks in advance!

marcus
Bitcraze
Posts: 599
Joined: Mon Jan 28, 2013 7:02 pm
Location: Sweden
Contact:

Re: Accessing analog sensor data through Python API

Post by marcus » Fri Jan 03, 2014 8:27 am

gtmtg wrote:Hi,

I'm trying to use an analog distance sensor with my CrazyFlie. For reference, it's a Sharp GP2Y0A21YK0F sensor. Would it be possible for me to access the sensor data (from the ADC pins on the expansion header) through the Python API? I'm thinking I would need to add a log variable--how would I start?

Thanks in advance!
Hi!

Yes, you can use the logging framework for this. Implement the support for reading the sensor and store the value in a variable that you add to the logging. There's more information on how to do this on the wiki. There's two things to note though: You have to wait until you are connected to the Crazyflie to start the logging (since it needs to verify that the variable is in the TOC) and the API for creating the log configuration has changed somewhat in the latest version of the repository and the documentation hasn't been updated yet. Have a look at this this merge to see the differences.

gtmtg
Beginner
Posts: 5
Joined: Mon Dec 30, 2013 8:54 pm

Re: Accessing analog sensor data through Python API

Post by gtmtg » Sat Feb 08, 2014 11:24 pm

Hi Marcus,

Thanks, though I had already found that and was looking more for some examples of the type of firmware modificaitons that I would have to do. No worries, though, as I've found what I need; I was able to add the reading/logging into the ADC task.

Thanks again!

Post Reply