ATTiny EMF Detector





Introduction: ATTiny EMF Detector

About: Electrical engineering student interested in hardware hacking, robotics, and photography. Learning Perl / Linux; speaks C / JAVA.

As is tradition, finished product image first.

Inspired from masteruan's similar build, which I will link below, I set off to build my own micro sized Electro-Magnetic Field Detector. The goals were to make this as small as possible while retaining enough stability that it would not break in someone's pocket. The challenge to that was the antenna. As you can see from my finished picture, I decided to use the protoboard to help the antenna keep its shape, which I believe it does marvelously.

Masteruan's build: Attiny85-EMF-detector

Step 1: Parts

[1x] Atmel ATTiny85V microcontroller and socket

[1x] 3.9M Ω resistor

[4x] LEDs (Colors many vary)

[Various] Jumper wires

[1x] Push button or switch

[1x] Button cell battery and holder

Step 2: Coding and Testing

Upload the code to the ATTiny85, instructions for this can be found all over the internet so refer to one of those if you've never worked with a "raw" microcontroller before.

Build the project on a breadboard to test the wiring before moving onto the protoboard. This step is probably the most important as its much more difficult to fix when the project is already soldered to a board.

As my code changed very little, and you'll most likely have to trouble shoot a few things yourself, I've attached the original Github code link here: Github

Step 3: Prep the Antenna

Coil the antenna to the desired shape. This can easily be done by wrapping a section of wire around a pencil then stretching it to a good length. What is a good length you ask? Well as you know from asking such a great question, the wire length will affect the frequency it pick up. However, since we are not looking for a specific frequency and instead are basically looking for any electrical noise, the length is not crucial to the build. I simply used a spare wire that held it shape when coiled.

My wire happened to be slightly larger than the protoboard's holes, so I drilled out the ones it was to pass through.

Step 4: Organize

With the largest component in place, the antenna, I decided where to place the rest of the parts. Wanting the strength LEDs up near the front, I placed those then worked backwards in such a way that (I thought) the ATTiny would be easy to wire in.

Step 5: The End

With everything in place, it was an easy solder job to finish. My project was not originally going to use a push button, just battery removal for power on/off. But I decided to add one after, as you can see by the stacked board at the bottom. I reused some scrap wire that had used shrink wrap on it, so I decided to waste not and use that too. It helped insulate my bad wiring job from shorting out.

Step 6: Things to Change

If I were to rebuild this project, I would firstly change the layout. Opting to place the button cell on the bottom of the board so the button can be on top. In such a way that he wires are organized better. Or specifically design a pcb for it. Maybe change the button for a switch so I don't have to hold it on. Perhaps use a 3D printed cover for the bottom half to cover the electronics.



    • Water Contest

      Water Contest
    • Creative Misuse Contest

      Creative Misuse Contest
    • Clocks Contest

      Clocks Contest

    26 Discussions


    Question 2 months ago

    Is that really a 3.9 M Ohm resistor? and how many watts? I'm wanting to build this myself, but don't want to purchase what I don't need.

    1 more answer

    Yep, 3.9 M ohm, ¼ watt. Wattage isn’t important though since the power source is small. And any resistor will work, it will just change the sensitivity threshold. I’d recommend using whatever resistor you have on hand.


    5 months ago

    Cool! Is it possible to vary the sensitivity/threshold of this simple emf detector? Maybe using a variable resistance instead fixed 100Ω resistor, or how ?

    2 replies

    I also updated the parts list to reflect the actual value of resistor I used, 3.9M Ω.

    Thanks and that's a great question. Changing the resistor should change what frequency is picked up. I don't think this particular circuit will ever be super acurate at a specific frequency though. But if you built it off an arduino (or other variations of) and had it pass back some serial data to the computer you could see how various modifications affect it.

    I think this would be better if you feed the antenna to pin 2 via a diode and use a potential divider to feed sufficient DC to the open end of the antenna to slightly forward bias the diode, and put a small capacitor across the input resistor. That way it will be more like an AM Radio detector. As it is you will have AC noise appearing at pin 2, but you are measuring a DC value randomly depending on how long it takes to measure the analog signal. (Typically 100micro seconds on a 16MHz clocked Arduino ). This means a lot of reads are with a negative value yielding zero and will not be included in the result thus affecting your average.

    Also I don't know what your clock frequency is on the ATTiny. If it is at 1MHz then the analogRead will take much longer. And, since that command is running inside loop() the other commands there will add to the cycle time between reads. You might consider setting the ADC to run freely and generate an interrupt on each conversion. You can then read the ADCH and ADCL registers (or just ADCH if you left shift the results and only require 8 bit resolution - see ADLAR bit explanation in datasheet) to get your measurement.

    Since the capacitor I mentioned and the input resistor form a low pass filter you can choose what frequency range is of interest to some extent but moreover you could do away with your average calculation and just directly light the LEDS according to the DC voltage on pin 2.

    1 reply

    All excellent notes. I built this project as the 'minimum viable option' between school projects with quick & dirty hardware results and someone else's code. The low pass filter would be very beneficial, as you mentioned, for a more accurate reading, wish I would have thought of that. I didn't have terrible results, but def not scientifically accurate ones. I used the default 1MHz clock and it had a noticeable delay. It was my first time using an attiny chip not on an arduino type board, so I'll have to read up on your notes here. I appreciate the feedback!

    Your parts list states 100 Ohm resistor but the breadboard schematic shows 100k and the actual breadboard and protoboard devices appear to have 3M9. A high value seems appropriate, but what worked for you in what situation?

    1 reply

    The resistor value doesn't matter too much unless you are looking for a specific frequency. I liked the results I got with the 3.9M Ω resistor so I updated the parts list to reflect that.

    This all looks very neat - nice!
    Could this be easily modified to make an EM interference detector?
    I'm sure that some light switches in my mother's house are 'dirty' and causing spikes in the circuit and blowing the bulbs - it'd be handy to have a small device I could hold next the switch and check for interference when I turn it on and off

    4 more answers

    I don't think that is very likely. The main reason lamps fail is excessive heat. That could be the result of excess voltage but that is not really likely either. More likely is lamps that are too powerful for the fitting, or poor quality fittings. Either way, if there is insufficient ventilation the lamps will become too hot and fail prematurely.

    Another reason lamps fail is turning them on an off too often, the thermally induced heating and contracting of the filament causes too much stress. Maybe your mother is trying to save power by switching on when entering a room and off when leaving. A false economy in some instances. Best is to replace with LED lamps as the old ones fail.

    I agree - which is why I replaced the original multiple halogen light fitting with a multiple LED one a couple of years ago - but they have still been dropping like flies

    I have sourced my LED bulbs from numerous places and not just the cheap ones - yet they still blow too frequently - 2 a month!

    Yes it could be a dodgy light fitting - but that is new and the light switch is very old and I think a 'dirty' switch is my next most likely cause.

    The reason I want to test it without replacing it is because the light switch is actually grouted into place and removing it will leave a mess I don't want to have to deal with unless I have to.

    That is basically what it is already. EM interference is just signal noise caused EM fields that you don't want. Any type of EMF is what we are detecting here. So would this detect EMinterference? Yes. Is it going to be reliable enough to detect a fault in a wiring system? Most likely not.

    Thanks for the reply - I will have to think of another way to do that then

    I reread the article and still dont understand what it does and how it works. also what is the intent of this? can anybody enlighten me? thanks.

    1 reply

    Hi, its a fun experiment in electromagnetic fields or EMF. Much like magnetic fields come from magnetic materials, electromagnetic fields are generated by all electrically charged objects. As you can use iron shavings to view a magnetic field, this device is an easy way to observe these EM fields as humans. For more info on how these fields work, I'd recommend reading the wiki page on Electromagnetic Fields or just searching it. It's a fascinating topic that a physics prof at my university got me hooked on. Enjoy!

    Whoops! Will add that in. Thank you for catching that!