Things used in this project

Hardware components:
10167 01
DHT22 Temperature Sensor
×1
SparkFun Sound Detector
×1
Photon new
Particle Photon
×1
11026 02
Jumper wires (generic)
×1
12002 04
Breadboard (generic)
×1
08377 02 l
Resistor 330 ohm
×1
Software apps and online services:
Google sheets
Google Sheets
Particle Build
Hand tools and fabrication machines:
Lasercutter
Laser cutter (generic)
3drag
3D Printer (generic)
09507 01
Soldering iron (generic)

Custom parts and enclosures

Enclosure 2D Laser Cutter Design
This is an Adobe Illustrator file that contains the plans for the Enclosure in which the Photon or microcontroller was placed in. This was used to cut out the enclosure out from a Clear Acryclic Sheet (18" x 24'), after which it was promptly assembled using a T-slot system. This was used to contain the microcontroller that ran the sensors as well as serve as a core element in the artistic presentation of this model.
705_project_lNJTrrt8QU.ai
Parabolic Dish TinkerCAD Design
This is a .OBJ file that contains the 3D design for the specific dish used. This was used in the project to refract the sound waves into a single focal point on which the SparkFun Sound Detector was placed
paraboloid_object_TziJXkhWWV.obj

Schematics

Fritzing diagram
Copy the basic wiring however use female to female wires to lengthen the reach of the wires.
fritzing_705_SoBMJ8vbeV.fzz

Code

Sound and Temperature Sensor CodeArduino
This is code written in the Arduino coding language which can be programmed to extract audio data and temperature data. This was used with the Sparkfun Sound Sensor (SEN 12462) and the DHT 22 sensor, as well as connected to a spreadsheet engine, namely, Google Drive, to analyze the data which was extrapolated.
 
// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_DHT.h>
#define DHTPIN 4            // what pin we're connected to
#define DHTTYPE DHT22       // DHT 22 (AM2302)
// Use the VBAT pin on the Photon for VCC

const long sample_rate = 50; // time between samples (in miliseconds)
const int array_size = 1200; // 1000/50=20 * 60=1200
int snd_array[array_size] = {};
int snd_max = 0;
int snd_min = 4096;

double snd_avg = 0;

const int blink_thresh = 3000;

unsigned long broadcast_interval = 5000;
unsigned long last_broadcast = 0;
unsigned long lastSample = 0 ;
unsigned long lastReset = 0 ;

unsigned long DHTbroadcast_interval = 5000;
unsigned long DHTlast_broadcast = 0;

DHT dht(DHTPIN, DHTTYPE);

double temp; 

void setup() {
    Serial.begin(9600);
    pinMode(DHTPIN, INPUT);
    
    Particle.variable("temp", temp);
    Particle.variable("snd_min", snd_min);
    Particle.variable("snd_max", snd_max);
    Particle.variable("snd_avg", snd_avg);

    pinMode(A0, INPUT); // mic AUD connected to Analog pin 0
    pinMode(D7, OUTPUT); // flash on-board LED
}

void loop() 
{
    int mic_reading = analogRead(0); //Serial.println(mic_reading);
    blinkMic(mic_reading) ;
    averageReading(mic_reading) ; 
    broadcast() ;
    checkDHT();
    //this will reset the min and max, but keep in mind that those
    //large and small values will remain in the array for up to one
    //minute depending on the sample_rate
    checkReset() ;
}


void averageReading(int value) 
{
    unsigned long now = millis();

    if((now - lastSample) > sample_rate) 
    {
        // Shift all the values right by 1
        for(int i = array_size-1; i >= 1; i--) 
        {
            snd_array[i] = snd_array[i-1]; 
            if((snd_array[i] < snd_min) && (snd_array[i] > 0))
            {
                snd_min = snd_array[i];
            }
            if(snd_array[i] > snd_max)
            {
                snd_max = snd_array[i];
                
            }
        }
    
        snd_array[0] = value; 
    
        // Average of all non-zero elements in the array
        double avg_sum = 0; 
        int size = 0 ;
        for (int a=0; a < array_size; a++) 
        {
            if(snd_array[a] > 0)
            {
                size++ ;
                avg_sum += snd_array[a];
            }
        }
        snd_avg = avg_sum / size;
        
        lastSample = now ;
    }
}


void blinkMic(int reading) 
{
    if(reading > blink_thresh) 
    {
        digitalWrite(D7, HIGH);
    } 
    else 
    {
        digitalWrite(D7, LOW);
    }
}

void checkReset() 
{
    unsigned long now = millis();
    
    //if it has been one minute since resetting min and max, reset
    if((now - lastReset) >= 60000) 
    {
        snd_max = 0 ;
        snd_min = 4095 ;
        lastReset = now ;

    }
}


void broadcast() {
    unsigned long now = millis();
    if((now - last_broadcast) > broadcast_interval) {
        Serial.print("Avg: ");
        Serial.println(snd_avg);
        Serial.print("Min: ");
        Serial.println(snd_min);
        Serial.print("Max: ");
        Serial.println(snd_max);
        snd_avg = 0;
        // snd_array[array_size] = {};
        last_broadcast = now;
    }
}

void checkDHT() {
    unsigned long now = millis();
    if((now - DHTlast_broadcast) > DHTbroadcast_interval) {
        
        double checkTemp = dht.getTempFarenheit();
        if (checkTemp > 32 && checkTemp < 100)
        temp = checkTemp;
        Serial.println("Temp: " + String(checkTemp));
        
        
        DHTlast_broadcast = now;
        
    }
}

Credits

29980761b143404464aa5781e65df3fc
Aidan Meier
1 project • 0 followers
Student
Contact
6eb4b31ca9b9293627b582b30fd609c7
Abdul Rafay
1 project • 0 followers
LT Makers group 705
Contact
4b3d41298d291f6ec3f0134120537db7
Aydin Truong
1 project • 0 followers
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login