I recently built a simple electromagnetic field (EMF) detector based on a code by Christian Figge that I found on the web. My design includes a 10-LED bar graph (from eBay), which I used to display measurement results. My prototype works well and detects the electromagnetic field generated by electrical appliances, computers, radios, and more from a short distance. – Arduino

The Hardware

The front end of my design is composed of a little bit of hardware (see the schematic shown below), the output of which is connected directly to one analog input (A0) of an Arduino UNO microcontroller. A total of 10 I/O pins (D2–D11) of the Arduino UNO is used to drive a 10-LED bar graph display (LDA-B10ZX). Here, the bar graph is wired to digital pins of the Arduino through 470R current-limiting resistors (R1–R10) Lowering the resistor value is not recommended because the bar graph draws more current (which may be beyond the limit of the Arduino) when all of the LEDs light up.

Useful Links

 

Simple EMF Detector Meter

The Code/Sketch
The code of my design is a borrowed slice from another project, as mentioned before. I just baked it up a snatch (haha)!

  1. #define MEASURES 15
  2. int senseLimit = 15;
  3. int probe = A0;
  4. int ranges[] = {50, 150, 250, 350, 450, 550, 650, 750, 850, 950};
  5. int ledcount = sizeof(ranges)/sizeof(int);
  6. int ledPinOffset = 2;
  7. int bucket[MEASURES];
  8. int total = 0;
  9. int pos = 0;
  10. int avg = 0;
  11. int val = 0;
  12. void setup() {
  13. Serial.begin(9600);
  14. pinMode(probe, INPUT);
  15. for (int i=ledPinOffset; i<ledcount+ledPinOffset; i++) {
  16. pinMode(i, OUTPUT);
  17. }
  18. for (int i=0; i<MEASURES; i++) {
  19. bucket[i] = 0;
  20. }
  21. }
  22. void loop() {
  23. val = analogRead(probe);
  24. if (val >= 1){
  25. val = constrain(val, 1, senseLimit);
  26. val = map(val, 1, senseLimit, 1, 1023);
  27. total -= bucket[pos];
  28. bucket[pos] = val;
  29. total += bucket[pos];
  30. pos = (pos + 1);
  31. if (pos >= MEASURES) {
  32. pos = 0;
  33. }
  34. avg = total / MEASURES;
  35. for (int i=0; i<ledcount; i++) {
  36. if (avg > ranges[i]) {
  37. digitalWrite(i+ledPinOffset, HIGH);
  38. } else {
  39. digitalWrite(i+ledPinOffset, LOW);
  40. }
  41. }
  42. Serial.println(val);
  43. }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s