Arduino: Intelligent HAM Antenna Switch

In the following I describe a revised HAM antenna switch that can be connected via CAT to HAM radios that are compatible with the Icom ci-v protocol.

The intelligent HAM antenna switch ensures that an appropriate antenna is connected to the radio depending on the selected frequency. There is no manual switching necessary - all switching is done by the micro-controller in the background, but can be overwritten any time.

Operation and Program Logic

The operation and the program of the antenna switch works like following:

  • An active antenna (relay) can be chosen with the Up / Down buttons.
  • If the radio is in transmit mode (PTT pin gets low) – the change from one antenna to another is blocked for security reasons.
  • If the antenna is changed, the new selected antenna will be saved into the EEPROM. This will be done for each band separately and happens automatically after a delay of a few seconds.
  • The current frequency (QRG) is read from the CAT connection using the Icom ci-v protocol. The Arduino is only reading on the bus. It does NOT send any telegrams in to the bus. If the current QRG changes, the LCD will be updated. In addition, it is determined whether the new QRG is on a different band.
  • If the band changes (due to changes of QRG), the program will activate the predefined antenna.
  • If (for any reason) the frequency is outside of a defined band, the antenna remains unchanged.
  • As long as the rig is in receive mode, the antenna can be changed using the Up / Down buttons.

Example: LCD display: The radio is set to a frequency of 21.1151, the intelligent antenna selector automatically switches to the antenna A as it was saved for band 15 previously:

ci-v information on LCD display - intelligent antenna selector

Another antenna can be activated with the Up / down buttons

CAT: ci-v Frequenz am LCD display für den intelligenten Antennen Selektor

After a short delay, antenna B will be saved to band 15.


  • In the case of CAT activity (new QRG messages in ci-v format on the bus) this is briefly displayed on the LCD (similar as in the sketch of ON7EQ)
  • If values ​​are saved in the EEPROM, this is briefly displayed on the LCD (similar to the code of ON7EQ)

Changes to the sketch

My sketch contains the following changes compared to the ON7EQ sketch:

  • If no QRG is received for a longer time, an "offline indicator" appears on the left in the first row. This shows that either the connection to the radio has been broken or that no frequency change has been made for a long time.
  • Each antenna can be given a meaningful name in the sketch. On the pictures used here it is just Ant A .. Ant G but you can use up to 8 characters.
  • Either Soft-Serial (for the UNO) or a HW-Serial (for the MEGA) can be used for the CAT interface to the radio. If you want to change it, you only need to adopt one precompiler #define.
  • Since the OM for which I programmed this did not want any different RX - TX antennas, this is currently not supported in the sketch. If you take a closer look at the code, you will see some preparation for it but it is not implemented yet. If this is really a feature that others would like to have, then this could be implemented on request.
  • An antenna (relay) will be activated when the device is switched on. If you don't like that, you can change it easily in the sketch. The "default" antenna does not necessarily have to be attached to the first output. As soon as the radio sends the first CAT message, the pre-selected antenna is activated according to the band.
  • The number of outputs is actually only limited by the available pins. An Arduino UNO has 13 "digital" pins and 5 "analog" pins. The sketch uses up to 3 user buttons, a PTT input, two GPIOs for the I2C display, I never use the two 2 HW serial / USB and I also block 2 pins for communication with the radio (even if TX is not used as stated above). 23 - 10 = 13 free pins. My built is for 8 antennas/relays.
  • Due to the increased number of outputs, the structure of the second line had to be adopted. Only the current antenna is displayed. A text description (8 characters) can also be specified in the code.
  • If you still want to have the "old antenna display" from ON7EQ with 5 antennas, you only need to adjust the displayShowAntenna() function and recreate the two custom characters. An alternative function is included in the sketch and can be used as a starting point.
  • The sketch activates the internal pull-ups for the input buttons. External pull-up resistors are therefore not required (but should also not interfere).
  • The LCD library I used offers several interfaces. I2C is almost "standard", but you can also connect the LCD in parallel with the same library or connect a RGB LCD from Sureeno, use a LCD on a SPI expander and much more. This LCD library can also be found on my homepage. German-speaking readers should definitely take a look at this version if they ever want to write äöüß on the LCD.
  • The variable names were changed a lot (starting with a small letter and using camelCase) but are similar to those of ON7EQ, so it should be easy to switch.
  • The rig communication part was taken over from the sketch by "Pete & SAM". This is structured like described in the "Serial Basics 2" in the forum. Honestly, I wouldn't have done it any other way. The changes are only marginal there.
  • There are no GOTO in the rest of the program logic. I partly use OOP and mostly functions. This avoids redundancies and code duplicates. This should also make the conversion to a 20x04 LCD very easy as you have every output on one position.
  • And last but not least: The sketch compiles on a more up-to-date Arduino IDE (at the beginning of 2021 this is Version 1.8.13).


The circuit was built into an old SAT tuner enclosure because I wanted a metal shielding and a transparent front panel to avoid selfmade cutouts for the display:

Intelligenter Antennen Schalter für CAT/ci-v Protokoll

The interior is very simple. I use the original tuner power supply, two step-down converters for 5.5V and 12V (as control voltage for the relay outputs), an I2C LCD, some of the original buttons and an 8-way relay card.

Intelligenter Antennen Schalter mit Arduino Uno und 8 fach Relais Karte

To control the antenna matrix, the activated relays send the 12V control voltage to the antenna switch. The click of the relay also gives a short "accoustic" feedback and you hear, that the antenna has been changed. As microcontroller I use an Arduino NANO Clone (with UNO bootloader). Not a single Dupont cable was used, all connections were soldered and protected with shrink tube.

Two 3.5mm stereo jack sockets were installed for the CAT interface ci-v. The PTT signal is connected with Cinch socket and passed to a second outlet. This means that the intelligent antenna switch can be easily integrated (daisychained) into an existing setup.

On the transceiver (here an ICOM IC-7300) the CI-V interface must be activated to 9600 baud, but you could chose another baudrate if you adopt the sketch.

CAT: activate ci-v on ICOM tranceiver

Notes about the ICOM CI-V interface

The CAT interface differs depending on the manufacturer. For ICOM, the ci-v is a protocol similar to the serial interface, not with RS232 level but with TTL levels. The baud rate can usually be set on the radio. I use a slow 9600 (because of soft serial). The description of the ci-v protocol can be found on the Internet. The used ICOM rig only sends the frequency when it changes. If you want to test read the QRG into PC, you should switch your terminal program to display the data in HEX. A CAT telegrams for ci-v starts with 0xFE 0xFE and ends with 0xFD. My sketch only uses the frequency information.

Ideas for a further versions and hardware Alternatives

Even if most parts a premade modules from lot of work went into the assembling of the hardware. One of the largest time consumers was the cabling because I didn't want to use these faulty Dupont cables.

A relay board where you can stack on an Nano. Apart from the well-known 4-way relay shield for the UNO I have only found one other board.

relais board for Arduino Pro MiniRelais board for the Arduino Pro Mini

For the Arduino Pro Mini you can find a 8-channel relay board. Like the Arduino UNO or NANO, the Arduino Pro Mini has an ATmega328p, but you need a separate USB-TTL converter for the programming. You can read more about this board here on my homepage: 8 Channel Relayboard IO22D08.


I am not satisfied with the look of the enclosure neither, but my manual skills are not sufficient for a do-it-yourself construction. If you invest a little more money, you find what you are looking for in the DIY HIFI section. Different variants are available. The model with the buttons below the display cut out has a really nice finish:

diy metal case with LCD cut out


If you are looking for a smaller enclosure, then the version with a rotary control next to the display is ideal. The conversion to an incremental encoder should be quite simple.

Metallgehäuse mit LCD Ausschnitt


Alternatives to the software (looking back at older versions) - Credits

I would like to give credits to the good work of others: In 2011 ON7EQ presented an "ARDUINO intelligent antenna matrix switch". The code is also available on his homepage but does not compile any more with the Arduino IDE. On his side there is a heavily revised sketch with the reference to "Pete & Sam" ZS6SAM. This sketch also needs adjustments so that it can be compiled with a current IDE. Sam's code was probably created for the Arduino MEGA. During the first few attempts I made the decision to rewrite lot of the parts. On the DM2RM homepage there is a variant of the original code with the conversion to an I2C display. But even this does not compile with a current IDE. Interesting on his side is the neatly drawn circuit diagram (but you don't need the ULN). All known homepages are liked on the end of this page.


Apart from the programming (the update actually caused more effort than a "finished sketch" would suggest), most of the time actually went into the hardware parts - even if I just used modules. Although it was extensively tested with the PC, the setup of the ICOM IC-7300 took a long time. The final connection settings on the IC-7300 could finally be clarified with a direct connection radio -> TTL-USB converter -> laptop and then the intelligent antenna selector worked as planned.


(*) Disclosure: Some of the links above are affiliate links, meaning, at no additional cost to you I will earn a (little) comission if you click through and make a purchase. I only recommend products I own myself and I'm convinced they are useful for other makers.


First upload: 2021-05-21 | Version: 2021-05-21