Are you fascinated by the intricate data flowing within your vehicle and eager to tap into it? This project guide will walk you through building a sophisticated car telematics device, “ChupaCarBrah,” leveraging the power of the Beaglebone Blue and the OBD2 port. We’ll delve into accessing real-time car data, including speed, engine RPM, and temperature, and even incorporate GPS and cellular connectivity for remote monitoring. This comprehensive guide expands upon the original project, providing enhanced clarity and SEO optimization for English-speaking automotive tech enthusiasts.
ChupaCarBrah: Your DIY Car Spy Device
Imagine a compact device that plugs into your car’s OBD2 port, silently gathering data and transmitting it to you remotely. That’s ChupaCarBrah. This project combines readily available components with the versatile Beaglebone Blue to create a powerful tool for car diagnostics, data logging, and even remote vehicle monitoring.
Image: ChupaCarBrah device installed in a vehicle, demonstrating its application for on-road data collection.
Parts List: Gathering Your Components
To embark on this Beaglebone Obd2 adventure, you’ll need the following components. These are easily sourced online and represent the core of your ChupaCarBrah device.
Image: A detailed view of the components required for building ChupaCarBrah, including Beaglebone Blue, OBD2 connector, GPS module, cellular modem, and wiring.
- Beaglebone Blue: The brain of your operation, providing the processing power and interfaces needed.
- OBDII Connector (Female): To interface directly with your vehicle’s diagnostic port.
- CAN Bus Transceiver (Integrated in Beaglebone Blue): Enables communication over the car’s Controller Area Network.
- GPS Module: For accurate location tracking.
- Cellular Modem (USB): Provides internet connectivity for remote data transmission.
- JST/SH Connector: To connect wires to the Beaglebone Blue CAN interface.
- Hook-up Wires (Colored): For organized and easily identifiable wiring.
- DC Barrel Jack Adapter: To power the Beaglebone from the OBD2 port.
- Plastic Cover Plate: As a base to mount the components.
- Rubber Bands: For securing components (alternative mounting options can be considered for a more robust build).
Assembly Guide: Building ChupaCarBrah Step-by-Step
Let’s assemble ChupaCarBrah. This process involves simple wiring and component mounting, requiring no specialized tools.
Wiring and Connections
Color-coded wires simplify the wiring process. Adhering to a standard color scheme, as recommended, reduces errors and makes troubleshooting easier.
- Black: Ground (GND)
- Red: Voltage Common Collector (VCC) – in this setup, red wire is not used for OBD2 connection.
- Yellow: CAN High (CAN Hi)
- Green: CAN Low (CAN Lo)
Refer to the Beaglebone Blue pinout diagram to identify the CAN bus connector pins. A JST/SH connector is used to interface with the Beaglebone’s CAN slot.
Image: Pinout diagram of the Beaglebone Blue, highlighting the CAN bus interface and relevant pins for connection.
-
JST/SH Connector to Beaglebone Blue: Connect the JST/SH connector to the CAN slot on the Beaglebone Blue. This provides a convenient interface for your hook-up wires.
Image: Close-up view of the JST/SH connector being attached to the Beaglebone Blue’s CAN interface slot.
-
Hook-up Wires to JST/SH Connector: Connect the hook-up wires to the female side of the JST/SH connector. Ensure you match the colors according to your chosen standard. The example uses:
- Black (GND): JST/SH black
- Yellow (CAN Hi): JST/SH yellow
- Green (CAN Lo): JST/SH white
Image: Connecting individual hook-up wires to the female JST/SH connector, preparing it for OBD2 interface.
-
Power Connection via DC Barrel Jack Adapter: Power will be supplied via the OBD2 port. Use the DC Barrel Jack Adapter to connect to the Beaglebone’s 12V input. Connect two black hook-up wires to the negative (-) terminal of the adapter and one red wire to the positive (+) terminal. This splits the ground connection for OBD2 and power.
Image: Detail of the DC Barrel Jack Adapter with hook-up wires connected, showing the split ground connection and positive power lead.
Image: Another view of the DC Barrel Jack Adapter, emphasizing the single red wire connected to the positive terminal for power input.
Image: The DC Barrel Jack Adapter plugged into the Beaglebone Blue’s power input jack, ready to receive power from the OBD2 connector.
-
OBDII Connector Wiring: Consult your vehicle’s manual for the precise OBD2 port pinout. Standard OBD2 pin assignments are commonly:
- Pin 5: Signal Ground (GND)
- Pin 6: CAN High (CAN Hi)
- Pin 14: CAN Low (CAN Lo)
- Pin 16: 12V Power
Image: Standard OBDII connector pinout diagram, clearly labeling power, ground, and CAN bus communication pins.
Connect the hook-up wires to the female OBDII connector according to your color code:
- Black wire to OBDII Pin 5 (GND)
- Yellow wire to OBDII Pin 6 (CAN Hi)
- Green wire to OBDII Pin 14 (CAN Lo)
- Red wire to OBDII Pin 16 (12V)
Image: Hook-up wires connected to the female OBDII connector, completing the physical interface for vehicle data access.
Adding GPS and Cellular Connectivity
For a complete ChupaCarBrah, integrate GPS and cellular modem. GPS provides location data, and the cellular modem enables remote data transmission. A battery is optional but recommended for continuous operation even if the car battery is disconnected.
-
GPS Module Connection: Connect the GPS module to the UART GPS slot on the Beaglebone Blue. This utilizes the serial communication interface for GPS data.
Image: Close-up of the Beaglebone Blue showing the UART GPS slot and the GPS module connected to it.
-
Cellular Modem Connection: Plug the USB cellular modem into the USB port on the Beaglebone Blue. Ensure a valid SIM card is inserted into the modem for cellular network access.
Image: USB cellular modem with a SIM card inserted, connected to the Beaglebone Blue’s USB port for internet connectivity.
Mounting and Securing Components
A clean and secure assembly is crucial. Use a plastic plate or similar insulated material as a base.
-
Beaglebone Mounting: Attach the Beaglebone Blue to the plastic plate. Drill holes as needed to align with the Beaglebone mounting holes.
Image: A plastic plate with drilled holes prepared for mounting the Beaglebone Blue and other components.
-
Component Placement: Position the GPS module and battery (if used) on the bottom side of the plate for better signal reception and weight distribution.
Image: GPS module and battery placed on the underside of the mounting plate, demonstrating component arrangement for protection and balance.
-
Securing with Rubber Bands: Use rubber bands to secure the OBDII cable and all components to the plastic plate. Ensure wires are neatly arranged and connections are secure. For a more permanent solution, consider using zip ties or a custom enclosure.
Image: Rubber bands being used to secure the OBDII cable and battery to the mounting plate, illustrating a simple method for component fixation.
Image: Additional rubber bands securing the hook-up wires to the OBDII connector, ensuring robust and reliable electrical connections.
-
Battery Connection: Finally, connect the battery to the Beaglebone Blue to power the device. ChupaCarBrah is now assembled!
Image: Connecting the battery to the Beaglebone Blue, powering up the completed ChupaCarBrah device.
Software Setup: Interacting with Your Car’s Data
With the hardware assembled, let’s configure the software on the Beaglebone Blue to access and process car data.
CAN Bus Communication with can-utils
can-utils
is a powerful suite of command-line tools for interacting with the CAN bus.
-
Access Beaglebone Blue: Power on your Beaglebone Blue and connect to it via WiFi. Ensure it’s connected to a network for internet access during software installation.
-
Update and Upgrade Packages: Open a terminal and run the following commands to update the package lists and upgrade existing packages:
sudo apt-get update sudo apt-get upgrade
-
Install can-utils: Install
can-utils
using apt:sudo apt-get install can-utils
-
Verify can0 Interface: Check if the
can0
interface is available and initially disabled:sudo ifconfig can0
The output should resemble:
can0: flags=128<NOARP> mtu 16 unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 10 (UNSPEC) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 43
If
can0
is up, disable it:sudo ifconfig can0 down
-
Connect to OBDII Port: Connect ChupaCarBrah to your car’s OBDII port (typically located under the dashboard near the steering wheel).
Image: ChupaCarBrah device being plugged into a vehicle’s OBDII port, establishing the data communication link.
Image: ChupaCarBrah discreetly installed and hidden within the vehicle’s dashboard after connection to the OBDII port.
-
Bring Up can0 Interface: Turn your car’s ignition ON (you may start the engine to prevent battery drain). Set the CAN bus bitrate (typically 500kbps for OBD2) and bring up the
can0
interface:sudo ip link set can0 up type can bitrate 500000 sudo ifconfig can0 up sudo ifconfig can0
The output should now show
<UP>
in the flags, indicating the interface is active:can0: flags=193<UP,NOARP> mtu 16 unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 10 (UNSPEC) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 43
-
Capture CAN Data with candump: Open a new terminal session and use
candump
to observe CAN messages:sudo candump can0
You might see a stream of CAN messages. If your vehicle’s CAN bus is quiet by default, you may need to send a request to elicit responses.
-
Send CAN Messages with cansend: Use
cansend
to send an OBD2 request for the vehicle identification number (VIN):sudo cansend can0 7DF#0209020000000000
In the
candump
terminal, you should see the request and the vehicle’s response, including VIN data.
Python CAN Interface with python-can
For more programmatic CAN bus interaction, use the python-can
library.
-
Install python-can: Install the
python-can
library using pip:sudo python3 -m pip install python-can
-
Run get_vin.py: Use the provided Python script
get_vin.py
(available in the original article’s GitHub repository or similar online resource) to retrieve the VIN:sudo python3 get_vin.py
This script sends a CAN message to request the VIN and prints the response. Modify
service_int
andpid_int
variables in the script to explore other OBD2 PIDs (Parameter IDs) as documented in the OBD-II PID specification.
GPS Data Retrieval
Accessing GPS data is straightforward using serial communication.
-
Test GPS Module with tio: Use the
tio
serial terminal program to read raw GPS data:tio /dev/ttyO2 -b 4800
You should see a stream of NMEA sentences. Press
Ctrl-t q
to exittio
. -
Process GPS Data with get_gps_data.py: Run the
get_gps_data.py
Python script (available in the original article’s repository) to extract and print the GPRMC sentence, which contains location information:sudo python3 get_gps_data.py
Decode the GPRMC sentence using an online NMEA decoder to visualize your location on a map.
Image: GPS coordinates decoded and plotted on a map, showing the accuracy of the GPS module integrated with ChupaCarBrah.
Cellular Network Connectivity with Hologram
Enable remote data transmission using a cellular modem and a service like Hologram.io.
-
Install ppp and hologram-python: Install the Point-to-Point Protocol (ppp) and the Hologram Python SDK:
sudo apt-get install ppp sudo python3 -m pip install hologram-python
-
Hologram SIM Activation: Activate your Hologram SIM card and subscribe to a data plan as per Hologram’s documentation.
-
Connect to Cellular Network: Use the Hologram command-line tool to connect to the cellular network:
sudo hologram network connect
Verify connection by pinging Google:
ping -c 1 www.google.com
-
Cellular Connection Test with cellular_test.py: Run the
cellular_test.py
Python script (available in the original article’s repository) to programmatically connect and disconnect from the cellular network and test internet connectivity:sudo python3 cellular_test.py
Image: Hologram cellular modem with LEDs indicating network connectivity status – blue LED solid and red LED blinking.
ChupaCarBrah Python Application: Data Exfiltration
Combine CAN, GPS, and cellular functionalities into a single Python application for data exfiltration to a remote server.
Client Script (chupacarbrah.py)
The chupacarbrah.py
client script (available on the project’s GitHub repository) reads OBD2 PIDs from a CSV file, retrieves CAN data, GPS coordinates, and transmits everything to a server.
-
Clone Repository: Clone the ChupaCarBrah client script repository to your Beaglebone:
git clone https://github.com/blupants/chupacarbrah.git cd chupacarbrah
-
Configuration: Modify the
chupacarbrah.py
script:obd2_csv_file
: Specify the CSV file containing OBD2 PIDs to monitor (e.g.,simple.csv
orobd2_std_PIDs_enabled.csv
).server_url
: Set the URL of your remote server (AWS Flask app, as detailed below).
-
Run Client Script: Start the client script:
sudo python3 chupacarbrah.py
The script will periodically collect car data and GPS information and send it to the specified server URL. To stop the script gracefully, create a
/tmp/stop
file:sudo touch /tmp/stop
Server Script (chupacarbrah_server.py) and AWS Deployment
The chupacarbrah_server.py
Flask server application (available on the project’s GitHub repository) receives data from the client and provides endpoints to view the collected data.
-
Local Flask Server Setup (for testing):
- Create a project directory
eb-flask
. - Create a virtual environment
virt
. - Activate the virtual environment.
- Install Flask (
pip install flask==1.0.2
). - Save dependencies to
requirements.txt
(pip freeze > requirements.txt
). - Download
chupacarbrah_server.py
and rename it toapplication.py
in theeb-flask
directory. - Run the Flask app locally:
python3 application.py
. - Test with
curl
to post dummy data tohttp://localhost:5000/api/v1/cars
and view data athttp://localhost:5000/api/v1/status
.
- Create a project directory
-
AWS Deployment:
- Create an AWS account.
- Install AWS CLI and EB CLI (
pip install awscli awsebcli
). - Initialize EB CLI:
eb init -p python-3.6 flask-chupacarbrah --region us-east-2
. - Configure SSH keypair (optional but recommended):
eb init
. - Create an environment and deploy:
eb create chupacarbrah-env
. - Open the AWS application URL:
eb open
. - Update
server_url
inchupacarbrah.py
with your AWS app URL.
Now your ChupaCarBrah device is capable of collecting and remotely transmitting vehicle data to your AWS server, opening up possibilities for car hacking and telematics applications. Explore further write-ups on car hacking to delve deeper into the potential of this device.