Arduino Energy & Sustainability Technology
Making the Arduino EMF detector
https://youtube.com/watch?v=y1Bke3750WE%26en%26fs%3D1%26rel%3D0%26showinfo%3D0%26ap%3D%252526fmt%253D22

Aaron ALAI’s EMF detector project looked so simple and fun I had to give it a try. After putting it together, I liked it so much that I went and built a more ‘meter-like’ version using an LED bargraph –

EMF

Arduino code is available here.

As I mention in the vid, I was a bit concerned the wire probe might be affected by the LEDs I mounted nearby — but from what I can tell, it still seems (relatively) accurate. A short walk around my workspace even revealed a few items I’d forgotten were plugged in – helpful! I’m sure there are many ways in which this project could be used/repurposed/modded – I plan on converting the readings to sound when I get the chance. If you make one be sure to submit a pic to the Flickr pool and/or send us a link.

55 thoughts on “Making the Arduino EMF detector

  1. In the code that comes with this project I see:

    total -= readings[index]; // subtract the last reading
    readings[index] = val; //read from the sensor
    total += readings[index]; //add the reading to the total
    index = (index + 1); // advance to the next index

    It should be noted that the smoothing doesn’t happen without removing the first line of those shown here. And then you get a problem when you start over from index = 0; so this should be changed to:

    readings[index] = val;
    total = 0;
    for(int i = 0; i < NUMREADINGS; i++){
    total += readings[i];
    }
    index += 1;

  2. This could be useful for activating something else; like an inductive relay, but in a non-contact fashion. (Like triggering a low-voltage circuit when a motor starts)

    1. Excellent suggestion. I have a need for something like that to trigger the big dust collector when I use the saw or planer. I could even trigger it at higher levels as the power board is on all the time. I just sniff for the higher amperage and even have a delay cut off. Awesome project!

      1. Excellent suggestion. I have a need for something like that to trigger the big dust collector when I use the saw or planer. I could even trigger it at higher levels as the power board is on all the time. I just sniff for the higher amperage and even have a delay cut off. Awesome project!

  3. Hello, It is really gr8!

    can you please tell me, how to get this done without using a microcontroller.
    I am working on a similar model as well.
    nknitinkushwaha[at]gmail[dot]com

    Thanks.

  4. Hello,

    I am a bit confused, how do i power this up,

    I bought ATMega328 Microcontroller,
    uploaded the sketch, now on the wiring part, i see in the ckt diagram,

    I am not able to see where the Orange wire goes to,
    Pins 2 thro 11 are on the Digital signal side.
    Common cathode gets to analog5–3.3M–gets to GND.

    still i am getting it to work,

    Am i missing something?

    I have a doubt on where the Orange wire and Probe wire goes to?

    where do i connect the VCC +5v?

    Please reply ASAP.

    Thanks

    1. It loks like the orange wire is going to 5v.. I think it is for something else because the resistor goes between ground and A5, and then the probe comes off of A5 also.. All of the other outputs are + anodes and then you run one ground for all of them.. I left off the other resistors because my LEDs require more power to light, plus they are brighter that way.. I don’t really care if they burn out either I have thousands of them.. Good show!!

    1. There is a link right under the Wiring chart for the circuit.. Click the word “HERE” and it will take you to a website where you can download a file with the code in it!! This is a really cool project and it works really well..

  5. thanks for simple schematic, and the code can be found on the video description or click on the Flickr pool , i will definitely try it :D

  6. i watched the vid on the arduino emf detector, and i thought i would build one of my own. im a bit confused right now, so i figured i would ask the experts. how would i go about making one out of a hand-held am fm sports radio?

    1. I am actually in the process of Trying to build an Oscillator for this Project, But I wonder if there is a way to use one of the Unused Pins as an output for a buzzer.. You have to be careful though with that because any time you have power going into a coil you are generating EMF.. And this is a very sensitive circuit.. we don’t want to read our own EMF now do we? :-)

    1. I built it and tried to detect my cellphone.. It barely had any EMF.. Maybe the phone is not powerful enough, or maybe the project just is not sensitive enough.. I tried making it as sensitive as possible for Paranormal investigation.. And it now detects when I get close to it.. But not on the cellphone at all..

  7. Just an idea, but if you think that the wire connector is effecting the readings, im sure you could build an RF cage around it with some thin metal…

    Then again that may make it worse and pick up more interference, well food for thought.
    PEACE

    1. Actually some metal Shielding that was hooked into the ground might eliminate board interference all together, then the only EMF reading would be at the Antenna, Where it belongs.. Good thinking!! :-)

  8. For those of you needing the code, I will put it here just copy and paste it into your program editor and I hope this will help.. I changed a few sensitivity settings on mine, but it works.. Follow instructions in the Comments of the code to change them.

    // EMF Detector for LED Bargraph v1.0
    // 5.12.2009
    // original code/project by Aaron ALAI – aaronalai1@gmail.com
    // modified for use w/ LED bargraph by Collin Cunningham – collin@makezine.com

    #define NUMREADINGS 1 // raise this number to increase data smoothing

    int senseLimit = 550; // raise this number to decrease sensitivity (up to 1023 max)
    int probePin = 5; // analog 5
    int val = 0; // reading from probePin

    int LED1 = 11; // connections
    int LED2 = 10; // to
    int LED3 = 9; // LED
    int LED4 = 8; // bargraph
    int LED5 = 7; // anodes
    int LED6 = 6; // with
    int LED7 = 5; // resistors
    int LED8 = 4; // in
    int LED9 = 3; // series
    int LED10 = 2; //

    // variables for smoothing

    int readings[NUMREADINGS]; // the readings from the analog input
    int index = 0; // the index of the current reading
    int total = 0; // the running total
    int average = 0; // final average of the probe reading

    void setup() {

    pinMode(2, OUTPUT); // specify LED bargraph outputs
    pinMode(3, OUTPUT);
    pinMode(4, OUTPUT);
    pinMode(5, OUTPUT);
    pinMode(6, OUTPUT);
    pinMode(7, OUTPUT);
    pinMode(8, OUTPUT);
    pinMode(9, OUTPUT);
    pinMode(10, OUTPUT);
    pinMode(11, OUTPUT);

    Serial.begin(9600); // initiate serial connection for debugging/etc

    for (int i = 0; i = 1){ // if the reading isn’t zero, proceed

    val = constrain(val, 1, senseLimit); // turn any reading higher than the senseLimit value into the senseLimit value
    val = map(val, 1, senseLimit, 1, 1023); // remap the constrained value within a 1 to 1023 range

    total -= readings[index]; // subtract the last reading
    readings[index] = val; // read from the sensor
    total += readings[index]; // add the reading to the total
    index = (index + 1); // advance to the next index

    if (index >= NUMREADINGS) // if we’re at the end of the array…
    index = 0; // …wrap around to the beginning

    average = total / NUMREADINGS; // calculate the average

    if (average > 50){ // if the average is over 50 …
    digitalWrite(LED1, HIGH); // light the first LED
    }
    else{ // and if it’s not …
    digitalWrite(LED1, LOW); // turn that LED off
    }

    if (average > 150){ // and so on …
    digitalWrite(LED2, HIGH);
    }
    else{
    digitalWrite(LED2, LOW);
    }

    if (average > 250){
    digitalWrite(LED3, HIGH);
    }
    else{
    digitalWrite(LED3, LOW);
    }

    if (average > 350){
    digitalWrite(LED4, HIGH);
    }
    else{
    digitalWrite(LED4, LOW);
    }

    if (average > 450){
    digitalWrite(LED5, HIGH);
    }
    else{
    digitalWrite(LED5, LOW);
    }

    if (average > 550){
    digitalWrite(LED6, HIGH);
    }
    else{
    digitalWrite(LED6, LOW);
    }

    if (average > 650){
    digitalWrite(LED7, HIGH);
    }
    else{
    digitalWrite(LED7, LOW);
    }

    if (average > 750){
    digitalWrite(LED8, HIGH);
    }
    else{
    digitalWrite(LED8, LOW);
    }

    if (average > 850){
    digitalWrite(LED9, HIGH);
    }
    else{
    digitalWrite(LED9, LOW);
    }

    if (average > 950){
    digitalWrite(LED10, HIGH);
    }
    else{
    digitalWrite(LED10, LOW);
    }

    Serial.println(val); // use output to aid in calibrating
    }
    }

    1. Please someone program it like the richter scale where every bar is 10x the previous one, that would be GREAT, it would let us detect small and large fields with accuracy relative to the size, also please add a SLOWER averaged serial right function if its not already included!!!

      1. I will help you since no one seems to want to hep so far.. :-P

        Look at the Code and Where you see this:

        if (average > 150){ // and so on …
        digitalWrite(LED2, HIGH);
        }
        else{
        digitalWrite(LED2, LOW);
        }

        if (average > 250){
        digitalWrite(LED3, HIGH);
        }
        else{
        digitalWrite(LED3, LOW);
        }

        if (average > 350){
        digitalWrite(LED4, HIGH);
        }

        Etc.. change the number to where you want it, That is the number, Basically telling the Uno that “If the Average of the reading is Greater than that presented number, Send that Output High, Otherwise Make it low.. High=on low=off.. I hope this helps you some..

    2. I am very confused. How do you add voltage to it to power it up and what would the piece be called? I have all of my resistors, LED bar graph, and wire (in A5) on the board and I’m not sure where to go from there. It would be super helpful if there were a list of materials required for this project..

  9. Any idea to display the digital value of output as shown in LCD bar graph???? ……..Will be very useful………..

  10. Hmmm, interesting….maybe attach one of these to the main power cable on the washer, program some limits, and detect when the washer cycle is complete, as there should be a significant drop in current. Use button to put the A in ‘monitor’ mode when it cycle starts…maybe have a dial to set the limit instead of coding it. And then it sends a response to my home network server when finished. Although I don’t have any CAT5 in the basement and a real pain to run it down there, so I might have to look into a wireless version.

  11. Please someone program it like the richter scale where every bar is 10x the previous one, that would be GREAT, it would let us detect small and large fields with accuracy relative to the size, also please add a SLOWER averaged serial right function if its not already included!!!!

  12. I want to figure out a way that I can either use one of the unused outputs as an Oscillator for a buzzer, or analog wire it with resistors to control an RC oscillator.. Maybe hook it up ths way.. One resistor of a different value onto each Anode, And the Diodes to prevent current Backup, and then put it in the RC Oscillators Capacitor instead of being one resistor that will keep the oscillator at a fixed pitch use multiple Resistors hooked up instead, That way with each LED that lights the Oscillator Pitch will become higher and higher.. I don’t think a Blocking Oscillator would Suffice for this though as it Emits EMF, Which would cause interference in the readings.. It might feed right back into the circuit.. That would be bad.. :-(

    But an Astable Multivibrator type Circuit might not put off so much EMF.. or even a NAND Oscillator.. or a 555 Timer.. Idk.. :-)

    1. When I try to upload the program to my arduino i get this error

      EMF_detector_LED_bargraph_smooth.cpp:30:5: error: ‘int index’ redeclared as different kind of symbol
      c:userssamdownloadsmpide-0023-windows-20120903mpide-0023-windows-20120903hardwarepic32compilerpic32-toolsbin../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/string.h:56:8: error: previous declaration of ‘char* index(const char*, int)’
      EMF_detector_LED_bargraph_smooth.cpp: In function ‘void loop()’:
      EMF_detector_LED_bargraph_smooth.cpp:63:28: error: invalid types ‘int [15][char*(const char*, int)]’ for array subscript
      EMF_detector_LED_bargraph_smooth.cpp:64:19: error: invalid types ‘int [15][char*(const char*, int)]’ for array subscript
      EMF_detector_LED_bargraph_smooth.cpp:65:28: error: invalid types ‘int [15][char*(const char*, int)]’ for array subscript
      EMF_detector_LED_bargraph_smooth.cpp:66:23: error: assignment of function ‘char* index(const char*, int)’
      EMF_detector_LED_bargraph_smooth.cpp:66:23: error: cannot convert ‘char* (*)(const char*, int)’ to ‘char*(const char*, int)’ in assignment
      EMF_detector_LED_bargraph_smooth.cpp:68:18: error: ISO C++ forbids comparison between pointer and integer
      EMF_detector_LED_bargraph_smooth.cpp:69:15: error: assignment of function ‘char* index(const char*, int)’
      EMF_detector_LED_bargraph_smooth.cpp:69:15: error: cannot convert ‘int’ to ‘char*(const char*, int)’ in assignment

      Any Ideas??

  13. Hi Im trying to build this project but seem to be getting it wrong if anyone would mentor me for this one project I would be grateful really @dragonmaster198577 if you could help me I would love it

  14. Right peeps, can anyone advice on this one?
    If we were to remove the chip of the board and we wanted to power this up using a 9v battery for example, what would we need between the battery and the Atmega for this to work? Any ideas all?

    Thanks

    1. Yeah, you should be able to. Codewise, there hasn’t really been much that would effect compatibility between models.

  15. I tried this code, but, getting a lot of errors. Is this supposed to be running in Processing or Arduino IDE?

Comments are closed.

Tagged