Marco Zonca
Published © GPL3+

Radio Frequency power detector "sniffer"

A wide range RF detector 50-3000Mhz with battery charger, ATtiny micro controller and SMD.

AdvancedFull instructions provided3,879
Radio Frequency power detector "sniffer"

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Microchip ATtiny 1614 Processor
×1

Story

Read more

Schematics

PCB rf-sniffer top

PCB rf-sniffer bottom

PCB rf-sniffer topsilk

Code

RF-sniffer code

Arduino
/*
 * ard-rf-sniffer (instrument monitor or threshold alarm)
 * by Marco Zonca 05/2022
 * 
 * LT5534 50-3000Mhz rf detector IC, ATTiny1614 3.3V MCU, LIR2450 rechargeable battery, MCP73831 4.2V charger IC, active buzzer, 
 * 2x 2 pos. dipswitch, trimmer, RGB led, red led, SMA-F antenna, SMA-M panel connector, on/off switch, some SMD resistors and capacitors
 * 
 * Remember to connect a specific antenna for every rf frequency range you want to detect;
 * in some cases a simple ring wire of any lenght can be enough as "antenna", expecially when the rf signal is strong
 * 
 * LT5534 datasheet says to not overcharge the rf input pin with signals > 10dbm (i.e. handheld 5W radio tx near the IC);
 * if it is the case, I suggest to put an attenuator between the antenna and the circuit (i.e. 20dbm SMA-MF serial attenuator).
 * Additionally use full metal box or, as I did, cover the interiors of the plastic box with copper foil to avoid signals passing trought,
 * or paint/spray with conductive material the interiors of the box (i.e. graphite).
 * 
 */

byte pin_ledred = 0;
byte pin_ledgreen = 6;
byte pin_ledblue = 7;
byte pin_DS1_instrcomparat = 1;
byte pin_DS1_buzz = 2;
byte pin_DS2_bit1color = 3;
byte pin_DS2_bit0color = 4;
byte pin_threshold = 8;
byte pin_vrf = 9;
byte pin_buzzer = 10;

byte a=0;
byte b=0;

bool isBuzzer=false;
bool isInstrument=false;
byte ledColor=0;
byte pin_LED=0;
byte buzlevel=250;  // buzzer loudness: 125/255 (125=50%, max 255=100%)
byte Off=0;
byte On=75;  // led brightness: 75/255 (75=30%, max 125=50%)

int rfSignal=0;
int rfThreshold=0;
int setBUZ=0;
int setLED=0;

long LedblinkMillis=10000;
unsigned long prevLedblinkMillis=0;
long ReadSetupMillis=2000;
unsigned long prevReadSetupMillis=0;

void setup() {
  pinMode(pin_ledred, OUTPUT);
  pinMode(pin_ledgreen, OUTPUT);
  pinMode(pin_ledblue, OUTPUT);
  pinMode(pin_buzzer, OUTPUT);
  pinMode(pin_DS1_instrcomparat, INPUT_PULLUP);
  pinMode(pin_DS1_buzz, INPUT_PULLUP);
  pinMode(pin_DS2_bit1color, INPUT_PULLUP);
  pinMode(pin_DS2_bit0color, INPUT_PULLUP);
  pinMode(pin_threshold, INPUT);
  pinMode(pin_vrf, INPUT);
  readSetup();
  initialShow();
  prevLedblinkMillis=millis();
}//setup()

void loop() {  // ------------------------------------------------------------>
  rfSignal=analogRead(pin_vrf);
  rfThreshold=analogRead(pin_threshold);
  if (isInstrument) {  // -------- instrument monitor
      setBUZ=map(rfSignal,rfThreshold,1023,0,buzlevel);
      if (isBuzzer) analogWrite(pin_buzzer,setBUZ);
      setLED=map(rfSignal,rfThreshold,1023,0,On);
      if (pin_LED != -1) analogWrite(pin_LED,setLED);
      delay(100);
      if (isBuzzer) analogWrite(pin_buzzer, Off);
      if (pin_LED != -1) analogWrite(pin_LED,Off);
    } else {  // ----------------- threshold alarm
      if (rfSignal > rfThreshold) tAlarm();
  }
  if ((isInstrument==false) && (prevLedblinkMillis + LedblinkMillis) < millis()) blinkLed();
  if ((prevReadSetupMillis + ReadSetupMillis) < millis()) readSetup();
}//loop() --------------------------------------------------------------------<

void tAlarm() {
    for (a=1;a<=3;a++) {
      if (pin_LED != -1) analogWrite(pin_LED,On);
      if (isBuzzer) analogWrite(pin_buzzer, buzlevel);
      delay(200);
      if (pin_LED != -1) analogWrite(pin_LED,Off);
      if (isBuzzer) analogWrite(pin_buzzer, Off);
      delay(200);
    }
}//tAlarm()

void blinkLed() {
  if (pin_LED != -1) {
    analogWrite(pin_ledgreen,On);
    delay(200);
    analogWrite(pin_ledgreen,Off);
    delay(200);
  }
  prevLedblinkMillis=millis();
}//blinkLed()

void initialShow() {
  if (isBuzzer) analogWrite(pin_buzzer, buzlevel);
  analogWrite(pin_ledred,On);
  delay(200);
  if (isBuzzer) analogWrite(pin_buzzer, Off);
  analogWrite(pin_ledred,Off);
  analogWrite(pin_ledgreen,On);
  delay(200);
  analogWrite(pin_ledgreen,Off);
  analogWrite(pin_ledblue,On);
  delay(200);
  analogWrite(pin_ledblue,Off);
  delay(200);
}//initialShow()

void readSetup() {
  isBuzzer=!digitalRead(pin_DS1_buzz);
  isInstrument=!digitalRead(pin_DS1_instrcomparat);
  a=!digitalRead(pin_DS2_bit0color);
  b=!digitalRead(pin_DS2_bit1color) * 10;
  ledColor=a+b;
  switch (ledColor) {
    case 0:
      pin_LED=-1;  // no led
    break;
    case 1:
      pin_LED=pin_ledred;
    break;
    case 10:
      pin_LED=pin_ledgreen;
    break;
    case 11:
      pin_LED=pin_ledblue;
    break;
  }
  prevReadSetupMillis=millis();
}//readSetup()

Credits

Marco Zonca

Marco Zonca

12 projects • 43 followers
"From an early age I learned to not use pointers"

Comments