Adding analog sensor to Crazyflie 2.0

Firmware/software/electronics/mechanics
Post Reply
rjbgreen107
Beginner
Posts: 1
Joined: Sat Mar 31, 2018 9:16 pm

Adding analog sensor to Crazyflie 2.0

Post by rjbgreen107 »

Hello,

I'd like to add an analog infrared proximity sensor to my Crazyflie 2.0 (https://www.sparkfun.com/products/242 if you're curious). I already have a breakout deck, and I plan on adding it to the top of the Crazyflie and using it in conjunction with my Flow deck.

The way I imagine this working is using the Deck API to periodically take an analog voltage measurement (at an interval on the order of milliseconds perhaps) and then using the Python logging library to read the value on the PC side. My question is- has any progress been made on the Arduino-like functionality for the Deck API? Is it still necessary for me to deal with freeRTOS to accomplish what I'd like to achieve? If so, could you point me to some examples? Is there any other way you think I could accomplish what I'm trying to do? All I'm trying to do is get an analog voltage measurement on the PC side at some regular interval. Thanks a lot.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Adding analog sensor to Crazyflie 2.0

Post by arnaud »

Hi,
Your plan sounds good :)

There is arduino-like functionality for the analog reading but not for the task unfortunately (not that it would be so hard to make but I never had time, if anyone is interested I would gladly help/guide with improving the deck subsystem).

For the required FreeRTOS part you can get inspiration from the zranger deck driver: https://github.com/bitcraze/crazyflie-f ... /zranger.c. Remove everything about vl53 and you will be left with an init that starts a task that runs a sensor reading loop at regular interval. The Z-ranger driver also shows how to add log variable that can be read using the log subsystem.

For the analog input, there is an easy to use arduino-like API: https://github.com/bitcraze/crazyflie-f ... k_analog.h. The analogRead(voltage) function takes one of these pin as argument: https://github.com/bitcraze/crazyflie-f ... .h#L47-L59, and will return the analog reading.
joseph83
Beginner
Posts: 2
Joined: Mon Feb 25, 2019 10:50 pm

Re: Adding analog sensor to Crazyflie 2.0

Post by joseph83 »

Hi!
This information is very useful to me.
I tried to follow these steps to get the z_ranger distance measurement.
However, there is another difficulty which is I can't find the monitor (Like Arduino monitor) to check the distance value.
Could you point me how to open the monitor or a way to check the value?

Thank you,
Post Reply