# RaspberryPi connect pixhawk via Mavlink
###### tags: `Drone`

## Install MAVProxy
**Install MAVproxy python tool within python3 for Linux / Ubuntu**
```
sudo apt-get install python3-dev python3-opencv python3-wxgtk4.0 python3-pip python3-matplotlib python3-lxml python3-pygame
```
```
sudo pip3 install PyYAML mavproxy --user
```
```
echo "export PATH=$PATH:$HOME/.local/bin" >> ~/.bashrc
```
* [MAVProxy document](https://ardupilot.org/mavproxy/docs/getting_started/download_and_installation.html#mavproxy-downloadinstalllinux)
## Set Serial
Open the rasberrypi configure
```
sudo raspi-config
```
select “Interfacing Options”.
Then “Serial”.
Select =="no"==.
>When prompted, select =="no"== to “Would you like a login shell to be accessible over serial?”.
>When prompted, select =="yes"== to “Would you like the serial port hardware to be enabled?”.
Reboot the Raspberry Pi when you are done.
check the serial
```
cat /boot/config.txt
```
The Raspberry Pi’s serial port will now be usable on /dev/serial0.
## Connect
>To test the RPi and flight controller are able to communicate with each other first ensure the RPi and flight controller are powered, then in a console on the RPi type:
```
sudo -s
```
```
python3 mavproxy.py --master=/dev/serial0 --baudrate 57600 --aircraft MyCopter
```
```
param show ARMING_CHECK
```
```
param set ARMING_CHECK 0
```
* [Communicating with Raspberry Pi via MAVLink](https://ardupilot.org/dev/docs/raspberry-pi-via-mavlink.html)
---
## Control Commands
* Mode list
```
mode
```
* Select the mode ( ex. STABILIZE )
```
mode STABILIZE
```
* Unlock safety button
```
arm safetyoff
```
* Lock the safetybutton
```
arm saftyon
```
* arm check
```
arm throttle
```
> * Run the mission
```
python mission.py --connect /dev/serial0
```
## Tutorial Video <i class="fa fa-youtube" aria-hidden="true"></i>
### Setting up RaPi and Pixhawk
{%youtube DGAB34fJQFc %}
### Testing with Dronekit SITL and RaPi
{%youtube 7QDb2SuUVsw %}
### Dronekit python autostart
{%youtube ELa6w6Z6mws %}
### Dronekit mission
{%youtube 2_ltk5nqWTk %}
## Reference
* [Communicating with Raspberry Pi via MAVLink](https://ardupilot.org/dev/docs/raspberry-pi-via-mavlink.html)
* [MAVProxy document](https://ardupilot.org/mavproxy/docs/getting_started/download_and_installation.html#mavproxy-downloadinstalllinux)
* [MAVlink document](https://ardupilot.org/dev/docs/mavlink-basics.html)
* [Dennis Baldwin](https://gist.github.com/dbaldwin) <i class="fa fa-github" aria-hidden="true"></i>
* [Dennis Baldwin's Video](https://www.youtube.com/user/dennisbaldwin) <i class="fa fa-youtube" aria-hidden="true"></i>
* [NXP-HoverGames Drone Ecosystem](https://www.nxp.com/applications/industrial/aerospace-and-mobile-robotics/hovergames-drone-ecosystem:HOVERGAMES-DRONE-SYSTEM)