Aidan MeierAbdul RafayAydin Truong
Published © GPL3+

Group 705 Parabolic Dish Audio and Temperature Node

Incorporating design and coding, this project has investigated the relationship between the audio levels and temperature in a classroom.

IntermediateFull instructions provided4 hours583
Group 705 Parabolic Dish Audio and Temperature Node

Things used in this project

Hardware components

DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1
SparkFun Sound Detector
×1
Photon
Particle Photon
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Resistor 330 ohm
Resistor 330 ohm
×1

Software apps and online services

Google Sheets
Google Sheets
Particle Build Web IDE
Particle Build Web IDE

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)
3D Printer (generic)
3D Printer (generic)
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

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.

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

Schematics

Fritzing diagram

Copy the basic wiring however use female to female wires to lengthen the reach of the wires.

Code

Sound and Temperature Sensor Code

Arduino
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

Aidan Meier

Aidan Meier

1 project • 0 followers
Student
Abdul Rafay

Abdul Rafay

1 project • 0 followers
LT Makers group 705
Aydin Truong

Aydin Truong

1 project • 0 followers

Comments