Skip to the content
2 layers97 × 54.3 mmAttiny3226Board, the printed circuit board in 3D

Attiny3226Board

ieb/N2KEngine

N2K Single board engine monitor using a 328p

Size
97 × 54.3 mm
Copper layers
2
Thickness
1.6 mm
Parts
73
Nets
52
Pads
198
Tracks, vias
511, 13
Pours
12
Routed
Yes
KiCad
KiCad 7 (file 20221018)
Created
1 Dec 2024
Updated
12 Jul 2026

Overview

Attiny3226Board is an open-source printed circuit board by ieb, from the ieb/N2KEngine repository on GitHub. It is a 2-layer board of 97 × 54.3 mm with 73 parts on 52 nets, routed with 511 tracks and 13 vias.

It is built around the ATTINY3226-SU, AMS1117-5.0 and LM393, with the TJA1050 and S1J among its other parts. Its parts include 24 resistors, 17 capacitors, 13 diodes, 12 connectors and 5 ICs. It belongs with the AVR (ATmega, ATtiny) boards of this library.

Main components

5

README

README.md

N2K Engine Monitor

This monitors an engine, mostly temperatures and fuel, emitting suitable N2K messages. Targeting a Volvo Penta D2-40. Code and pcb are based on the interface board in https://github.com/ieb/EngineManagement, however this time the pcb is from scratch using a Atmel 328p directly to make the unit more robust. The original has been in service for 3 years with no problems seen, outlasting the Volvo Penta MDI unit, which failed 2x in < 4 years. Ok, the replacement was based on relays following the Perkins schematic for the same engine, so not really hard to do.

PCB

Single board. If using a 328p chip you will need to flash the bootloader. See programBootLoader for details.

328p based board

board

Attiny3226 Board, 12bit ADCs and better RPM accuracy

board

Setup

Setup starting with a new board, this is for 3226 which the preferred board.

  • Test the board supply to check power consumption, should be about 30mA at both 5v and 12v.
  • Connect up a UDPI programmer, and serial monitor.
  • Burn Fuses, and tune the internal clock on the 3226, see tuning3226/README.md
  • Upload the code.
  • Connect a CAN bus with 1 other device.
  • Verify CAN messages are sent and received (menu item d)
  • Measure and set the supply voltage to the chip after powering with 12v. (menu item V)
  • Check the Sensor diagnostics (menu item D, and M), might need to connect some NTC sensors and fake up flywheel source.
  • Set the engine hours to match the existing board.
  • Install the board

Connection notes

  • The GND connection must be made to the engine block (star pattern) to avoid GND voltage differences when the anternator is charging. Do not GND on the battery as that will result in dips in the coolant temperature of 5C or more. The battery voltage will include the GND drop on the charging line.

  • The exhaust NCT should be connected to a part of the wet exhaust with good thermal connection to the inside of the exhaust. Do not connect to the elbow on the engine as this could result in false alarms when starting a warm engine. The trigger level is 45C or an 8C every 30s rise. Typically an exaust in UK waters on a D2-40 rests at 34-37C and rises rapidly should raw water fail.

Changes from original build 4 years ago

  • All components SMD, no draughtboards or modules with pin headers to fail.
  • Switched from a LM385 to a LMV393 for the flywheel pulse generator as all I need is a clean square wave to count the pulses. (actually I miss ordered 10 LMV393's and then switched over).
  • Changed to a 16MHz crystal on the MCP2515 since this is what the 328p is using. Perhaps 1 crystal would work for both, but probably not.

Memory usage

after reducing memory requirements (580 used before), varies up an down a bit with debug.

attiny3226

text
RAM:   [==        ]  20.1% (used 619 bytes from 3072 bytes)
Flash: [========  ]  81.1% (used 26579 bytes from 32768 bytes)

NB, no malloc in use in code. Over 77% Flash usag pio inspect no longer works, however removing One wire code may give enough space for debug symbols to allow inspect to work

Status bits.

The status bits in PGN 127489 are set to indicate an alarm condition.

Alarm set levels and alarm clear levels are in enginesensors.h

WHen an alarm condition is set if the check engine, maintenance or emergency stop bits are set, they are not cleared when the alarm clears. Generally advisable to stop the engine and check.

Emergency stop will be set when temperatures are too high. Best to stop the engine before damage occurs.

Over Temperature status 1 bit 1 set when over temperature is suspected including coolant (> 97C), exhaust > 45C, alternator > 110C, engine room > 70C. Will also set check engine and engine emergency shutdown alarms.

Low oil pressure alarm is set when oil pressure is < 10psi.

If sensors fail then engine comms alarm is set.

Water flow alarm uses the wet exhaust silencer probe as a proxy for raw water flow. The probe is mounted on the silencer body, which is in direct contact with the wet exhaust but thermally isolated from the engine block and heat exchanger — so silencer temperature reflects exhaust gas vs raw water flow only, and is not biased by block temperature on a warm restart. Two independent triggers, both gated on engine running, past the start-up grace period, and not stopping:

  • Absolute over-temp: exhaust > 45C. WATER_FLOW and CHECK_ENGINE are set on the first sample; EMERGENCY_STOP is held off until the condition has persisted for 5s so a single noisy ADC sample cannot trip it.
  • Rate-of-rise: exhaust climbs more than 8C in any 30s window once past the 35C baseline. This catches a flow failure before the absolute threshold (the 21-Jun-2026 incident showed a +9C rise in the first 30s while still well below 45C).

A coolant-vs-exhaust convergence check was previously included but removed: on a warm restart the silencer takes several minutes to thermalize while coolant is already at operating temperature, producing a coolant–exhaust gap that approaches the trip margin under entirely healthy conditions.

The alarm clears only once exhaust drops below 38C (widened from 40C) to avoid chatter on a cooling elbow.

Charge indicator alarm is set when the alternator voltage is < 12.8V

Engine shutdown alarm will be set when the engine is shutting down.

Other alarms are not set at this time.

Building and Uploading

Attiny3226 based board

Use UDPI. I use the old, slow and slightly buggy jtag2udpi programmer loaded onto an Uno. I use https://github.com/ieb/jtag2updi forked just in case. After programming the Uno needs a 10uF cap between reset and ground to prevent a reset on the Uno when programming starts. The UDPI output is on Digital Pin 6 and connects via a 4K7 Resistor to the UDPI pin on the Attiny3226. The target board should be powered separately, and the serial monitor can remain attached while programming. Do not power the board using both a serial converter and the 12v power supply as this will cause the serial port to draw too much USB current and be shutdown. Programing setup is in platformio.ini. Before programming a fresh chip, set the fuses to set the CPU Frequency.

Fresh boards also need to go through a runing process , see tuning3226/

Obviously edit platform.ini with the correct serial ports for upload and monitoring.

text
pio run -e attiny3226 -t fuses

Then upload code with an upload command. Fuses only need to be set once per chip.

text
pio run -e attiny3226 -t upload

To monitor

text
pio device monitor

Clock Tuning 3226

The 3226 board uses an internal oscilator due to lack of pins and so it needs tuning from a board with a quartz crystal as per https://github.com/SpenceKonde/megaTinyCore/blob/master/megaavr/extras/Ref_Tuning.md. The Tuning source needs to be https://github.com/SpenceKonde/megaTinyCore/tree/master/megaavr/libraries/megaTinyCore/examples/TuningSource uploaded onto a Uno or any 328p with pin 9 available. The UNO must have an real crystal not a resonator. The tuning code is https://github.com/SpenceKonde/megaTinyCore/tree/master/megaavr/libraries/megaTinyCore/examples/megaTinyTuner, but for these boards must be modified to use PB1 as the timing pin since this is exposed directly. (Oil pressure sense). Copies of both of these are in tuning as they needed minor modifications.

328p based board

Can be built on any 328p suitably wired, however to build using the pcb design first flash a bootloader, see [programBootLoader/README.md] for details, then come back here.

Having flashed with the urbootloader connect a serial adapter configured for 5V to the serial header pins, adjust platform.ini to reflect the serial port and run

text
pio run -t upload

to monitor

text
pio device monitor

Do not attempt to power the board both on the 12v line and through the serial port 5v at the same time. This will probably shutdown the USB port on your laptop (or worse produce some smoke) Monitoring over serial can be done provided only GND, TX and RX are attached. Ie no power from the serial adapter.

LM393 RPM to pulses

Critical that this chip as a 100nF decoupling capacitor. Without it it will generate pulses from power supply noise with the inputs shorted together. See schematic. LTSpice models don't predict this behavior.

Engine Events

Stores upto 29 events in EEPROM, with a 15s resolution and one of upto 255 types. All the following PGNS have standard priorietary PGN format + a Function code byte. The Manufactore code is 2046 and the Industry is Marine, ie 4.

PGN Abuse

Since Raymarine instuments display only a asubset of PGNs, some are beeing abused to get critical temperatures avialable on the insturments.

  • alternator temperature, critical for LiFePO4 charging, is sent as oil temperature in Dynamic Engine Parameters (PGN 127489)
  • ehxhaust temperature, critical for raw water flow monitoring, is sent as transmission oil temperature in Dynamic Transmiossion Parameters (PGN 127493L)

Temperature PGN 130312 non standard IDs

  • Exhaust temperature is sent as ID 30
  • Additional OneWire Temperature probes are sent as IDs 31-35 where present.

PGN 65305L

Standard Packet proprietary, 8 bytes

| Field | Length | Value | Description | |-----------------------------------------------------| | 1 | 11 bits| 2046 | Manufacturer code | | 2 | 2 bits | | Rserved | | 3 | 3 bits | 4 (0b100) | Industry Code | | 4 | 8 bits | | Requst Function Number | | 5 | 5 bytes| | reserved/payload |

FunctionDescriptionValid PGNResponse
11Get events65305LEvents PGN 130817L Functon 12
12Get events response130817LList of events
13Clear events65305LACK PGN 65305L Functon 14, no payload
14Clear events ACK65305LAck clear events, no payload

PGN 130817L

FieldLengthValueDescription
111 bits2046Manufacturer code
22 bitsRserved
33 bits4 (0b100)Industry Code
48 bitsRequst Function Number

Function 12

FieldLengthValueDescription
41 byteuint8_tNumber of events
5+(n*4)1 byteuint8_tEvent ID
6+(n*4)3 bytes3Byte UDouble 0.001Engine Hours of event (15s resolution)
Event IDMeaning
0Current engine hours, no event
1Engine Stop
2Low Oil Pressure
3High Coolant Temperature
4High Exhaust Temperature
5High Alternator Temperature
6High Engine Room Temperature

Todo

  • build board.
  • Flash bootloader and test
  • Port code from original
  • Allow for 16MHz MCP2515 oscillator, current library uses 8MHz.
  • Handle when engine not running, now that device is powered from CanBus
  • Reduce memory requirements in EngineSensorts and bind measurements to messages.
  • PR SmallNMEA2000 with changes
  • Test and Calibrate NTCs
  • Test and Calibrate Coolant and fuel
  • Test On N2K Bus
  • Implement 1 wire
  • Allow Engine Hours to be set via serial
  • Improve status and diagnostics to include n2k traffic
  • Implement status alarms
  • Consider swapping NTC4 for a oil pressure sensor if it can be accommodated.
  • Power from Engine supply since oil pressure sensors use > 10mA typically. This means fuel levels and temperature will only be available with engine controls turned on.
  • Check voltage calibration, some doubt over digtal multi meter accuracy used previously - verified against a ADS1115 to be accurate
  • Add firmware version, shows on the help, press h when connected over serial.
  • Create a attiny3226 based board, with 12bit ADCs for better resolution on the voltages.
  • Calibrate CPU clock
  • Verify RPM accuracy (measured at +- 0.2% relative to calibrated 16Mhz crystal)
  • Verify NTC and other ADC readings.
  • Install onboard
  • Implement event storage
  • Implement PGN proprietary messages to query engine events.
  • Update schematic to improve ADC stability when charging main LiFePO4s
  • Fix OneWire on Attiny3226 (see lib/vportonewire)
  • Fix event streaming to contain the right number of events including current hours.
  • Read stop button, on PC0. This will go to 12V when the solenois is powered.
  • Lowered alternator low voltage alarm to 12.2v and added window for overheat to combat high noise levels on the coolant sensor.
  • Added window period for all alarms to avoid 1 reading triggering alarm condition, set a 5s.
  • Fixed (hopefully, need to test on engine) noise in in Engine Coolant readings, due to 12v ripple.
  • Check the divders, which we specked at 100K/47K which could be too large for the ADC capacitance.

Could do... but probably will not

The board currently runs of switched engine power, so to read fuel tank and batteries the engine has to be turned on. This is good, since power consumption becomes irrelevant although its typically < 80mA. I could optimize so that the board could be powered from the Can bus, but probably wont. Better to have it off when not relevant.. eg when sailing.

New Board check list

  • Oil sensor with pot
  • NTCs, set Vdd then 10K == 25C, 22K == 8C, Check thermstor against room temp and body temp.
  • Check Fuel 190R == full 0R == empty, linear, 120R == 120/190 = 63% 47/190 == 24
  • Check AltV by connecting to suppy V
  • Check Coolant, Supply -> 1K top. 22R == 120C, 120R == 60+10*(134-120)/(134-97) = 63
  • Check RPM with a 1KHz signal
  • Check oneWire
  • Check CAN and engine events are responding, verifies can read and write.

Engine overheat data from 21 July 2026.

Had been motoring for about 45m, 2.2K rpm all stable.

  • 10:08:45 Coolant 87C, Exhaust 38.4C, Engine Room 57. raw water hose detaches, sudden drop in Engine Room temperature due to water spraying engine bay. Exhaust note changed.
  • 10:09:00 Coolant 90C, Exhaust 40.2, Engine 50C
  • 10:09:15 Coolant 92.7C, Exhaust 47.1, Engine 49.4C
  • 10:09:30 Coolant 95.2C, Exhaust 51.9, Engine 48.6C <<< Should have alarmed here.
  • 10:09:45 Coolant 97.4C, Exhaust 57.9, Engine 47.3C
  • 10:09:55 Coolant 98.3C, Exhaust 62.6, Engine 47.1C engine was turned off before overheat.

Exhaust elbow temperature rises rapidly 22C over 1m vs 8C over the same period for the engine coolant temperature, although at the time no raw water alarm sounded as the limit was set at 80C and there was no display showing exhaust temperature.

Exhaust elbow temperature seems to be a strong indicator of water flow once the engine is running at temperature.

Parts

73
QtyValueFootprintReferences
910KResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR3, R7, R9, R12, R17, R19, R23, R25, R27
9S1JDiode_SMD:D_0805_2012Metric_Pad1.15x1.40mm_HandSolderD5, D6, D7, D8, D11, D12, D13, D14, D15
510nFCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC17, C18, C19, C20, C23
4100nFCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC1, C10, C15, C24
34.7KResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR16, R18, R28
3470nFCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC11, C14, C16
34K7Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR1, R2, R26
2100KResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR10, R14
210uFCapacitor_SMD:C_1206_3216Metric_Pad1.33x1.80mm_HandSolderC6, C7
218pFCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC8, C9
222KResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR4, R5
247KResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR11, R15
2LEDLED_SMD:LED_0805_2012Metric_Pad1.15x1.40mm_HandSolderD1, D2
2SJ1Diode_SMD:D_SOD-123D3, D4
1 HC-49 16MHzCrystal:Crystal_SMD_HC49-SDY2
110uFCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC21
112V InTerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-2-5.08_1x02_P5.08mm_HorizontalJ5
11KResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR22
11WireTerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-3-5.08_1x03_P5.08mm_HorizontalJ13
1220KResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR8
1470RResistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR6
1AMS1117-5.0Package_TO_SOT_SMD:SOT-223-3_TabPin2U6
1ATtiny3226-SPackage_SO:SOIC-20W_7.5x12.8mm_P1.27mmU3
1Attiny UDPIConnector_PinHeader_2.54mm:PinHeader_1x05_P2.54mm_VerticalJ3
1CANTerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-2-5.08_1x02_P5.08mm_HorizontalJ2
1EngineTerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-2-5.08_1x02_P5.08mm_HorizontalJ7
1FlywheelTerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-2-5.08_1x02_P5.08mm_HorizontalJ12
1FuelLevelTerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-2-5.08_1x02_P5.08mm_HorizontalJ6
1LM393Package_SO:SOIC-8_3.9x4.9mm_P1.27mmU2
1MCP2515-xSOPackage_SO:SOIC-18W_7.5x11.6mm_P1.27mmU1
1NTC1TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-2-5.08_1x02_P5.08mm_HorizontalJ8
1NTC2TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-2-5.08_1x02_P5.08mm_HorizontalJ10
1NTC3TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-2-5.08_1x02_P5.08mm_HorizontalJ4
1Oil PressureTerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-3-5.08_1x03_P5.08mm_HorizontalJ9
1PolyfuseFuse:Fuse_1812_4532Metric_Pad1.30x3.40mm_HandSolderF1
1StopSolenoidConnector_PinSocket_2.54mm:PinSocket_1x01_P2.54mm_VerticalJ1
1TJA1050Package_SO:SOIC-8_3.9x4.9mm_P1.27mmU4

More from ieb/N2KEngine

1
  • 2 layers97.2 × 50.5 mmAtmel328pBoard, the printed circuit board in 3D

    Atmel328pBoard

    ieb/N2KEngine

    N2K Single board engine monitor using a 328p

    72 parts

Similar boards

  • 2 layers108 × 47 mmEsp32board, the printed circuit board in 3D

    Esp32board

    ieb/N2KEngineEsp32

    N2K Engine Interface with BLE built around an ESP32 and ADS1115 ADCs

    88 parts
  • 2 layers100 × 56 mmTSAL, the printed circuit board in 3D

    TSAL

    ncku-formula-racing/circuit

    A monorepo of circuit boards

    146 parts1
  • 2 layers54 × 60 mmMicroPAMI-2026, the printed circuit board in 3D

    MicroPAMI-2026

    LesKaribous/Karibous-2026-PAMI

    39 parts1
  • 2 layers94.9 × 40.6 mmEsp32-c3-board bms, the printed circuit board in 3D

    Esp32-c3-board bms

    ieb/N2KNMEA0183Wifi

    Exposes NMEA2000 and BMS data over BLE for Apps to use. Also supports Wifi/http/tcp/udp services.

    43 parts2
  • 2 layers80 × 30 mmAc sensor, the printed circuit board in 3D

    Ac sensor

    sshoecraft/ac-sensor

    AC Sensor used in hydronic HVAC system

    24 parts
  • 4 layers106 × 29.2 mmBatterymeter, the printed circuit board in 3D

    Batterymeter

    hb020/batterymeter

    Handheld Battery AC and Time Domain characterization tool on Attiny series 2

    145 parts20
  • 2 layers147.8 × 106.3 mmMr washi, the printed circuit board in 3D

    Mr washi

    mayermakes/MyGenWashy

    Generic washing Machine Controller - Result of the TuttleButtle Hackathon 2025

    54 parts12GPL-3.0

Questions

How big is the Attiny3226Board PCB?

It measures 97 × 54.3 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Attiny3226Board use?

73 parts, built around the ATTINY3226-SU, AMS1117-5.0, LM393 and TJA1050. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Attiny3226Board KiCad files?

From the ieb/N2KEngine repository on GitHub, at the commit this page was made from: the board is pcb/caninterfaceboard/attiny3226Board.kicad_pcb and its schematic pcb/caninterfaceboard/atmel328pBoard.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Attiny3226Board design in my own project?

Its repository states no licence, so its author keeps all rights: ask ieb before reusing the design.