Close

Testing the coils

A project log for Divergence

Divergence is a wearable EMF detector that provides haptic and sonic feedback of the electromagnetic sources that surround us.

afrdtAfrdt 07/12/2014 at 07:520 Comments

For testing the coils I based my code on Aaron Alai's EMF detector project and Collin Cunningham's EMF experiments. I tested various resistors for their sensitivity and also calculated the resistance of the conductive thread that would be used for the soft circuit and decided to use a 3.6 M Ohms resistor on the ground connection of the coil and connected the other end to an analog pin. I tested the values that I got by printing them on the Serial Monitor and then added a speaker to have a sonic feedback of what was going on. I used a "smoothing" technique of creating an array an calculating the average value (as the previous authors suggested) in order to filter any unwanted noise to the results and then I mapped the values to a range of frequencies between 20 and 880 Hz and their respected durations between 10 to 500 milliseconds. The frequency mapping as can be observed in the code is inverted so that the higher the signal the higher the pitch and the lower the signal the lower the pitch. I got quite some interesting results as when I moved the coil closer to my mobile phone and the laptop I was getting lower frequencies and when I moved it closer to the plug where my laptop's transformer was I got higher and higher frequencies.

This is the code that I used:

// DivergenceCoil

// code on Flora

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

int senseLimit = 15; // raise this number to decrease sensitivity (up to 1023 max)

int probePin = A7; // analog 7

int val = 0; // reading from probePin

int soundOut = 12;

// 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(soundOut, OUTPUT);

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

for (int i = 0; i < NUMREADINGS; i++)

readings[i] = 0; // initialize all the readings to 0

}

void loop() {

val = analogRead(probePin); // take a reading from the probe

if(val >= 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

int freq = map(average, 0, 1023, 880, 20);

int dur = map(freq, 880, 20, 10, 500);

tone(soundOut, freq, dur);

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

Serial.print(" ");

Serial.print(average);

Serial.print(" ");

Serial.println(freq);

Serial.print(" ");

Serial.println(dur);

delay(1);

}

}

Discussions