Please see the following due Tuesday, Feb 13th and again PART II Review Feb 20th, (scroll all the way to the bottom of this post).
Some libraries, sound sensor code and writing to SD card I have used in the past:
/Libraries
#include <SD.h>
#include <SPI.h>
#include <DHT.h>
#include <Wire.h>
#include <SoftwareSerial.h>
#include “Adafruit_PM25AQI.h”
//SOUND SENSOR THINGS//////////////////////////////
const int sampleWindow = 10000; // Sample window width in mS (50 mS = 20Hz) 12.10.17 was 1000
unsigned int sample;
/////////////////READ SOUND SENSOR////////////////////
unsigned long startMillis= millis(); // Start of sample window
unsigned int peakToPeak = 0; // peak-to-peak level
unsigned int signalMax = 0; //originally set to 0
unsigned int signalMin = 1024; //originally set to 1024
// collect data for 10 seconds
while (millis() – startMillis < sampleWindow)
{
sample = analogRead(4);
if (sample < 1024) // toss out spurious readings
{
if (sample > signalMax)
{
signalMax = sample; // save just the max levels
}
else if (sample < signalMin)
{
signalMin = sample; // save just the min levels
}
}
}
peakToPeak = signalMax – signalMin; // max – min = peak-peak amplitude
double volts = (peakToPeak * 5.0) / 1024; // convert to volts
//SD CARD BEGIN/////////////////////////////////
if (SD.begin()) {
Serial.println(“SD card is initialized. Ready to go!”);
}
else {
Serial.println(“Failed”);
return;
}
sd_file = SD.open(“data.txt”, FILE_WRITE);
if (sd_file) {
sd_file.print(“Time”);
sd_file.print(“,”);
sd_file.print(“Humidity”);
sd_file.print(“,”);
sd_file.print(“Temperature_C”);
sd_file.print(“,”);
sd_file.print(“Heat_index_C”);
sd_file.print(“,”);
sd_file.print(“PhotoResistor”);
sd_file.print(“,”);
sd_file.print(“SoundSensor”);
sd_file.print(“,”);
sd_file.print(“RainSensor”);
sd_file.print(“,”);
sd_file.print(“pm10_standart”);
sd_file.print(“,”);
sd_file.print(“pm25_standart”);
sd_file.print(“,”);
sd_file.print(“pm100_standart”);
sd_file.print(“,”);
sd_file.print(“pm10_environment”);
sd_file.print(“,”);
sd_file.print(“pm25_environment”);
sd_file.print(“,”);
sd_file.print(“pm100_environment”);
sd_file.print(“,”);
sd_file.print(“Particles > 0.3 um / 0.1L air”);
sd_file.print(“,”);
sd_file.print(“Particles > 0.5 um / 0.1L air”);
sd_file.print(“,”);
sd_file.print(“Particles > 1.0 um / 0.1L air”);
sd_file.print(“,”);
sd_file.print(“Particles > 2.5 um / 0.1L air”);
sd_file.print(“,”);
sd_file.print(“Particles > 5.0 um / 0.1L air”);
sd_file.print(“,”);
sd_file.print(“Particles > 10 um / 0.1L air”);
sd_file.print(“\n”);
}
sd_file.close();
}
void loop() {
sd_file = SD.open(“data.txt”, FILE_WRITE);
if (sd_file) {
senddata();
}
else {
Serial.println(“error opening file”);
}
delay(1000);
}
void senddata() {
for (long seconds = 00; seconds < 86400; seconds = seconds + (TIME/1000)) {
float temp = dht.readTemperature();
float hum = dht.readHumidity();
float fah = dht.readTemperature(true);
float heat_index = dht.computeHeatIndex(fah, hum);
///////////////WRITE DATA TO SD FILE////////////////////
sd_file.print(seconds);
sd_file.print(“,”);
sd_file.print(hum);
sd_file.print(“,”);
sd_file.print(temp);
sd_file.print(“,”);
sd_file.print(((heat_index) – 32) * (0.5556));
sd_file.print(“,”);
sd_file.print(lightsensorValue);
sd_file.print(“,”);
sd_file.print(volts);
sd_file.print(“,”);
sd_file.print(rainSensorValue);
sd_file.print(“,”);
sd_file.print(pm10_std);
sd_file.print(“,”);
sd_file.print(pm25_std);
sd_file.print(“,”);
sd_file.print(pm100_std);
sd_file.print(“,”);
sd_file.print(pm10_env);
sd_file.print(“,”);
sd_file.print(pm25_env);
sd_file.print(“,”);
sd_file.print(pm100_env);
sd_file.print(“,”);
sd_file.print(part_03um);
sd_file.print(“,”);
sd_file.print(part_05um);
sd_file.print(“,”);
sd_file.print(part_10um);
sd_file.print(“,”);
sd_file.print(part_25um);
sd_file.print(“,”);
sd_file.print(part_50um);
sd_file.print(“,”);
sd_file.print(part_100um);
Serial.print(“\n”);
////////////////WRITE DATA TO SERIAL MONITOR///////////////
Serial.print(seconds);
Serial.print(“,”);
Serial.print(hum);
Serial.print(“,”);
Serial.print(temp);
Serial.print(“,”);
Serial.print(((heat_index) – 32) * (0.5556));
Serial.print(“,”);
Serial.print(lightsensorValue);
Serial.print(“,”);
Serial.print(volts);
Serial.print(“,”);
Serial.print(rainSensorValue);
Serial.print(“,”);
Serial.print(pm10_std);
Serial.print(“,”);
Serial.print(pm25_std);
Serial.print(“,”);
Serial.print(pm100_std);
Serial.print(“,”);
Serial.print(pm10_env);
Serial.print(“,”);
Serial.print(pm25_env);
Serial.print(“,”);
Serial.print(pm100_env);
Serial.print(“,”);
Serial.print(part_03um);
Serial.print(“,”);
Serial.print(part_05um);
Serial.print(“,”);
Serial.print(part_10um);
Serial.print(“,”);
Serial.print(part_25um);
Serial.print(“,”);
Serial.print(part_50um);
Serial.print(“,”);
Serial.print(part_100um);
Serial.print(“\n”);
if (seconds >= 58) {
minutes = minutes + 1;
}
if (minutes > 59) {
hours = hours + 1;
minutes = 0;
}
sd_file.flush(); //saving the file
delay(TIME); //how long between each measurement
}
sd_file.close(); //closing the file
}
Homework for Tuesday, Feb 13th
I. Sensor prototyping – [post to blog as cagtegory “2.5 Sensors Control + Pilot”]
Control tests (good and bad baselines). In controlled setting. Document this in diagrams, photos, etc. List problems! problem are good. try to create limits of good and bad qualities. almost break the sensor…
Pilot Test – on site but only walking around one block.
Time – will you record over 15 minutes or over 24 hours?
Space – we will all measure first at quarter block locations but then hi-rez at every address How to write multiple lines of data Graphing the data in excel. Select data cells, INSERT/ (first graph)…select data and change graphics icon of line weight and color Think about a time column converting seconds to time (Format)
Ill updated the Google My Map dropping pins for 3 x 3 block area.
I used this converter online: https://mygeodata.cloud/converter/kml-to-csv . See Teams.
Eventually you will make your own map, dropping a pin for every street address.
II. Premiere Movie – [post to blog as category “2.6 Phenomena clips”] you may have to make a Vimeo account to host
start to record video/audio clips on your phone: a) conceptual good and bad, b) on-site and c) baseline locations around town. If you download any video be careful to document the source.
Organize your clips in folders. Name the folders per phase changes and types of phenomena.
Be careful how / not to record children and try to record backs of peoples heads so they are not identifiable. Be very conscious of the sensory quality other than sight.
Consider short clips of 3-5 seconds, 10-30 seconds Pics are also good to collect.
qualities)
PRINT all and bring in Tuesday, Feb 13th on 11×17.
///
Tuesday, Feb 13th in class I will carefully explain the Data Management workflow from
- Arduino SD card raw data CSV
- cleaned data save as excel file
- graphs
- workflow to GIS VIZ (Elephant) tool, namely z-line tool