# Set up Navio 2 and Raspberry Pi

![](https://3748318177-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LJGeH9CamtpOqRPgXs0%2F-LK3bOiuj73HLz1hmVv_%2F-LK3bSOAq1nUrqAlXiYI%2FNavio2_RPI.jpg?alt=media\&token=af2689a6-3a5b-40d9-8ab1-eba872652f08)

Original docs for configuring Navio 2 autopilot board:

1. [Hardware setup](https://docs.emlid.com/navio2/ardupilot/hardware-setup/)
2. [Configuring Raspberry Pi](https://docs.emlid.com/navio2/common/ardupilot/configuring-raspberry-pi/)
3. [Ardupilot installation and running](https://docs.emlid.com/navio2/ardupilot/typical-setup-schemes/)

To configure your autopilot you need your board computer to be connected to a wifi network with internet available.

## Connecting to GCS.uno

After you set up your drone and can connect with it using regular ground control software (such as QGroundControl or MissionPlanner), there are few steps left to control a drone remotely over 4G networks.

### How it works

Ardupilot is configured to stream its MAVLink telemetry messages to local (onboard) UDP port. A small script (written in JavaScript) listens to this UDP port and transmits messages to GCS.uno server. When you open GCS.uno in a web-browser, this telemetry is got from server and rendered to a screen almost in realtime. In opposite direction, you press an action button on a web-page, this magically tranforms to a MAVLink message and reaches onboard autopilot to be executed.

SSH to your board Raspberry and follow next steps.

### Configure Ardupilot

Depending on what frame you have configured using emlid-tool, the configuration file will be accordingly `arducopter`, `arduplane` or `ardurover`. Not ***`ardupilot`***! Asuming you have *arducopter*, open config file:

```
sudo nano /etc/default/arducopter 
```

Make sure these line are present or make copy-paste from here:

{% code title="/etc/default/arducopter" %}

```
TELEM1="-A udp:127.0.0.1:14550"
ARDUPILOT_OPTS="$TELEM1"
```

{% endcode %}

Save it with `Ctrl+X`, `y` and restart Ardupilot

```bash
sudo systemctl daemon-reload
sudo systemctl restart arducopter
```

Check status

```bash
sudo systemctl status arducopter
```

It should be active and running:

![](https://3748318177-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LJGeH9CamtpOqRPgXs0%2F-LK2KYyFKhKiqcQ-g0kz%2F-LK2KfDHKNarRL4L6LAp%2Fassets--L9vrI9jkeVxY5zqfnJW--LA-rXkR_Nrogc3075rK--LA8Ov_0ApEv4IQ8D97B-%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202018-04-15%20%D0%B2%2016.02.57.png?alt=media\&token=b0e39cda-5c40-4dd5-9e74-34049f0c176e)

### Check MAVProxy

MAVProxy is used to be able to connect to autopilot using desktop GCS (over onboard or local WiFi) and our web-based GCS simultaneously. It is already installed in Emlid Raspbian image, just check it:

```bash
mavproxy.py --master=udp:127.0.0.1:14550 --out=tcpin:0.0.0.0:5762
```

It should looks like this:

![](https://3748318177-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LJGeH9CamtpOqRPgXs0%2F-LK2KYyFKhKiqcQ-g0kz%2F-LK2Kr3WSfGHOW6GgDGy%2Fassets--L9vrI9jkeVxY5zqfnJW--LA-rXkR_Nrogc3075rK--LA8VbQxvBXx3bU5G7pd-%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202018-04-15%20%D0%B2%2016.30.56.png?alt=media\&token=82b0d880-0459-4369-ab78-540f46ed4eb7)

`Ctrl+C` to exit.

### Video streaming

GCS.uno has a video server which can be used to stream realtime RTSP video to your web-based dashboard. Next steps describe how to configure onboard Raspicam camera module.

```bash
sudo apt-get update
sudo apt-get install autoconf automake libtool pkg-config libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libraspberrypi-dev gstreamer1.0-tools gstreamer1.0-plugins-good gstreamer1.0-plugins-bad
```

If you have dependency warnings, try to solve them using following commands:

```
sudo apt-get install --fix-broken --assume-yes
sudo apt-get autoremove
sudo apt-get install -f && sudo dpkg --configure -a
```

CD to your home dir and clone gst-rpicamsrc (this is a GStreamer wrapper around the raspivid/raspistill functionality of the RaspberryPi):

```
cd
git clone https://github.com/GCS-uno/gst-rpicamsrc.git
```

Compile it:

```bash
cd rpicamsrc
chmod +x autogen.sh
./autogen.sh --prefix=/usr --libdir=/usr/lib/arm-linux-gnueabihf/
make
sudo make install
```

Test it with Raspicam connected:

```
gst-launch-1.0 rpicamsrc bitrate=1000000 ! filesink location=test.h264
```

Ctrl+C after 10 seconds and check if file `test.h264` exists and readable. Configuration of video streaming to GCS.uno servers is described in the next steps.

### Install additional dependencies

#### NodeJS

```bash
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs build-essential
```

#### PM2 process manager

```bash
sudo npm install pm2 -g
```

### Download and install board scripts

```
cd
git clone https://github.com/GCS-uno/drone_board.git
cd drone_board
npm install
```

Inside `drone_board` directory you can find two shell scripts `mavproxy.sh` and `video.sh` which help running MAVProxy and video streaming. If you are sure not to use them, just skip to next step, otherwise make them executable:

```
chmod +x mavproxy.sh
chmod +x video.sh
```

### Get your drone keys

Sign in to your [GCS.uno dashboard](https://pilot.gcs.uno/), add new drone and get its MAVLink and Video keys.&#x20;

![](https://3748318177-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LJGeH9CamtpOqRPgXs0%2F-LK2Qczd9zlbSlHTGks7%2F-LK2Qh4MRLu-L4lGaY7i%2Fget_drone_keys.png?alt=media\&token=8cb615f5-2578-4a46-a319-4eda05edbe52)

Then put them in following commands to be readable by scripts. For MAVLink key (replace `abcd1234` with one copied from dashboard):

```
DRONE_MAVLINK_KEY=abcd1234; echo "export DRONE_MAVLINK_KEY=$DRONE_MAVLINK_KEY" >>~/.bash_profile && source ~/.bash_profile
```

The same for Video key (replace `abcd1234`):

```
DRONE_VIDEO_KEY=abcd1234; echo "export DRONE_VIDEO_KEY=$DRONE_VIDEO_KEY" >>~/.bash_profile && source ~/.bash_profile
```

### Start board scripts

Check MAVProxy script:

```bash
./mavproxy.sh
```

�If it looks good `Ctrl+C` to exit and then run it in background with PM2 process manager:

```bash
pm2 start mavproxy.sh --name mavproxy
```

�Now run `drone.js` to check connection with GCS.uno server:

```bash
node drone  
```

If it reports that connection is established, `Ctrl+C` to stop and run it again with PM2:

```
pm2 start drone.js --name drone
```

And finally start script for video streaming:

```bash
pm2 start video.sh --name video
```

#### Enable scripts to start on system boot

Enable PM2 to start on boot:

```
pm2 startup
```

This will prompt a `sudo` command which must be copied and executed to enable autostart. Then save list of active processes:

```
pm2 save
```

And check it:

```
pm2 list
```

Now check your GCS.uno dashboard, you can see you drone's telemetry streaming.

### Connect USB 4G modem

![](https://3748318177-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LJGeH9CamtpOqRPgXs0%2F-LK6h3eCFkbab56Sbejt%2F-LK6h80zl1srIhpE3Xgp%2FHTB16dHwQVXXXXXJapXXq6xXFXXXv.jpg?alt=media\&token=6f0b1774-bff4-422b-8e77-7a1390d2d437)

Almost all 4G modems work fine with Raspberry Pi computers without any additional configuration. Just check if you have SIM-card with enabled 4G internet option. Otherwise look into modem's manual to find out how to use it with Linux-based systems.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gcs.gitbook.io/uno/setup_navio2_guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
