ArduinoISP sketch + Serial Passthrough

TL;DR: I figured out how to use serial debugging through an Arduino while using it as an ISP.

I’ve been working on a project with an ATTINY-84 recently, and I have been using an Arduino Uno with the ArduinoISP sketch as a programmer.

However, I wanted to be able to use the serial monitor to see serial debug messages printed by the ATTINY. The default ArduinoISP sketch doesn’t support this, since it needs serial communication for uploading programs.

Looking at the ArduinoISP sketch, it determines what is going on when it receives a serial message by reading the first byte of the message.

Since most bytes are simply ignored as errors, there’s room to add in another byte to enable serial passthrough!

case '~':
  serialPassthrough = true;

When the Arduino receives a ‘~’, it switches into serial passthrough mode, which disables the ISP functionality and prints whatever serial messages it receives like follows:

while (Serial.available() > 0) {

How to use:
(These steps are the normal steps to use the ArduinoISP sketch)

  1. Upload the modified ArduinoISP sketch to an Arduino board
  2. Select ‘Arduino as ISP’ as the programmer in the ‘Tools’ menu
  3. Connect the proper pins of the Arduino to whatever you’re programming
    (This is where the steps differ!)
  4. Either connect the Tx pin of whatever chip/board you’re programming to the Rx pin of your Arduino through an open switch, or leave it disconnected for now.
  5. Make sure that the first byte of your debug messages is ‘~’
  6. Upload your sketch
  7. Close the switch or connect the serial communication to your Arduino. You should receive serial messages through the serial monitor now.

I hope this is helpful for someone!
I have attached the modified ArduinoISP sketch.

ArduinoISP_serialPassthrough.ino (16.8 KB)

1 Like