Page 1 of 1

Accessing analog sensor data through Python API

Posted: Mon Dec 30, 2013 9:03 pm
by gtmtg
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!

Re: Accessing analog sensor data through Python API

Posted: Fri Jan 03, 2014 8:27 am
by marcus
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.

Re: Accessing analog sensor data through Python API

Posted: Sat Feb 08, 2014 11:24 pm
by gtmtg
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!