Macchina Docs
  • Macchina.cc
  • Introduction
    • Disclaimer
  • Product Documentation
    • M2 Docs
      • Getting Started
      • Arduino IDE Quick Start
      • M2 Code libraries
        • CAN bus
        • Single-wire CAN
        • LIN
      • Next Steps with M2
      • Detailed Reference
        • Installation
        • Processor
        • Pin Mapping
        • Automotive Interfaces
        • Communication
          • M2 Bee-Compatible Add-ons
          • Cellular
        • Power
        • Storage/Memory
        • 12V IO
        • LEDS/Buttons
        • Enclosures
        • Breakout Board
        • Schematics and Source
      • Versions of M2
    • A0 Docs
      • Quick Start Guide
      • Firmware Reference
      • Hardware Reference
      • Projects
      • Troubleshooting
    • SuperB Docs
      • Getting Started
      • Hardware
      • Sending AT Commands
    • P1 Docs
      • Getting Started
      • Pin Mapping
      • Interfaces
      • Power Supply Note
    • OBD3way Docs
  • Projects
    • A0 Projects
      • A0 CAN Vehicle Data
      • A0 CAN Point to Point
      • A0 CAN Read VIN
      • Work-in-Progress A0 projects
    • M2 Projects
      • "OK Google, start my car!"
      • M2 and SavvyCAN, the Basics
      • Help Collect Voltage Data
      • Mini-Project Tutorials
        • M2 CAN Loopback
        • M2 CAN Point to Point
        • M2 SWCAN Point to Point
        • M2 VIN Extraction
    • P1 Projects
      • P1 CAN Vehicle Data
      • P1 CAN Loopback
    • Community Projects
    • Project Support
    • Other Resources
  • Support /contact us
    • Contact US / FAQ
    • Common Issues
    • Out of Stock/ Status
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. Projects
  2. P1 Projects

P1 CAN Vehicle Data

Use P1 to read vehicle data and export it to a CSV file.

PreviousP1 ProjectsNextP1 CAN Loopback

Last updated 4 years ago

Was this helpful?

Items Used

  • 1x

  • 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

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

Install Python-CAN Library

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

pip install python-can
sudo reboot now

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

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

Example Results

P1
Downloading the python program
Installing Pip, curl and reboot not shown.
Installing python-can, reboot not shown.
Terminal while data collection is running
Hosting the HTTP server
Retrieving the file from a browser
Vehicle and engine speed for a short drive around the block
Coolant temperature from the same test drive