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

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

Similar projects you might like

Blynk GPS Tracker
Intermediate
  • 41
  • 2

Full instructions

Simple GPS tracker using a Particle Photon (or Electron) and an EM406 GPS module with location visible on Blynk app map.

Pool Buddy
Intermediate
  • 1,619
  • 11

Work in progress

Monitor and log water quality (pH & ORP) and temperature from everywhere.

IoT Thermometer Using Python
Intermediate
  • 986
  • 8

Full instructions

How to develop a simple but powerful IoT thermometer using a Zerynth-powered single-board MCU and the Zerynth App.

Particle Photon Flip Dot Clock
Intermediate
  • 2,162
  • 31

Full instructions

The flip dot display uses an electromechanical dot matrix that spin from black to yellow to display text, numbers and more!

Patriot iOS App
Intermediate
  • 547
  • 9

Use an old iPhone device to control and display the status of your Patriot IoT devices.

Patriot iOS App

Team Patriot

What To Wear LCD
Intermediate
  • 48
  • 1

Ever wondered what to wear due to unpredictable weather??? Wonder no longer!

Add projectSign up / Login