Site Information

 Loading... Please wait...

Blog

Implementing Vehicle Telematics with Raspberry Pi and PiCAN FD HAT

Posted by Wilfried Voss on

Understanding Vehicle TelematicsUnderstanding Vehicle Telematics

Vehicle telematics refers to the integration of telecommunications and informatics technologies to collect, transmit, and analyze data from vehicles in real time. In practical terms, a telematics system in a fleet uses a combination of GPS and onboard sensors (e.g. engine diagnostics via the CAN bus) to send valuable vehicle and driver data back to a central server or cloud platform. This enables fleet operators to track vehicle locations, monitor performance (speed, fuel use, etc.), and gain insights that improve logistics and safety. Essentially, telematics is more than simple GPS tracking – it’s a comprehensive in-vehicle data monitoring method that can reveal if a truck is idling too long, identify harsh driving events, or flag maintenance issues before they become critical.

A complete telematics solution typically consists of three main components: (1) a GPS receiver for precise location tracking, (2) a telematics device (sometimes called a “black box”) that interfaces with the vehicle’s OBD-II/CAN bus and collects data (this device often plugs into the OBD-II port or CAN wiring), and (3) a communications modem (with a SIM card) that transmits the data over cellular networks to a cloud server. The telematics device gathers data like GPS coordinates, vehicle speed, engine parameters, and fault codes, then uses its cellular modem to relay that information to an online server in real time. On the cloud side, fleet management software can store and analyze this incoming data, allowing managers to view vehicle locations on a map, receive alerts (e.g. if a fault code indicates a mechanical problem), and generate reports on usage or driver behavior.

Raspberry Pi as an In-Vehicle Telematics Device

PiCAN FD with GPS/GNSS ublox NEO-M8M for Raspberry Pi with SMPS

Figure: Raspberry Pi with PiCAN FD GPS/GNSS HAT attached, providing CAN bus and GPS capabilities for a custom telematics unit. The HAT connects to the Pi’s 40-pin header and includes an SMA connector for the GPS antenna.

The Raspberry Pi single-board computer can serve as the core of a custom telematics device when paired with appropriate hardware expansions. One such expansion is the PiCAN FD with GPS/GNSS HAT by Copperhill Technologies, which is designed specifically for vehicle integration. This HAT provides a Controller Area Network (CAN) interface (including CAN-FD support) and an onboard u-blox NEO-M8M GPS/GNSS receiver, turning the Raspberry Pi into a combined data logger for engine diagnostics and GPS location. The PiCAN FD board’s CAN controller (Microchip MCP2518FD) supports both classic CAN 2.0 and CAN-FD frames, allowing it to interface with vehicle networks for reading data like speed, RPM, fuel level, and diagnostic trouble codes. Simultaneously, the integrated GNSS module can receive signals from GPS, Galileo, GLONASS, and BeiDou satellite constellations, providing accurate position and speed data even in challenging conditions (urban canyons, weak signals). The GPS antenna connects via an SMA connector on the HAT for reliable reception.

A key advantage of this HAT is that it’s designed for seamless integration with Raspberry Pi. It uses the Linux SocketCAN driver, meaning once the provided driver overlay is enabled, the CAN interface appears as a network device (can0) on the Pi. This allows developers to use standard Linux tools and libraries (in C or Python) to send/receive CAN messages. The HAT also optionally includes a 3A switch-mode power supply (SMPS) that can power both the Pi and the HAT from the vehicle’s electrical system (7V–24V input). In a vehicle installation, this means you can wire the HAT to the vehicle’s 12V (or 24V in trucks) supply and power the Raspberry Pi directly, an important feature for automotive use where a stable, regulated 5V supply is needed for the Pi. Overall, combining a Raspberry Pi with the PiCAN FD GPS HAT creates a compact telematics unit that can be connected to the vehicle’s OBD-II port or CAN wiring (via the HAT’s screw terminal or an OBD-II adapter cable) to gather engine data, while simultaneously logging GPS coordinates and time.

GPS and Engine Diagnostics Data Collection

One of the primary functions of a telematics system is collecting GPS data and engine diagnostics data. The PiCAN FD HAT’s u-blox NEO-M8M module provides standard NMEA GPS data (latitude, longitude, velocity, heading, timestamp, etc.), which can be read by the Raspberry Pi over a UART or I²C interface. In practice, you would attach a GPS antenna, enable the UART on the Pi (or use I²C as configured), and then parse NMEA sentences to obtain real-time location and speed. For example, using a library or gpsd on Raspbian Linux, the Pi can continuously read the vehicle’s coordinates and even detect events like start/stop or route deviations. Accurate GPS data is vital for fleet tracking – it allows visualization of vehicle routes, logging of mileage, and geofencing applications (knowing when a truck enters or leaves certain areas).

Equally important is the engine and vehicle data accessible via the CAN bus. In passenger cars, the OBD-II standard (mandated in the US since 1996) exposes a variety of Parameter IDs (PIDs) that can be queried over CAN (ISO 15765-4) for real-time engine metrics. Using the SocketCAN interface on the Pi, one can either passively listen to CAN broadcasts or actively request data. For instance, sending a CAN frame with ID 0x7DF (the OBD-II functional request ID) and the proper data bytes can ask the vehicle’s ECU for specific information. A concrete example is sending 7DF#0201050000000000 – this is a request for engine coolant temperature (PID 0x05). The ECU would respond on a corresponding CAN ID (0x7E8 or similar) with the temperature value. By issuing standard OBD-II queries (Mode 01 for live data) the telematics Pi can gather metrics such as vehicle speed, engine RPM, throttle position, fuel level, engine load, and coolant temperature. It can also monitor Diagnostic Trouble Codes (DTCs) via Mode 03, enabling remote detection of engine faults (e.g. if the “Check Engine” light is on). In heavy-duty vehicles that use the SAE J1939 protocol (typically on a CAN bus as well), the device can similarly read parameters like engine speed, oil temperature, fuel consumption, and so on – J1939 broadcasts many of these on the bus continuously, which the Pi could capture and interpret with the appropriate software library.

Crucially, telematics devices use this engine data to generate actionable insights. According to Geotab (a fleet telematics provider), the OBD-II port gives access to information such as engine revolutions (RPM), vehicle speed, fuel usage, and fault codes, which the telematics device can analyze to detect behaviors or conditions: e.g. identifying excessive idling time, instances of over-revving, sudden acceleration/braking events, or maintenance issues indicated by fault codes. All this data is then uploaded to the cloud platform for fleet managers to review. By combining GPS data with engine data, a Raspberry Pi-based telematics system can not only track where a vehicle is, but also how it’s being driven and its current health. For example, the system can report that Truck #5 is at a certain latitude/longitude traveling at 65 mph, with engine RPM of 2000, coolant at normal temperature, and no active fault codes. Such granular telemetry is invaluable for optimizing fleet operations – it helps in scheduling maintenance (using engine hours and fault alerts), improving driver behavior (through alerts or coaching if speeding or harsh braking is detected), and ensuring overall efficiency and safety in logistics.

Cloud Connectivity and Data Transmission

Collecting data on the Raspberry Pi is only half of the telematics equation – the other half is transmitting that data to a cloud server where it can be aggregated and accessed remotely. In mobile fleet scenarios, a cellular data connection is the most common way to connect a telematics device to the internet (since vehicles are on the move and away from fixed Wi-Fi). A typical telematics unit includes a cellular modem (often 4G/LTE based) and a SIM card for this purpose. The Raspberry Pi does not have built-in cellular capability, but it can be augmented with a Cellular HAT or modem that provides mobile network connectivity. Through this modem, the Pi can send periodic telemetry updates to cloud endpoints using protocols like HTTP(S) REST APIs, MQTT publish/subscribe, or even direct TCP/UDP sockets. The data can be sent in intervals (e.g. every few seconds for location, or immediately when a critical event like a fault code occurs) or buffered and batch-transmitted to optimize bandwidth.

When implementing cloud connectivity in the United States, it’s important to use cellular hardware that supports U.S. network bands and technologies. Modern telematics projects in the US rely on 4G LTE networks (as 2G/3G networks have been largely retired). Many IoT deployments use LTE Cat-M1 (LTE-M), a low-power LTE variant with nationwide coverage on carriers like AT&T and Verizon, or LTE Cat-1/Cat-4 for higher bandwidth needs. For instance, a cellular module might need to cover LTE bands B2, B4, B12, B13, etc., which correspond to the frequencies used by North American carriers. Manufacturers often provide region-specific modem versions – e.g. a “North America” LTE module certified for Verizon, AT&T, T-Mobile networks. Ensuring the module and SIM are compatible with U.S. carriers is crucial for reliable service. (Notably, U.S. carriers are currently emphasizing LTE-M for IoT; one major carrier, AT&T, has begun phasing out its NB-IoT network in favor of LTE-M going forward, whereas others like Verizon and T-Mobile still maintain NB-IoT at present, reflecting an industry shift toward LTE-M and upcoming 5G IoT technologies.) Once the hardware is in place, the Raspberry Pi establishes a data connection – often the cellular HAT provides a USB or serial interface for networking (PPP or ECM interface) – giving the Pi internet access. The telematics application running on the Pi can then push data to cloud endpoints. Many developers choose to use cloud IoT platforms (AWS IoT, Azure IoT, etc.) or a custom server application to ingest the telemetry. The communication is typically secured (TLS encryption) and might be optimized to consume minimal bandwidth (e.g. sending JSON payloads with essential data or using binary protocols).

To facilitate this, several off-the-shelf Raspberry Pi HATs for cellular connectivity are available. These HATs either include an integrated cellular modem or act as a carrier for one, and manage the connection (sometimes exposing a network interface on the Pi). Below are a few examples of cellular HAT options:

  • Sixfab 3G/4G LTE Base HAT: A versatile cellular add-on that provides a mini-PCIe slot for a cellular modem module. This HAT acts as a bridge between the Raspberry Pi and modems like the Quectel EC25 (LTE Cat-4) or EG91/95 (Cat-1) series. It supports a wide range of cellular standards – from low-power LTE-M to high-speed LTE-Advanced – depending on the inserted module. The Sixfab Base HAT exposes both UART and USB connections to the Pi for flexibility, and with a suitable LTE module (e.g. EC25), it can achieve up to ~150 Mbps downlink on 4G networks. This solution is ideal if you need broad carrier compatibility or upgradeability; for example, you could use a Cat-M1 module for IoT data efficiency or a Cat-4 module for faster data. (It even allows the Pi to create an LTE hotspot or handle GPS from the module if available.)

  • RAK Wireless WisLink Cellular HAT (RAK2013): A cellular IoT HAT that comes with a soldered-on modem (various configurations available, such as Quectel BG96 or EG95). It is a Raspberry Pi HAT aimed at Low Power Wide Area Network connectivity, supporting multiple standards including 4G LTE Cat-M1 (LTE-M), NB-IoT, and even Cat-1/Cat-4 fallback. For instance, with the BG96 radio option, this HAT can operate on LTE-M and NB-IoT networks and also has GNSS capability. The RAK2013 HAT is designed for IoT deployments that need nationwide coverage and low power consumption – it supports both a nano SIM and eSIM, and is certified for use with major US carriers (versions like EG95-NA are certified for Verizon, AT&T, T-Mobile, etc.). This HAT makes it relatively plug-and-play to give your Raspberry Pi cellular connectivity, and even supports Voice over LTE (VoLTE) with an integrated audio codec, should your telematics application require audio or calls.

  • Waveshare 4G HAT (SIM7600X): A ready-to-use HAT that includes a SIMCom SIM7600G-H module, which provides 4G LTE Cat-4 connectivity along with 3G/2G fallback and built-in GNSS. With this HAT attached, the Raspberry Pi can connect to 4G, 3G, or even 2G networks, as well as specialized IoT networks like NB-IoT and Cat-M1 (supported by the module). The SIM7600G-H is a Cat-4 modem, meaning it supports data rates up to ~150 Mbps downlink and 50 Mbps uplink on LTE, which is plenty for transmitting telematics data. The inclusion of GNSS means this HAT could even serve as an alternative GPS source, though in our case the PiCAN’s own GNSS suffices. This Waveshare board is a convenient all-in-one solution for adding cellular: it has the SIM slot and antennas on board, and connects via USB interface to the Pi for internet access. It even allows the Pi to send SMS or make calls, which could be used for alerts (e.g. SMS notification of critical faults).

Each of these HATs, and others like them, can equip a Raspberry Pi telematics unit with the ability to communicate over cellular networks. In the context of a fleet in the US, one would choose a HAT/module combo that matches the carrier with the best coverage for the fleet’s operating area (Verizon, AT&T, T-Mobile, etc.) and purchase IoT data SIM cards for those networks. The Raspberry Pi, once connected via the cellular HAT, would establish a data session (often using PPP or USB tethering drivers) and then periodically upload the collected GPS and CAN bus data to the cloud. This could be implemented by a custom Python script or service on the Pi that formats the data (e.g. JSON containing timestamp, lat, lon, speed, and engine metrics) and POSTs it to a web server or publishes to an MQTT topic. On the cloud side, one might have a database and web dashboard to visualize the telematics data for all fleet vehicles in real time.

Development Approach and Considerations

When developing a Raspberry Pi-based telematics system, a structured approach is key. First, set up the hardware and OS: attach the PiCAN FD HAT to the Raspberry Pi (ensuring the 40-pin header is properly connected and mounting screws/spacers are used for stability). Install Raspbian (Raspberry Pi OS) and enable the required interfaces in the firmware configuration. As outlined in the HAT’s user guide, you would activate the SPI interface and add the CAN controller overlay in /boot/config.txt (e.g. dtoverlay=mcp251xfd,spi0-0,interrupt=25) to initialize the MCP2518FD CAN controller at boot. Also enable uart if using the GPS via serial. After a reboot, the CAN interface can0 becomes available. You can then install utilities like can-utils (which provides candump, cansend, etc.) to test CAN communication. For example, running candump can0 will display any CAN traffic, confirming the HAT is receiving data. If connected to a vehicle, you should see CAN frames (if the vehicle is on) or can try sending a request as in the earlier example and observe the response.

Next, set up the software for data acquisition. For CAN bus reading and writing in code, a common choice is the Python library python-can, which works with SocketCAN interfaces. This allows your Python program to easily send CAN messages and listen for incoming frames in a high-level manner. You might write a script that periodically requests specific OBD-II PIDs (for cars) or parses broadcast messages (for trucks) and updates internal state for each metric (speed, RPM, fuel, etc.). Simultaneously, for GPS, you can either parse NMEA sentences from /dev/ttyS0 (for UART) or use a library like pynmea2 or even leverage gpsd to get structured GPS data. The PiCAN HAT’s GPS can also be read via I²C if configured, but UART is straightforward. Ensure that the GNSS has a lock (the HAT’s LED will indicate satellite fix status) before relying on location data.

With data being collected, the next step is implementing the cloud communication. This involves initializing the cellular connection via your chosen HAT. Depending on the HAT, this could be as simple as the HAT exposing a network interface (e.g. the Sixfab HAT in QMI mode or the SIM7600 via USB ECM) which you configure with DHCP, or using PPP dial-up via a serial AT command interface. Many HAT manufacturers provide setup scripts or tutorials (e.g. Sixfab’s software suite or chat scripts for PPP). Once the Pi has an active internet connection (you can verify by pinging a server or checking IP address), your telematics script can start sending data. A robust approach is to use an MQTT client on the Pi to publish messages to a cloud MQTT broker (many IoT platforms support MQTT ingest). MQTT is lightweight and well-suited for IoT data. Alternatively, you can send HTTP POST requests to a RESTful API endpoint. For reliability, you might implement buffering and retries – e.g. if the cellular signal drops, cache data on the Pi (perhaps in a local SQLite database or file) and upload it when the connection restores, to avoid data loss.

Fleet management integration: The cloud server that receives the data should be set up to aggregate data from multiple vehicles. Each Pi could include an identifier in its transmitted data (like vehicle ID or VIN). The cloud application can then present this on a dashboard. Over-the-air updates and remote configuration are also considerations – since the Raspberry Pi is essentially an in-vehicle computer, one may want to SSH into it or use a device management platform to update the software, adjust logging intervals, etc., especially when managing a fleet of many units. Security is paramount: use encryption for data in transit and secure the Pi (disable unused services, use firewalls) because telematics devices are potential cyber targets.

Finally, real-world testing is crucial. Before deploying to an entire fleet, one should test the Raspberry Pi telematics unit in a vehicle to ensure it can acquire GPS fix quickly, read CAN data correctly for that vehicle model, and maintain a steady cellular link while driving around. Logging data to an SD card during tests can help debug issues like intermittent connectivity or data format problems. Because automotive power can be noisy and ignition events can cause voltage dips, it’s wise to use a power management setup (the PiCAN HAT’s SMPS helps by providing a stable 5V). Some developers add a UPS HAT or a shutdown circuit to gracefully power off the Pi when the vehicle ignition is turned off, to avoid corrupting the SD card.

In summary, building a telematics system with a Raspberry Pi and the PiCAN FD with GPS HAT involves integrating hardware for CAN bus and GPS, writing software to collect engine and location data, and using a cellular HAT to transmit that data to the cloud. This DIY approach gives a lot of flexibility – for example, you can customize what data to log and how frequently, and tailor the cloud backend to your company’s needs. With GPS and engine diagnostics as the core focus, such a system can provide real-time fleet tracking and vehicle health monitoring. Fleet managers can see not only where each vehicle is and where it’s headed, but also get alerts if an engine problem arises or if a driver is operating outside of parameters (speeding, high RPM, etc.). By leveraging existing Raspberry Pi HATs and following automotive best practices, one can implement a powerful telematics solution for logistics and fleet management that is tuned to the networks and standards used in the United States.


Basics of Fleet Maintenance

Basics of Fleet MaintenanceBasics of Fleet Maintenance is an essential resource for anyone involved in the operation, management, or maintenance of mobile equipment. Written in a clear and accessible style, this book addresses the key challenges facing today’s fleet managers and maintenance professionals. Whether you're new to the field or a seasoned expert, you'll find practical insights and actionable guidance to improve your maintenance operations.

This comprehensive guide goes beyond theory to deliver real-world strategies and techniques for managing fleet maintenance effectively. It includes:

  • Proven checklists and self-assessments to evaluate your current practices

  • In-depth case studies illustrating successful implementation in various fleet environments

  • A curated list of 50 high-impact action items to help you quickly launch or accelerate your improvement efforts

Topics span a wide range of critical areas, including:

  • Decision support systems and data-driven planning

  • Maintenance cost control and budget optimization

  • Labor productivity and work standards

  • Facility layout and shop design

  • Inventory and parts management

  • Warranty tracking and recovery

  • Fuel and tire management

  • Leasing options and insurance strategies

In addition, the book explores the latest advancements in fleet information management systems, offering insights into how digital tools and analytics can transform your operations.

Whether you're managing a small municipal fleet or a large commercial operation, Basics of Fleet Maintenance provides the tools and knowledge you need to build a more efficient, cost-effective, and reliable fleet. More information...

I2C vs. CAN Bus: Choosing the Right Communication Protocol for Your Embedded System

In the world of embedded systems, choosing the right communication protocol can make or break your project's performance, scalability, and reliability. Among the most widely used protocols are I2C (Inter-Integrated Circuit) and CAN (Controller Area Network). Each has its own strengths, limitations, and ideal use cases—so how do you choose the right one for your [...]

Read More »


Develop Real-Time Embedded Systems Using STM32, FreeRTOS, and STM32CubeIDE

Real-time operating systems (RTOS) are the backbone of many modern embedded applications—from automotive control units and aerospace instrumentation to laboratory test systems and consumer electronics. These systems demand consistent, deterministic behavior and the ability to respond to events within strict timing constraints—all without human intervention, often for years at a time. This hands-on guide introduces you [...]

Read More »


Expanding Embedded Communication: CAN FD Shield for STM32G431 NUCLEO-G431RB

As embedded systems grow in complexity and demand faster, more reliable communication, developers turn increasingly toward advanced protocols like CAN FD (Controller Area Network with Flexible Data-rate). While classical CAN has served the automotive and industrial sectors reliably for decades, the rise of sensor-rich applications and real-time control systems calls for a modern alternative. STMicroelectronics’ [...]

Read More »


Turn Your Raspberry Pi into a Smart Marine Hub with OpenPlotter and Signal K

The world of marine electronics is evolving. Once dominated by expensive, closed systems with limited flexibility, there’s now a shift toward something more open, more personal, and—frankly—more exciting. At the heart of this movement is OpenPlotter, a Linux-based operating system tailored for Raspberry Pi computers, and Signal K, an open data standard designed to bring [...]

Read More »


The PiCAN Advantage: High-Performance CAN Interfaces for Raspberry Pi

The PiCAN series is a comprehensive line of CAN Bus interface boards (HATs) developed specifically for the Raspberry Pi platform. Designed and manufactured by Copperhill Technologies, these boards offer robust support for both Classical CAN (2.0A/B) and the more advanced CAN FD protocols. The product line is engineered to meet the diverse needs of automotive, [...]

Read More »


Mastering SAE J1939: Real-Time Simulation & Monitoring Made Easy

The SAE J1939 ECU Simulator Board by Copperhill Technologies is a high-performance, low-latency vehicle network adapter designed for SAE J1939 applications. It allows any host device with a USB COM port to monitor SAE J1939 data traffic and communicate with the SAE J1939 vehicle network. The board supports the full SAE J1939 protocol, including J1939/81 [...]

Read More »


Unlocking the Sea: Popular Applications of NMEA 2000 in Marine Systems

In the world of marine electronics, seamless communication between devices is not a luxury—it’s a necessity. Enter NMEA 2000, a marine data network standard developed by the National Marine Electronics Association (NMEA). Based on the Controller Area Network (CAN) protocol, NMEA 2000 provides a plug-and-play system that allows electronic devices to talk to each other [...]

Read More »


J1708 to J1939 Conversion Made Smarter: The Truth Behind Protocol Gateways

I regularly receive inquiries about converting from SAE J1708/J1587 to SAE J1939. Most often, the goal is to bridge old and new technologies—for example, connecting a modern J1939-based dashboard to a legacy J1708-based diesel engine. There are other scenarios, but this one comes up frequently. The logical next step is to look for a protocol [...]

Read More »


Error Reporting in SocketCAN with Specific Reference to the MCP2515 CAN Controller

SocketCAN is a set of open-source CAN drivers and a network stack, included in the Linux kernel, which allows CAN devices to be accessed via standard socket APIs. It provides a flexible and extensible framework for CAN communication, diagnostics, and application development. One powerful feature of SocketCAN is error reporting via special CAN frames, which is [...]

Read More »