Yet another Arduino Nano and si5351 Digital VFO/BFO

January 2017, summer holiday season down-under, afforded time to build something I’ve been wanting to build for several years, my first Digital VFO. I’ve built a kit Digital VFO with pre-soldered surface mount parts and burned-in firmware, but this was to be a scratch build with Arduino Nano, C code with modifications, and a Silicon Labs si5351 PLL clock generator on a breakout board. I used the wiring map and script from Tom AK2B (modified from one by SQ9NJE ) and uses Jason NT7S si5351 library. The script is simple, supporting a single push-button to cycle frequency increments, and dealing with encoder interrupts, contact debouncing, refreshing the LCD display, IF offset and VFO/BFO outputs.  Jason’s si5351 library hides the gutsy device interfacing, giving you a handful of common-sense functions to call… for example, set_frequency() takes as its argument the frequency in centi-hertz (1/100th of a hertz) and the ‘clock 0/1/2’ flag. It couldn’t be simpler. The Adafruit board contains the si5351 and a 25MHz clock (from local IoT supplier Core Electronics).  Here’s a video demonstration of the VFO’s features.

Tom’s script didn’t compile first time, as Jason’s library had changed since Tom posted his script. Jason had removed one parameter from the init() and set_frequency() methods to simplify things. In Tom’s script I removed the arguments (which were ‘0’ anyway). This was a remarkably simple build experience!  The key is the si5351… three clocks, 1-160MHz, all software controlled, in a tiny 10 pin MSOP package, and all for a few dollars.

One thing’s for sure, it will be hard going back to quartz.  [Postscript 12/2018: Quartz crystals are still favoured for good clean BFOs;  but I can’t see any reason other than nostalgia for building a free-running VFO these days].  

With the wide range of Arduino breakouts, all sorts of control and monitoring behaviours now become possible — GPS, SWR, power and temperature monitoring for power amplifier stages or linears, sequencing, switching, wifi, bluetooth, packet data links, to name a few.

Design notes

Once you have control of the VFO and BFO in software, controlling other things in a transceiver like band, memories or multiple VFOs, IF filter switching is all just a matter of a few more lines of code.  I came up with the following additional controls:

  • Step cycle (10, 100, 1k, 10kHz steps)
  • VFO cycle (A, B or C)
  • Band up/down (LF, MW, 160, 80, 60, 40, 30, 20, 17, 15, 12, 10)
  • Mode cycle (SSB, AM, CW)
  • Rx/Mute status (Rx, Tx)

Controlling mode and band switching relays

If you decide to implement control of mode and band switching in your homebrew radio’s Arduino controller, a mechanism is needed to pass binary or BCD values representing the active mode and band selections through to the individual control lines that energise the relays for each. The traditional way of doing this is to get the controller to output a BCD 3 or 4-bit nibble on its pins, and use a CMOS/TTL 1-of-8 (74LS138) or 1-of 16 (74LS154) decoder, with an inverting transistor relay driver stage which does the actual switching.  You can buy the CMOS version of the venerable 74LS154 1-of-16 IC in surface mount on an Arduino style break-out board to minimise space.

A more contemporary way of achieving the same thing is to use a 1-of-16 decoder driven by I2C. Something like this break-out expander. Or this IO expander.  This is preferable because you don’t need to tie up lots of your Nano pins to synthesise a BCD nibble, instead, you pass the selected value to the expander/decoder device via I2C. I’ve not decided how to do this yet.

Supporting multiplexed pushbuttons

I came up with the need for pushbuttons to control the following features of a multiband radio:

  1.  freq step (100Hx, 1kHz, 10kHz)
  2. VFO cycle (VFO A, VFO B, VFO C)
  3. band up (40, 30, 20 etc)
  4. band down (20, 30, 40 etc)
  5. mode cycle (SSB, CW, AM)
  6. mute (RX, TX).

The Hitachi LCD display does not support serial I2C. That means 4 Arduino digital outputs are necessary to convert 4 bit data values to the display, plus 2 control lines. That does not leave enough digital and analogue pins for all the pushbuttons or  output lines.

A common way around this (without going to the added complexity of IO expander break-outs) is to multiplex a number of pushbuttons switching on a resistive voltage divider, on a single analog input. The script reads the pin and interprets a voltage range for each button. Here’s a circuit and tutorial. I built a rack of 6 momentary on switches (on a receiver front panel I prefer pushing down on a spring loaded switch over pushing in on a pushbutton). The values I got were quite predictable and narrow in range. In the mapping script I used wide number ranges to allow for DC supply variations or drift.

si5351 clock filtering

The si5351 clock outputs are square waves. There is some discussion in the forums about the harmonic content of the waveform and the need for low pass filtering.  The answer is, it depends on what you are doing with the VFO signal. In the dual conversion multiband receiver I have in mind, all 3 mixers are SBL-1s. I asked the Yahoo QRP-TECH crowd what they thought of the need to low-pass filter a square wave when used to drive an SBL-1 Double Balanced Mixer. There wasn’t any consensus, but two themes emerged:

  • square waves are rich in harmonics and these should be cleaned up, and
  • a DBM is a switching device in which the diodes saturate when driven with correct oscillator signal level, so squareness of the waveform doesn’t matter much.

I decided that low pass filtering was desirable, and plan to add a 5 element Chebychev LPF and a broad-band 2N3904 amplifier stage on at least the VFO clock.

Arduino Nano pin plan

Here’s a plan for how I used the Nano’s IO pins (it assumes an HD7044 LCD and old-fashioned TTL band and mode decoding and switching):

D0 – NC
D1 – NC
D2 – rotary encoder up
D3 – rotary encoder down
D4 – // mode output (lsb) (TBC)
D5 – LCD Register Select
D6 – LCD Enable/Clock
D7 – LCD D4
D8 – LCD D5
D9 – LCD D6
D10 – LCD D7
D11 – // mode output (msb) (TBC)
D12 – // band output (lsb) (TBC)
D13 – // (internal LED) –
A0 – // Multiplexed buttons — VFO cycle, Step cycle, band up, band down, Mode cycle, mute)
A1 – // band output . (TBC)
A2 – // band output . (TBC)
A3 – // band output (msb) (TBC)
A4 – si5351 SDA
A5 – si5351 SCL


Experimenters are using Arduino analog inputs with simple external circuitry to implement the following meters in transceiver projects:

  • Voltmeter: a volt meter is valuable for monitoring battery voltage and health from a portable QRP rig. A voltmeter is one of the easiest additions — simply create a voltage divider with two resistors across the supply rail so that the peak supply voltage is a bit less than 5 volts (measures close to 1024 on the pin using AnalogRead()) and scale the resulting value in software.
  • S-meter: a simple one transistor circuit can sample and rectify IF or audio signal and bring it into the 0-5 volt range for another analogue pin.
  • RF-meter: sample and rectify the PA output via a tiny capacitor (a few pF); the Arduino can use the same display space for S-meter on receive and RF on transmit.
  • SWR: a simple directional coupler can supply both forward and reflected indicative voltages, which can be displayed concurrently or alternately.

Useful notes on Arduino Nano

While researching the Nano I found the following useful facts:

  1. D0 and D1 are used in the serial interface between the Arduino and the PC. The same channel is used by the system’s serial monitor Serial:: which allows a script to trace to the attached screen or other serial device.  Seems best to not use these pins.
  2. D13 controls an on-board LED through an appropriate resistor to ground. As the Nano boots, D13 is made an output (all the other i/o lines come out of a reset as inputs). And the system software, before it executes whatever you’ve put in setup(); will briefly take D13 high before returning it to low. For this reason this pin should be used for input only, to avoid relays clattering during the first seconds after power up.
  3. Arduino analogue I/Os can be used as digital ones.  To set A0 as output and high you use:

 pinMode(A0, OUTPUT);
digitalWrite(A0, HIGH);


August 2017: I made up a second Arduino Nano and si5351 VFO/BFO/Controller for another homebrew rig, with some improvements.  The post describing the VFO is here.   A video of the new rig (receiver only at this stage) is here.

March 2018: Have built four or five Arduino Nano/si5351 VFO/Controllers now.  A post describing my latest Nano/si5351 controlled QRP rig is here.

September 2018: Here’s a post on a compact G6LBQ BiTx using an Arduino/si5351 VFO and BFO.     

November 2018: Here’s the github repo with my code.  It works on a HFSignals (VU2ESE) Raduino module.  If you use it, remember to execute the Initialiser script once (to set up EEPROM).  Further details in the readme and main file header.  

December 2018: And another Arduino/si5351 compact VFO/BFO/Controller and CW Keyer, first stage of a compact multiband SSB/CW transceiver.   

Tagged , , , ,

33 thoughts on “Yet another Arduino Nano and si5351 Digital VFO/BFO

  1. VK3IL says:

    You’re turning to the dark side! Welcome to the world of digital electronics! There are a number of VFO kits out there now too using this synthesizer. I used one in upgrading my KN-Q7A rig (see ). You can do an awful lot with microprocessors in rig control and still use analog for the signal chain. Now you just need to get into designing surface mount PCBs and start using the microprocessors directly 🙂 Even though it costs money to have PCBs produced commercially, it’s pretty cheap these days from China.




    • Paul Taylor says:

      Thanks David. Its pretty good here on the dark side of digital electronics! I can see a steady trajectory in my projects from 1970s radio craft. I can see the day when i do design one off PCBs with surface mount components, mainly to reduce size for portable rigs. Thanks for your Likes and comments David! 73 de vk3hn.


  2. […] the success of My First DDS VFO, complete with Arduino script programming, I found myself interested in mimicking more of the […]


  3. Ardy says:

    Congratulations Paul, si5351 have more clean output and low distortion than DDS ad9850 / 51. 2nd output can using for local oscilator.
    Nice project Paul. 73 de yc2lev


  4. […] the success of My First DDS VFO, complete with Arduino script programming, I found myself interested in mimicking more of the […]


  5. […] in February 2017 I scratch-built my first Arduino and si5351 VFO. Here’s my second one.  It is a generic Nano/si5351 module wired up to Farhan’s […]


  6. […] apart from soldering the SMA connectors) it is just 30mm wide and can used with an Arduino to make VFO with 3 programmable sine wave outputs. Current cost is less than £5 on ebay plus the […]


  7. Michael says:

    Hello Paul. I am just starting to replicate your VFO in the above article (As the basis for another project later). Do you have the exact code still for this exact configuration please? I have downloaded the code dated VK3HN, 20 June 2017, but it cannot find Rotary.h and pcf8574.h which is not needed in this version. I’m looking forward to getting this going. Many thanks…, Michael ZL3AX


    • Paul Taylor says:

      Hi Michael, sorry for the delayed reply, WordPress alerts have dropped off.

      The code is for the Progressive Receiver, not yet posted as it’s not working to my satisfaction. Look at Progressive_VFO.ino on my github page in the vk3hn_si5351_VFO_controller repository. I haven’t flashed this particular controller for probably 9 months but it should still work. You may need to adjust it a bit, and of course, it probably has bugs! Let me know if you need anything interpreted. Regards Paul VK3HN.


      • Anonymous says:

        Thanks Paul. Things have already moved on a bit and have found some code and got the VFO working. Now the project begins, and the code will evolve here. I am still interested in code that gets the best quality from the Si5351 and am working on this. Thanks Paul. M. (Zl3AZ, J87AB, G0GPX)


      • Paul Taylor says:

        Sounds good Paul, there’s lots of code and help around. Good luck with your project. Thanks for commenting.


  8. UR5SDL says:

    your cod is not work !!!
    hi has error her PCF_BPF.write

    E:\Arduino\Arduino_si5351_VFO_Controller_Keyer-master\Arduino_si5351_VFO_Controller_Keyer-master\SP_VFO_Controller_Keyer\SP_VFO_Controller_Keyer.ino: In function ‘void set_filters(uint32_t)’:

    SP_VFO_Controller_Keyer:1011:41: error: ‘class PCF8574’ has no member named ‘write’


    • Paul Taylor says:

      The PCF8574 library that people are using has changed its write() signature. Change all write() to digitalWrite(). Look in the class header if that doesn’t work. There are a number of other things you will need to do to get the script to execute correctly. Most of the comments are in the code headers and readme. If you get stuck just ask. Good luck.


  9. Adrian says:

    Hello Paul
    I came across your website whilst researching the internet for possible solutions for a replacement VFO for my G6LBQ transceiver (and other projects). I like what you have done!

    I have downloaded your code (Arduino_si5351_VFO_Controller_Keyer-master) & fixed the errors as per your comments about changing write() to digitalWrite() and the code now verifies..I am a beginner in writing code so please forgive me if I ask daft questions and I don’t understand some things about how this all works, could you advise ? Specifically:

    1. Where is the initialiser script used ?
    2. Can you confirm that you use the Raduino circuit for the Arduino_si5351_VFO_Controller_Keyer-master ?

    And something you may have noticed…I built a G6LBQ transceiver using the original designed VFO. The VFO uses the same Silicon Labs chip as in the Raduino and others. However the original G6LBQ VFO has display tracking errors. At 1MHz its approx 100Hz off frequency,at 28MHz its approx 7 KHz off frequency and so on. My basic analysis has revealed that there is a mathematical function somewhere in the code that results in this error. I suspect its because the IF frequency I used ended in an odd number and the code doesn’t take this into account.

    I would appreciate your help & thoughts.
    (I have some spare un populated G6LBQ boards if you are interested ?)


    Adrian M1LCR

    Liked by 1 person

    • Paul Taylor says:

      Hi Adrian,
      Thanks for commenting and good to meet another G6LBQ Bits builder. First the answers:

      1. Initializer script is at
      Compile it, make sure your Arduino console is set to 9600, and execute it once. Change any default frequencies etc to suit your rig. These are one-time values as the VFO is frequently persisted in EEPROM.

      2. The circuit is as per Raduino. However, I use my own multiplexed buttons for both front panel and keyer memory pushbuttons. These are wired in the standard way, each one earths a different point in a resistor series, resulting in a distinct reading on the Arduino analogue input. You will need to fiddle around with these, see the notes in the repo.

      I never built Andy’s original VFO and never took the time to study his code, so I cannot comment. The displayed frequency is just a derivative of a float or long sum or difference calculation so there is always room for error. I recommend you do a standard si5351 calibration first to get your PLL clock compensation right, the NT7S lib has a script in examples to make this easy.

      You may need some more answers to get my code to work for you, I didn’t tidy it up for wide adoption. Just ask here.

      73 Paul VK3HN.


      • Adrian Rees says:

        Hi Paul
        I have been working on the code, at this time just to get it to compile and upload to the Nano. I have rectified the write() to digitalWrite() issue and have now run ito the following:
        conflicting declaration ‘typedef struct VFOset_type VFOset_type’
        When compiling the SP_VFO_initialiser sketch.
        I am using a Win 7PC and the Arduino IDE v 1.8.10
        Could you explain how you compile the sketches ? Seperately or all together ?
        Sorry but I don’t have a lot of experience in software…!


      • Paul Taylor says:

        Hi Adrian, thanks for trying my code. The struct that appears to be giving trouble is the same in both scripts. Do you get the same error with the main script?


      • Adrian Rees says:

        Hi Paul
        Thanks for the reply.

        When I try to compile the main script the process stops with the above error, and in the SP_VFO_Initialiser tabbed page. The seems to occur on line16 of that .ino and that line states:

        } VFOset_type;

        I have selected the shack sloth definition, #define SS_EI9GQ //, as that particular variant is closest to what I have in mind. Does that help ?

        If I can get the code to compile, I can then hack it around to get to what I need.



      • Paul Taylor says:

        Send me the exact compiler error text.


      • Adrian Rees says:

        Hi Paul
        Can you send me an email to my email address and I’ll send you the whole file. Its a bit big to post here….
        My email address is ###############


  10. win says:

    hi Paul
    from github: prt459 Update SP_VFO_Controller, try to compile, and found:

    SP_VFO_Initialiser:16:3: error: conflicting declaration ‘typedef struct VFOset_type VFOset_type’

    } VFOset_type;


    D:\WIN TITIP\SSB\si5351 prt459\Arduino_si5351_VFO_Controller_Keyer-master\SP_VFO_Controller_Keyer\SP_VFO_Controller_Keyer.ino:556:3: note: previous declaration as ‘typedef struct VFOset_type VFOset_type’

    } VFOset_type;


    SP_VFO_Initialiser:18:28: error: conflicting declaration ‘VFOset_type VFOSet [10]’

    VFOset_type VFOSet[NBR_VFOS]; // array of band parameter sets


    D:\WIN TITIP\SSB\si5351 prt459\Arduino_si5351_VFO_Controller_Keyer-master\SP_VFO_Controller_Keyer\SP_VFO_Controller_Keyer.ino:558:13: note: previous declaration as ‘VFOset_type VFOSet [4]’

    VFOset_type VFOSet[NBR_VFOS]; // array of band parameter sets


    SP_VFO_Initialiser:19:6: error: redefinition of ‘byte v’

    byte v; // index into VFOSet array (representing the current VFO)


    D:\WIN TITIP\SSB\si5351 prt459\Arduino_si5351_VFO_Controller_Keyer-master\SP_VFO_Controller_Keyer\SP_VFO_Controller_Keyer.ino:559:6: note: ‘byte v’ previously declared here

    byte v; // index into VFOSet array (representing the current VFO)


    D:\WIN TITIP\SSB\si5351 prt459\Arduino_si5351_VFO_Controller_Keyer-master\SP_VFO_Controller_Keyer\SP_VFO_Initialiser.ino: In function ‘void setup()’:

    SP_VFO_Initialiser:24:6: error: redefinition of ‘void setup()’

    void setup(){


    D:\WIN TITIP\SSB\si5351 prt459\Arduino_si5351_VFO_Controller_Keyer-master\SP_VFO_Controller_Keyer\SP_VFO_Controller_Keyer.ino:1908:6: note: ‘void setup()’ previously defined here

    void setup()


    D:\WIN TITIP\SSB\si5351 prt459\Arduino_si5351_VFO_Controller_Keyer-master\SP_VFO_Controller_Keyer\SP_VFO_Initialiser.ino: In function ‘void loop()’:

    SP_VFO_Initialiser:81:6: error: redefinition of ‘void loop()’

    void loop()


    D:\WIN TITIP\SSB\si5351 prt459\Arduino_si5351_VFO_Controller_Keyer-master\SP_VFO_Controller_Keyer\SP_VFO_Controller_Keyer.ino:2346:6: note: ‘void loop()’ previously defined here

    void loop()


    Multiple libraries were found for “si5351.h”
    Used: C:\Users\elektro\Documents\Arduino\libraries\si5351
    Not used: C:\Users\elektro\Documents\Arduino\libraries\Si5351Arduino-master
    Not used: C:\Users\elektro\Documents\Arduino\libraries\Etherkit_Si5351-2.1.4
    exit status 1
    conflicting declaration ‘typedef struct VFOset_type VFOset_type’



  11. win says:

    thanks for ypur reply. IDE Arduino 1.8.9


  12. Adrian says:

    Hi Paul. I have IDE Version 1.8.13 and all compile fine with that version. Strangely enough the RTCLIb is giving me a few headaches though. I set the time, but when I re-boot the power the clock restarts at the time it was set originally…..weird. Thanks for great code though!


  13. Anonymous says:

    code error ………..

    ‘typedef struct VFOset_type VFOset_type’


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Shack of VK2KMI

Ham Radio Blog of VK2KMI

Ham Historian

A passionate amateur looks at Melbourne history


My journey of repairing and recycling anything I put my hands on that I believe is still useful. Not just hardware, but including software with relevant content and issues in the field of Cyber Security, Vulnerability Scanning and Penetration Testing.

Amateur radio with VK1DA

Amateur Radio, Computing and other activities of Andrew VK1DA/VK2UH

G4YDM Ham-Radio and SWL news

Radio craft, homebrew, QRP/SOTA, AM


Radio craft, homebrew, QRP/SOTA, AM

VK1DA on the net

Amateur radio experiences with VK1DA

Tj Lab



Amateur Radio and unrelated technologies

Paul Gacek


<span>%d</span> bloggers like this: