You are on page 1of 3


RF Detector using an Arduino

Programmed in Bascom
By Burkhard Kainka (Germany)

Add an RF receiver to a microcontroller and

you open up many possibilities. It doesnt
need to be complicated, for most applications
you can get away with just using a simple
diode detector; in fact we can even use a plain
old LED for the job! Just take an Arduino Uno
with an extension shield and youve already got
all the hardware youll need. Now add the code,
programmed in Bascom.

you werent expecting. In my study at

If you delve back into the history of RF home I can tell when a streetcar passes That doesnt mean
receiver designs you are sure to find ref- by because it noticeably affects the that silicon diodes are
erence to the simple detector receiver received signal strength of an AM sta- all bad for this sort of appli-
using a germanium (Ge) diode. Micro- tion around 720 kHz. cation. You can make use of a bias voltage
controllers have inputs able to measure There are two main reasons for using to offset the diodes conduction threshold.
analog signals so there is no reason why a germanium diode in the detector cir- Figure 2 shows such a circuit without any
we cant just hook up the output of the cuit shown in (Figure 1). First off it has form of tuned circuit for frequency selec-
detector to one of the A/D inputs on the a low forward-conduction voltage. This tion so its got a very wide bandwidth.
microcontroller and see if we can pick up means that signals as low as 100 mV will With no received signal you can measure
some signals. produce an output signal. Secondly its a voltage of around 0.6 V at the diode.
Once youve got it connected you have reverse-voltage resistance is not espe- When a signal is received this voltage
already built a signal strength meter. cially high, thats useful to dissipate level drops noticeably. This circuit works
The readings you make can be useful, any charge accumulating on the output well with RF signals of around 100 mV.
for example, in the world of amateur capacitor. It can be used as an RF signal monitor
radio to tune an aerial. The resonant fre- If you replace it with a silicon diode and works across the entire short wave
quency of the detector circuit needs to be such as a 1N4148, for example, you will band without the need for any selector.
adjusted to be in the range of the mea- need to receive a much stronger signal
sured frequency. You can also tune to a before you start to see an output signal An LED as a detector diode?
nearby medium wave station and check from the circuit. You will also need to Would it be possible to use the LED
the received signal strength in your area. add some form of output load such as a thats already fitted to the Elektor Exten-
You might be surprised to detect things 1 M resistor. sion-Shield? We already know that LEDs


+5V Pull-up

20p Ge
Pin C2

1n Si


Figure 1. The classic detector receiver. Figure 2. Si diode with bias voltage. Figure 3. An LED RF detector. January & February 2016 93


An Integrating Detector
Listing 1. Measuring the LED voltage [1]. Maybe we could do with a bit more gain?
--------------------------------------------------- This could be achieved in principle by
UNO_RX1.BAS B1 RF out, C2 RF in using a higher value of pull up resistor.
--------------------------------------------------- Even better would be to just switch on
$regfile = m328pdef.dat ATmega328p the pull up resistor briefly and then go
$crystal = 16000000 16 MHz
into a high impedance state before the
$baud = 9600
measurement is made. The charge across
$hwstack = 16
the LED will dissipate during the mea-
$swstack = 16
$framesize = 16 surement period. The presence of an RF
signal will increase the discharge rate.
Dim D As Word You can think of the LED junction as hav-
ing a small value of capacitance. Every
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , peak of the received RF signal brings the
Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2 LED briefly into conduction which has the
Config Lcd = 16 * 2 effect of reducing the charge on its capac-
Cls itor slightly. The value of this capacitor
Cursor Off
is only a few picofarads. That means you
only need a very low level of RF current
Config Adc = Single , Prescaler = 64 , Reference = Avcc 5V
to produce a measurable effect. To give
Config Timer1 = Pwm , Prescale = 1 , Pwm = 10 , Compare A Pwm = Clear better sensitivity you can increase the
Up delay between turning off the pull up and
Tccr1a = &B10000010 Phase-correct PWM, Top=ICR1 making a measurement. This will how-
Tccr1b = &B00010001 Prescaler=1 ever make the circuit sensitive to low fre-
quency signals which can cause interfer-
D = 8 1 MHz ence. For this reason its better to make
Icr1 = D the measurement quickly after the pull
Ocr1a = D / 2 up has been turned off using a relatively
Portc.2 = 1
short sample time (Prescaler = 8).
The program in Listing 2 performs aver-
aging on the measurement samples to
D = Getadc(2) determine the zero level D0. By comparing
Print D the zero level with the input we can find
Locate 1 , 1 out if an RF signal has been received. A
Lcd D drop of three A/D steps of the LED voltage
Lcd is recognized as the threshold to indicate
Waitms 500 a signal has been received. Tests indicate
Loop that a received RF signal of around 50 mV
is necessary. To flag this event, LED2
on the Elektor Shield is lit and a tone is
also function as a photo diode, a voltage the value 410 which corresponds to a produced at B2. You can hook up a sim-
stabilizer, limiter and a varicap, surely we voltage at the LED of around 2 V. Con- ple piezo loudspeaker here to make the
can get one to work as an RF detector as nect a 10 cm length of insulated wire to tone audible. The signal strength is also
well. LED1 on the shield is already con- C2 to act as an antenna. Attach a bare transferred serially but not available on
nected to the analog input ADC2. There wire at B1 and hold the other end of it. the LCD due to timing constraints. When
is also a 1 k resistor in series with the Your body is now connected to the signal an RF signal is received at the input an
LED but that should not give a problem. and becomes an antenna for the signal (almost) constant tone will be audible at
The internal 30-k pullup resistor can which can be picked up by a normal AM the output.
be configured to provide a bias voltage, radio receiver. Now take the insulated With this set up you can send and receive
perfect; we really dont need anything wire on C2 and couple it to the RF signal. Morse characters. For this the output
else to build the circuit (see Figure 3). You will see the measured value drop to frequency was raised to 2 MHz to give
below 400. Its interesting to note that increased range. For tests you can dab
And so to the software! Now we have the measured value remains at a con- your finger on the output pin B1 to send
already built our little RF test lab (List- stant level. The RF oscillations are not Morse signals. The other hand should
ing 1) and can begin programming it to registered because the sample rate of the close enough to the receiving antenna
generate an RF signal. A 1 MHz square A/D converter is relatively low and this to ensure reception of the signals. You
wave signal is output from pin B1. produces an averaging effect on the mea- can of course set up two Arduinos so that
The program enables the pull up resistor sured signal. The measurement shown is signals can be sent and received.
on port pin C2 and continually measures the average voltage across the LED which For test purposes a sine wave genera-
the voltage on ADC2. Here you can read drops as the RF signal gets stronger. tor was used as a RF generator with a

94 January & February 2016


finger touching the output signal so the

Listing 2. RF receiver with sound output [1].
body works as an antenna, it was possible
to achieve a range of around 39 inches
using an output signal of 16 Vpp and a -------------------------------------------------------
frequency of 1 MHz. UNO_RX2.BAS B1 RF out, C2 RF in
So what can the circuit be used for? With- -------------------------------------------------------
out any additional circuitry you can use it $regfile = m328pdef.dat ATmega328p
to track down sources of RF interference. $crystal = 16000000 16 MHz
Many switch mode power supplies are $baud = 9600
guilty of high levels of RF noise. Energy $hwstack = 16
saving lamps and conventional fluores- $swstack = 16
$framesize = 16
cent lamps are also culprits when it comes
to unwanted RF noise especially in the
Dim D As Word
medium wave band. All of these sources
Dim D0 As Word
can be easily detected with the integrat-
Dim N As Byte
ing LED detector you have built from an
Arduino. Ddrb.2 = 1

By the way, dont overlook the other use- Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 ,
ful components on the extension shield Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2
(Figure 4). There are two push buttons Config Lcd = 16 * 2
and a pot to play with. With a little inge- Cls
nuity you could make use of these to Cursor Off
provide sensitivity adjustment, a Morse
key, call button, mute and standby Config Adc = Single , Prescaler = 8 , Reference = Avcc 5V
Web Link Config Timer1 = Pwm , Prescale = 1 , Pwm = 10 , Compare A Pwm = Clear
Tccr1a = &B10000010 Phase-correct PWM, Top=ICR1
Tccr1b = &B00010001 Prescaler=1

D = 4 2 MHz
Icr1 = D
RF in RFout Ocr1a = D / 2

D = 0
S2 S1
For N = 1 To 50


10k Portc.2 = 1
Waitus 100
Portc.2 = 0
D = D + Getadc(2)
Next N
28 27 26 25 24 23 22 21 20 19 18 17 16 15
D0 = D / 50





1 2 3 4 5 6 7 8 9 10 11 12 13 14 Portc.2 = 1
Waitus 100
Portc.2 = 0
16MHz D = Getadc(2)
If D < D0 Then
22p 22p D = D0 - D
If D > 2 Then
Print D
1 2 3 4 5 6 7 8 9 10 11 12 13 14 Locate 1 , 1

Lcd D
150307 - 14
Sound Portb.2 , 20 , 4000 LED2 and Piezo
End If
End If
Figure 4. Except for the two antennae and the
piezo beeper everything else is already on board
the Extension shield. January & February 2016 95