# P1 CAN Vehicle Data

#### Items Used

* 1x [P1](https://www.macchina.cc/catalog/p1-boards/p1-under-dash)
* 1x Car with OBD-II port

#### Download P1 Vehicle Data Python Program

After connecting to P1 via SSH, run the command below to download the python program and save it to \~/scripts. (If using putty to SSH, just right click to paste!)

```
wget -P ~/scripts https://gist.githubusercontent.com/kenny-macchina/cf47daf663f9091460fc3454f5e38de9/raw/676f2a36f300fa8e5c9c43c05a7bc18af2479b5c/p1_data.py
```

![Downloading the python program](/files/-MBdsXg6Y2fBvKroH5dG)

#### Install Pip

Run the commands below to install the "Pip" package manager and reboot.

```
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
sudo reboot now
```

![Installing Pip, curl and reboot not shown.](/files/-MBeBM6Egbq-GPjrOMCY)

#### Install Python-CAN Library

Run the commands below to install the python-can library and reboot.

```
pip install python-can
sudo reboot now
```

![Installing python-can, reboot not shown.](/files/-MBeBClG2gqUeVufii_3)

#### Collecting Data

First, start your car, then plug P1 into the OBD-II port and run the data collection program using the command below. (Make sure you're in the home directory beforehand by running the command "cd".) P1 will prompt for a password as the program sets up the CAN0 bus. After entering the password data collection will begin until the program is halted by pressing CTRL-C.

```
python scripts/p1_data.py
```

![Terminal while data collection is running](/files/-MBeFexvWZz3AKtqF_30)

#### Retrieving Data

To download the CSV file from P1, the command below can be used to host an HTTP server on the port specified, this can then be visited in a web browser (from a computer on the same LAN) and the file(s) downloaded.

```
python3 -m http.server 1337
```

![Hosting the HTTP server](/files/-MBeFvlVRh_WMpX2d0vJ)

![Retrieving the file from a browser](/files/-MBeG7bEBQ8mB-Rmc2_8)

#### Example Results

![Vehicle and engine speed for a short drive around the block](/files/-MBeNJTbNzjnbtIppcuA)

![Coolant temperature from the same test drive](/files/-MBeNMyQnUQ6wm6aYnjJ)


---

# 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://docs.macchina.cc/projects/p1-projects/p1-can-vehicle-data.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.
