Skip to content

two-7/openCAN

Repository files navigation

openCAN

openCAN is an open source firmware platform for working with vehicle CAN bus networks. It can sit on the bus as a node, reading and injecting messages, or inline as a man-in-the-middle, filtering and rewriting traffic in real time. Built on the 32-bit SAMD21, programmable through the Arduino IDE, with fully open source firmware.

🔧 Hardware Features

  • ✅ 8 Digital Outputs
  • ✅ 6 Analog Inputs
  • ✅ Dual MCP2515 CAN Controllers
  • ✅ 32-bit Microcontroller (ATSAMD21G)

🚗 What Can It Do?

openCAN can operate as a gateway or man-in-the-middle (MITM) device on the CAN bus, intercepting, filtering, and modifying CAN messages in real time. This allows for creative applications in automotive systems, retrofits, and diagnostics.

Example Use Cases

🔄 Cross-Platform Signal Translation (Engine Swaps)

Bridge a donor engine's CAN messages to a chassis that expects a different format:

  • Read RPM, coolant temp, oil pressure, and other signals from the engine-side CAN bus
  • Repackage them into the message IDs and formats the chassis cluster expects
  • Factory gauges, warning lights, and chimes work correctly without cluster modification or a standalone digital dash

🌡 PWM Fan Control

Use coolant temperature data from the CAN bus to:

  • Generate a PWM output signal
  • Drive an electric fan based on temperature profile

🚙 Speed Signal Generation

Generate a VSS (vehicle speed signal) for a swapped engine, transmission, or ECU:

  • Read output shaft speed sensor, speed sensor pulses, or ABS speed data
  • Calculate vehicle speed based on tire size and final drive ratio
  • Output a corrected speed signal (CAN message or pulse output) for the ECU, cluster, and cruise control to use

🛠 Gauge Reassignment

Display oil temperature on the coolant temp gauge:

  • Read oil temp from CAN Bus A
  • Rewrite it as coolant temp on CAN Bus B
  • Toggle the mode with an existing switch (e.g., cruise control cancel)

⛽ E85/Flex Fuel Content Monitoring

Read an ethanol content sensor and make fueling decisions in real time:

  • Read frequency output from a flex fuel sensor on a digital input
  • Calculate ethanol percentage and fuel temperature
  • Broadcast the values as a custom CAN message for the ECU or a digital dash to consume
  • Optionally trigger a relay output (e.g. enable a secondary fuel pump or water/meth injection) above a set ethanol percentage

🏁 RPM-Triggered Outputs

Use live RPM data from the CAN bus to fire outputs at specific thresholds:

  • Read engine RPM from the powertrain CAN bus
  • Trigger a relay output above a set RPM (shift light, exhaust valve, anti-lag solenoid)
  • Combine with throttle position or clutch switch input for launch control or 2-step style logic

🛟 Failsafe Monitoring

Add protection the donor ECU doesn't provide on a swapped platform:

  • Monitor oil pressure switch and coolant temp sender on analog inputs
  • If oil pressure drops or coolant temp exceeds a threshold, trigger a relay output (warning light, fuel pump cutoff, fan to max)
  • Runs independently of the ECU, so it works even if the donor ECU has no concept of the new chassis's sensors

🔧 Hardware Details

Microcontroller: ATSAMD21G

🚌 CAN Interfaces (Dual MCP2515)

CAN Bus CS Pin INT Pin
CAN1 D10 D2
CAN2 D11 D3

⚡ Digital Outputs

All 8 digital output channels are NPN switch-to-ground stages (MMBT2222A). openCAN pulls the output node high through a base/collector resistor, and the SAMD21 GPIO drives the transistor base, pulling the output low when active. D0, D1, and D4–D7 are the six low-amp output control channels. D8 and D9 are sized for relay coil drive. (D2 and D3 are reserved as the CAN controller interrupt lines.)

Pin Driver Resistor Function
D0 Q1 (MMBT2222A) R1 (1k) Low-amp output control
D1 Q2 (MMBT2222A) R20 (1k) Low-amp output control
D4 Q3 (MMBT2222A) R4 (1k) Low-amp output control
D5 Q4 (MMBT2222A) R10 (510) Low-amp output control
D6 Q5 (MMBT2222A) R11 (510) Low-amp output control
D7 Q6 (MMBT2222A) R17 (1k) Low-amp output control
D8 Q7 (MMBT2222A) R18 (1k) Relay control via ground switch
D9 Q8 (MMBT2222A) R19 (1k) Relay control via ground switch

📥 Analog Inputs

Pin Resistors Function
A0 R2 (1k pull-up to 3.3V) Resistive sensor input (e.g. fuel/temp senders)
A1 R3 (1k pull-up to 3.3V) Resistive sensor input (e.g. fuel/temp senders)
A2 R13/R14 (1k pull-up to 3.3V) Switch-to-ground input
A3 R15/R16 (1k pull-up to 3.3V) Switch-to-ground input
A4 R22 (4.7k) / R23 (2.2k to GND) 0-5V analog sensor input, ~1.6V at pin for 5V signal
A5 R21 (4.7k) / R24 (2.2k to GND) 0-5V analog sensor input, ~1.6V at pin for 5V signal

🔌 Connecting to openCAN

Arduino IDE Setup

  1. Download and install the Arduino IDE from arduino.cc/en/software
  2. Open the IDE. Go to File → Preferences.
  3. Paste the following URL into the Additional Boards Manager URLs field: https://raw.githubusercontent.com/two-7/openCAN/main/package_two7_index.json
  4. Go to Tools → Board → Boards Manager.
  5. Search for openCAN SAMD21 Boards and install the package.
  6. Plug the openCAN board into the computer.
  7. Go to Tools → Port and select the COM port openCAN is connected to.
  8. Go to Tools → Board → openCAN SAMD21 Boards → openCAN.
  9. Go to Tools → Serial Monitor.
  10. In the Serial Monitor pane, set the line ending to New Line and the baud rate to 500000.
  11. Live openCAN data streams to the Serial Monitor, refreshing once per second.

📷 Board Images

digital IO 3d Board

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages