EMF Detector

🕒 2 min read

Check out the intensity of emf produced by an electrical appliance using this EMF detector! This arduino EMF detector project is based on Aaron ALAI original EMF Detector project.


In this project, the arduino will determine the amount of emf detected by reading the value received from the antennae attached to analogue input 5. I modified the code to produce a clicking sound, where the rate of the clicking sound produced will be proportional to the intensity of emf detected. When there is high intensity of emf around a electrical appliance, the rate of the ‘click’ sound will be very rapid. Whereas when there is little emf around, the rate of the ‘click’ sound will not be that rapid.


Parts Required

  • Piezo speaker x 1
  • Arduino Uno x 1
  • Jumper wires
  • LED x 1
  • 330Ω resistor x 1
  • 3.3MΩ resistor x1
  • Wire x 1 (To be used as antennae)



[Coming Soon…]





#define sample 300                           //this is how many samples the device takes per reading
                                             //more information for #define http://arduino.cc/en/Reference/Define 
int inPin = 5;                               //analog 5
float val;                                   //where to store info from analog 5
int pin11 = 11;                              //output of red led
int speakerPin = 9;
int array1[sample];                         //creates an array with number of elements equal to "sample" 
                                            //more information about arrays http://arduino.cc/en/Reference/Array
unsigned long averaging;                    //the program uses this variable to store the sum of each array it makes

void setup() {
   pinMode(11, OUTPUT); 
   pinMode(speakerPin, OUTPUT);

void loop() {
for(int i = 0; i < sample; i++){             //this code tells the program to fill each element in the array we made with
   array1[i] = analogRead(inPin);            //information from the antenna wire coming out of the Arduino
   averaging += array1[i];                   //more information about for loops http://arduino.cc/en/Reference/For
}                                            //the averaging line is simply saying: add averaging to whatever is in array position i
                                             //averaging += array[i] is the same as averaging = averaging + array[i]
                                             //for more information about += http://arduino.cc/en/Reference/IncrementCompound

val = averaging / sample;                    //here the program takes the sum of all numbers in array1, and divides by the number of elements "sample"

val = constrain(val, 0, 100);                //this constrains the variable value to between two numbers 0 and 100                                       
    // val = map(val, 0, 100, 0, 255);       //for more information about constrain http://arduino.cc/en/Reference/Constrain
 for (int i = 0; i < 2; i++) {   
    digitalWrite(pin11, HIGH);         
    delay(104-val);                          //the map statement tells the program to map out 0-100 to 0-255, 255 is 
    digitalWrite(pin11, LOW);                //the threashold of analogWrite for more information about map http://arduino.cc/en/Reference/Map
    averaging = 0;                           //this line of code sets averaging back to zero so it can be used again

for (int i = 0; i < 2; i++) {
int tone = 956;
int duration = val;
for (long i = 0; i < duration * 100L; i += tone * 2) {
digitalWrite(speakerPin, HIGH);
digitalWrite(speakerPin, LOW);
  averaging = 0;   

Share your love

Leave a Reply

Your email address will not be published. Required fields are marked *