How to configure the uart interface and use easily

Firmware/software/electronics/mechanics
Post Reply
NickCong
Beginner
Posts: 29
Joined: Sun Oct 15, 2017 12:24 pm

How to configure the uart interface and use easily

Post by NickCong »

Hi Bitcraze:
i want to mount sensors to CF2, the sensor need communicate with CF2 by uart , i know the CF2 have uart1 and uart2 let me use,but i don't know how to configure the uart,and don't know which function can i use,and which folder/file can i write my code(it is run the RTOS, i dont't know where to create my task ).i try to comprehend the crazyflie-fireware, but it is too complicate to me do modify it.
so what should i do (eg. which function can i use) can let the CF2 receive the sensor's date and then send the date to the host computer.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: How to configure the uart interface and use easily

Post by arnaud »

Hi,

You can make a deck driver and there is a pretty easy API to use the UART of the expansion port.

For example I recently played with a vive/lighthouse receiver implemented in a Teensy, I connected the UART of the teensy to the expansion port UART1 and this code allowed me to interface it: https://gist.github.com/ataffanel/38890 ... 058dab4471. The position I got from the teensy are accessible to the computer in log variables (at the bottom).

Not all the includes might be required (I started from a copy-paste of one of the GPS driver ...) but hopefully this should give you a good starting point.
NickCong
Beginner
Posts: 29
Joined: Sun Oct 15, 2017 12:24 pm

Re: How to configure the uart interface and use easily

Post by NickCong »

ok, thank you ,i will try it, i find out my sensor need +4~8V power,but the vcc of CF2.0 only around +3.3V,so can you give me advice to solve it?
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: How to configure the uart interface and use easily

Post by arnaud »

You can use a separate battery, or use a step-up power supply. We have already used a step-up for an fpv setup and it worked well. Though, the exact solution depends of your sensor, for instance how clean the power supply has to be.

Be careful that IO of the Crazyflie are 3.3V. So you also need voltage-translation electronic for the data lines. For the line from your sensor to the Crazyflie it could be as simple as 2 resistor to make a voltage divider, but it must be there.
Post Reply