Monitoring auto sensor data with the Raspberry Pi

The CAN Bus

CAN stands for Control Area Network. Bosch developed this bus system in 1983 for networking control devices in automobiles. In the meantime, CAN has become an ISO standard. All relevant data exchanged among the control devices are transmitted over the CAN bus of the race car (see the "Caution!" box). A CAN adapter from the Peak System company intercepts the data for telemetry. Listing  1 shows how the data looks.

Listing 1

Telemetry Data

$ ./candump can0
can0 0x713 [8] 2C EB C2 4A 65 0D EB 00
can0 0x5C4 [8] AE 65 0D 3B C2 4A 65 0D
can0 0x5C2 [8] 5A EB C2 4A EB C2 4A 30

Caution!

The race car described in this article was developed by students in an automotive engineering program. Therefore, the students know exactly what devices have been built in and connected to the CAN bus.

It is likely that your car has just such a bus, and this might in turn give you the idea of trying out the technology demonstrated here on your own set of wheels. However, you should exercise extreme caution if you feel like trying this at home.

The CAN bus is not equipped with an authentication or verification mechanism. Therefore, you can easily turn off the cooling water pump simply by using CAN messages. As a result, one single message sent in error can damage the engine or, in the worst-case scenario, lead to an accident.

It is better not to meddle with the electronics built into your vehicle if this is a car you actually use and on which you depend.

The CAN bus recognizes four different frame types: A pure data frame contains up to 8  bytes of data, a remote frame transmits data requests from a different bus participant, the error frame signals error conditions, and the overload frame makes it possible to arrange for a compulsory time out between the data and remote frames. The CAN adapter merely picks up data packets on the CAN bus passively. In other words, only the data frames like those shown in Listing  1 are of interest for that project.

The different sensor values land in one or more bytes of the CAN message depending on the resolution and effective range of the sensor. The meaning of the individual bytes of the message with ID 0x713 is shown in Table 1. Measuring signals must be collected according to priority to avoid generating different CAN messages in greater number than is absolutely necessary. This keeps the bus workload as small as possible.

Table 1

CAN Data with ID 0x713

Byte

Meaning

0

Oil pressure

4

Fuel temperature

5

Oil temperature

7

Water temperature

Hardware

You will want a powerful server for this kind of task. However, size, weight, electricity consumption, and of course price are primary considerations in the context of racing. Here, the Raspberry Pi lends itself for use almost by necessity. Consequently, in the newest race car from joanneum racing graz  [1], a Pi collects the measurement data, analyzes it, and makes it available to the pit stop team during the race.

Additional equipment includes an active USB hub, a WiFi stick, a wireless camera, a CAN USB adapter, and a UMTS stick for data transmission to the pit stop box, and of course a few cables (Figure  4).

Figure 4: The hardware components for the test set up.

Buy this article as PDF

Express-Checkout as PDF

Pages: 8

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content