Introduction: Android On-The-Go (OTG) LC-Meter

About: I am a retired Electronic Systems Engineer now pursuing my hobbies full time. I share what I do especially with the world wide student community.

Several years ago I built a LC-Meter based on an open-source design of a "Surprisingly Accurate LC meter" by Phil Rice VK3BHR at

Presented here is a modified design based on a Microchip PIC18F14K50 USB Flash Microcontroller which is connected to an Android phone using the On-The-Go (OTG) mode. The phone provides power to the circuitry and an Android Application provides the Graphical-User-Interface (GUI).

The following are the highlights of the design:

  1. Single PIC18F14K50 microcontroller with USB interface and internal analog comparator
  2. Simple c-code on the microcontroller implementing a basic frequency counter
  3. GUI Test code in Qt Creator and Android application using Android Studio
  4. All calculations carried out in higher level language
  5. Low power consumption ~ 18 mA at +5V
  6. Design verified by building a bread-board and engineered unit

I wish to acknowledge use of the Usb serial controller for Android v4.5 example code in implementing the OTG connectivity.

Step 1: Theory of Operation & Circuit Schematic

Operating principle

The basic principle of operation is based on determining the resonant frequency of a LC parallel tuned circuit.

Refering the equivalent circuit: The internal comparator is set-up as an oscillator whose frequency is determined by the LC parallel resonant circuit.

L1/C7 form the core resonant circuit oscillating at ~50 kHz. Let us call this F1

A capacitor of accurate value, C6 is added in parallel during the calibration cycle. The frequency then changes to ~ 30 kHz. Let us call this F2.

The resonant frequency changes when either an unknown inductor LX is connected in series with L1 or an unknown capacitor CX is connected in parallel with C7. Let us call this F3.

Measuring F1, F2 & F3 it is possible to calculate the unknown LX or CX using the equations shown.

The calculated and displayed values for two conditions 470 nF and 880 uH are shown.

Circuit Schematic

The PIC18F14K50 is a single chip solution for the OTG-LC Meter as it provides an internal comparator which can be used for the LC-Oscillator and an in-built USB interface permitting connection to a PC-USB port or the Android Phone OTG Port.

Step 2: Android Application

Operating Steps:

  1. After setting up the Android phone to development mode, install the app-debug.apk from the software step using a PC and suitable USB cable.
  2. Connect the LC-meter to the Android phone using an OTG adaptor.
  3. Open the LC meter Application (Figure 1)
  4. Press the Connect button, results in request for connection (Figure 2)
  5. With probes open in C-Mode or shorted in L-Mode, press Calibrate, results in Ready (Figure 3)
  6. In C-Mode, connect unknown capacitor (470 nF) and press Run, (Figure 4, 5)
  7. In L-Mode, connect unknown inductor (880 uH) and press Run (Figure 6,7)

Step 3: Power Consumption

The PIC18F14K50 is a USB Flash Microcontrollers with nanoWatt XLP Technology.

The three pictures show the current drawn by the LC-Meter hardware in OTG-Mode during different stages of operation:

  1. When the hardware is connected to the Android phone but the application is not initiated, 16.28 mA
  2. When the application is initiated and is in RUN mode, 18.89 mA
  3. Only for 2 Seconds when Calibration is initiated, 76 mA (additional relay current)

Overall the application when running draws less than 20 mA which would be of the order drawn by the 'Torch' in an Android phone.

Step 4: Hardware

The PCB design was carried out in Eagle-7.4 and the CAD files are attached in .Zip form. They contain all details including the Gerber data.

However for this project, a breadboard model was first fabricated. After finalization of the circuitry the detailed design was carried out in CADSOFT Eagle 7.4 and the PCB fabricated using the toner-transfer method.

Card level tests were carried out using the Qt test software before packaging the card into the plastic enclosure.

Fabrication and test of two units helps in validating the repeatability of the design.

Step 5: Software

This project involved the development of code on three development platforms:

  1. The development of the embedded code for the PIC18F14K50 microcontroller
  2. PC based test/independent application in Qt on Linux
  3. Android application using Android Studio on Linux

Microcontroller Code

The C-Code for the PIC18F14K50 was developed under MPLAB 8.66 using CCS-C WHD Compiler. The code and fuze file are attached:

  1. 037_Android_2_17 Sept 17.rar
  2. PIC_Android_LC-Meter.hex (open in MPLAB with a checksum 0x8a3b)

Qt test application on Linux

A Qt test application was developed under Qt Creator 4.3.1 with Qt 5.9.1 under "Debian GNU/Linux 8 (jessie)". The code is attached:

Aj_LC-Meter_18 Sept 17.Zip

This can be used as an independent PC based application using the LC-meter hardware

Android application on Linux

Developed under Android Studio 2.3.3 with sdk 26.0.1.

Tested on Android phone, Radmi MH NOTE 1LTE with Android version 4.4.4 KTU84P

LC-Meter_19 Sept

apk file app-debug.apk

Microcontroller Contest

Participated in the
Microcontroller Contest