Car Rev Alarm and Gear Indicator

Having had a Toyota GT86 for a while I quite enjoyed the built-in rev alarm and winding the engine all the way round, until an old lady made it an insurance write off. Though, I did have the luxury of driving a BMW 430d M Sport hire car from my insurance for a few months. I now have a 2006 Honda Civic Type-S GT hatchback, and really miss that alarm (and the rest of the 86, really).

So… lets make a DIY rev alarm! Using an Arduino and a cheap MCP2515 module I sniffed the traffic between an ELM327 diagnostics tool and the Civics OBD-II port. I found that the CAN bus runs at 500Kbps, and spews out a lot of standard 11-bit ID CAN messages. By issuing the ‘010c’ command to the ELM327 to request the engine RPM parameter I saw that it was sending extended 29-bit CAN messages with an ID of 0x18DB33F1, and that replies had an ID of 0x18DAF110 (I won’t be going into specifics about the OBD-II protocol regarding physical and functional addressing here, googling the two hex numbers returns some interesting results). Great! That was all I needed to get the project started.

Sample capture output

Standard ID: 0x3F8       DLC: 8  Data: 0x00 0x00 0x00 0x00 0x02 0x20 0x19 0x44
Standard ID: 0x164       DLC: 8  Data: 0x04 0x00 0x00 0x38 0x7B 0x00 0x00 0x84
Standard ID: 0x0D0       DLC: 7  Data: 0x00 0x00 0x00 0x00 0x00 0x00 0x29
Extended ID: 0x18DB33F1  DLC: 8  Data: 0x02 0x01 0x0C 0x00 0x00 0x00 0x00 0x00
Extended ID: 0x18DAF110  DLC: 8  Data: 0x04 0x41 0x0C 0x0B 0xE4 0x55 0x55 0x55
Standard ID: 0x13F       DLC: 8  Data: 0x01 0x2E 0x01 0x22 0x00 0x00 0x00 0x0F
Standard ID: 0x0D0       DLC: 7  Data: 0x00 0x00 0x00 0x00 0x00 0x00 0x38
Standard ID: 0x294       DLC: 8  Data: 0x00 0x16 0x00 0x02 0x8D 0x52 0x00 0x04

The rev alarm plugs into the vehicles OBD-II port, and contains an RT6200 buck regulator to drop the cars 12V down to around 5V, which is used to power the ATmega328P microcontroller, MCP2515 CAN controller and MCP2561 CAN transceiver.

The Arduino platform and this MCP2515 library were used to code up the device. The alarm trigger point is set by revving the engine to the desired RPM and pressing the button on the right. The 7 segment display can cycle between displaying the selected gear, RPM to the nearest 1000 or nothing by pressing the left button. The display brightness is automatically adjusted with the help of an LDR.

Since there are no selected gear parameters in the standard OBD PIDs I had to instead work it out from the engine RPM, vehicle speed, wheel circumference and gear ratios. This unfortunately means that the gear ratios and wheel circumference need to be reprogrammed whenever the device is to be used in a different vehicle. Also any inaccuracies with the vehicles speedometer, tyre wear and pressure can throw off the calculations at lower speeds (generally less than 20MPH) so some fine tuning may be required, though this is easily done by adjusting the wheel circumference setting until the gear display is stable. For my Civic I had to reduce the wheel circumference setting by 4%.

As the OBD port is always powered, even when the vehicle is off, the usual low power sleep features had to be coded in so the car doesn’t end up with a dead battery. Most of the electronics in the rev alarm draw no more than 70uA in sleep, however the buck regulator draws around 2.7mA. This is a little higher than I was hoping for, but it’s still low enough not to drain the battery for a long time.

The Arduino code and various other things are available on the GitHub repo.

10 comments

Skip to comment form

    • Tom on January 9, 2018 at 10:58 am
    • Reply

    I currently use a “Garmin ecoRoute HD Vehicle Diagnostics Communicator HD” Bluetooth interface with my Garmin GPS Unit.
    Do U think that I can share (Use at the same time, pin’s 6 & 14), on my Civics OBD-II port, with the “Car Rev Alarm and Gear Indicator” and my current GPS interface connected, with both being able to consist with each other?

    Are these the pins of the OBD-II port that U are using?
    Pin
    1 = •PIN 16 – Unswitched Vehicle Battery Positive
    2 = •PIN 6 – SAE J2284 (CAN High)
    3 = •PIN 14 – SAE J2284 (CAN Low)
    4 = •PIN 5 – Chassis Ground

    Thks for this great project
    Tom

    1. Hey Tom, yea the CAN bus can have multiple nodes connected at once. Your Bluetooth adapter and the rev alarm can both share those same 4 pins (16, 6, 14 and 5) in the OBD-II port.

    • Tom Cobb on January 9, 2018 at 9:04 pm
    • Reply

    Zak
    Thks for Your Fast Reply!
    Can You off-hand, tell me, what the fuse setting are, that needed to be set, when loading the optiboot.hex file?

    Thks Again
    Tom

    1. Fuse settings are in the README.md of the firmware folder:
      Low: 0x62
      High: 0xDE
      Extended: 0xFD

        • Tom Cobb on January 9, 2018 at 11:27 pm
        • Reply

        Zak
        Now, I’ll See if I can get all the parts and get It all Together & Working!

        I’ll let U know, How It all goes

        Thks
        Tom

          • Tom Cobb on March 3, 2018 at 5:12 pm
          • Reply

          Zak
          I have gotten the hardware built.

          I’m having a problem getting revAlarm.ino to compile.

          I am getting this error:
          revAlarm:262: error: ‘class MCP_CAN’ has no member named ‘setSleepWakeup’
          CAN0.setSleepWakeup(1);

          I googled “CAN0.setSleepWakeup(” and found your “Improved sleep functionality #10” mods.

          So, I’m currently working on making the changes to my downloaded MCP_CAN_lib files.

          Is there a way to download MCP_CAN_lib with your mods already in them?
          Thks for making your project public!
          Tom

          1. Hey Tom, my modified MCP lib can be found here – https://github.com/zkemble/MCP_CAN_lib

            • Tom Cobb on March 3, 2018 at 7:52 pm

            Zak
            I haven’t tried it the car, but
            I can cycle from “Blank” to “-” to “Zero” with beeps
            and the Led Display can change it’s brightest
            and with the “Serial_Enabled 1” It says
            “Entering Configuration Mode Successful!”
            “Setting Baudrate Successful!”
            “MCP2515 Initialized Successfully!”
            “Setting Mask Successfully!”
            ….
            and ends in “SLEEP”

            I’m Very Happy, So far
            I will try it in the Car, later today or tomorrow.

            Zak

            Do you think that WHEEL_CIRCUMFERENCE setting is likely to need to changed (tweaked) when I replacing my worn-out and new tires.
            I currently have 22k miles on current tires.
            Thks
            Tom

    • Tom Cobb on March 3, 2018 at 11:33 pm
    • Reply

    Zak
    I was thinking about maybe, adding a 4 mode, that could be used, to adjust and then save the Wheel_Circumference by up to + or -9%, So that the firmware wouldn’t need to be recompiled and reprogrammed, to the device, as the tires wear, and then again, when the tires have to be renewed.

    Have you, needed to change (adjust) the Wheel_Circumference setting from your -4% adjustment as your tires have worn?

    Thks Again
    Tom

    1. I changed my tyres when they were at around 2mm tread, the new ones were at 8mm and I didn’t need to recalibrate the wheel circumference. I was thinking about a calibration mode where it asks you to go various speeds in each gear so it can work out the gear ratios and everything, then it’ll work in different cars without having to recompile, but it was going to be too much work for no gain since I don’t change cars every week. xd

Leave a Reply

Your email address will not be published.

Are you human? *