Twitter

We (Lizzie) managed a huge feat in accomplishing pushing the data of the Arduino and sound sensor to Twitter. This created an additional layer of interactivity and in encouraging the individual to engage in monitoring the sound environment that they experience.

You can view the feed for the data we collected during setup, test and presentation here.

Post Presentation

Despite losing an LED during the presentation set up overall it went really well. (I said environment way too much)

The questions that we were asked were both informative of our product and presenting, concerning both the technical elements that we had dismissed in our development as well as queries pushing the importance of sound and how people would react in an environment that increases focus on the awareness of the sound environment.

One question that was slightly out of field was a query of volumes by motorways. Naturally this is in an area of unknown or unspecified factors, sound insulation, building materials, sheltering, which changes the reception of sound itself. Being aware of the environment in relation to sound also means being aware of it in terms of location and what that area comprises of. Different materials provide different levels of insulation against the elements, sound inclusive.
The first step to bettering the environment you’re in may start with being aware of sound, but continues with the investigation and maturing of the environment through your influence.

That said the decibel values for living by a motorway, unabsorbed by plantlife, barriers or otherwise, would be very high, and well beyond recommendable exposure levels for a few hours.

Presentation Reflection

I think it went really well.

I was terrified it would stop working, even though I had tested it 4 times this morning, twice in the room and in the scarf, but technology is never reliable enough for an important presentation!

It didn’t though, we didn’t get high enough levels for the LEDs to be lit, but it was sending it’s data away happily to twitter, which I was so relieved about!! We didn’t get many questions, so I’m going to assume that’s because we explained everything well in the presentation😉

One question that was interesting was whether we thought decibear really would change people’s behaviour. I’m not sure it would to be honest, but I have to say that just wearing something, even for testing, that I know is listening to ambient sounds, really did increase my awareness to them. Not sure it would be enough to change my route to uni on a cold day, but I definitely was more aware.

 

So, just one more lose end, here’s a link to the final code in the blog (slightly different from the last one copied to here): https://www.dropbox.com/s/93z4t59x4n7msc0/decibear_tweet.pde

 

Aaaaand we’re done!! So long Decibear, it’s been fun!

IMAG0781

Roles

I feel we’ve both worked really hard on this project, I hope the product shows that, but the blog definitely does!
I guess though that we have to split the project down into roles to help with marking, although it’s really difficult in our case as we’ve both done pretty much everything, so I’m listing us down as the lead, in that that person took the biggest role, but the other will have done some of it as well!

Lead Researcher – Karla
Lead Coder – Lizzie
Lead CD-compiler – Karla
Lead blog (site)-creator – Lizzie
Lead kit-babysitter – Karla
Lead optimist – Lizzie
Lead Saunders-negotiator – Karla
Lead swearer-at-computers – Lizzie

We both came up with the ideas together as a long process of bouncing the craziest things we can think of against our skill set. And also against Mike Blow, so thanks for some project ideas go to Mike too. And thanks to Will Skates for his midnight help with a php script to send stuff to twitter.

Project bibliography and reference

Dave Cornman. (2003). Effects of Noise of Wildlife. Nature Sounds Society. http://www.naturesounds.org/conservENW.html

Lane H, Tranel B (1971). “The Lombard sign and the role of hearing in speech”. J Speech Hear Res 14 (4): 677–709. http://jslhr.asha.org/cgi/content/abstract/14/4/677

Louis Hagler, MD. (2005). Summary of Adverse Health Effects of Noise Pollution. World Health Organization Guideline for Community Noise. http://www.noiseoff.org/document/who.summary.pdf

The Journal of Speech and Hearing Disorders, Monograph Supplement 1, 1950 http://www.asha.org/uploadedFiles/publications/archive/Monographs1.pdf

HSE NIHL Statistics. http://www.hse.gov.uk/statistics/causdis/deafness/index.htm

The Journal of Speech and Hearing Disorders, Monograph Supplement 1, 1950 http://www.asha.org/uploadedFiles/publications/archive/Monographs1.pdf

Noise-Induced Hearing Loss, D.E. Wheeler, P.h.D, 1950 http://archotol.jamanetwork.com/article.aspx?articleid=587677

Applied Industrial Hygiene, Noise-Induced Hearing Loss, Volume 4, Issue 7, 1989 http://www.tandfonline.com/doi/abs/10.1080/08828032.1989.10390405

Noise-Induced Hearing Loss, Peter M. Rabinowitz, 2000 http://hannaziegler.tripod.com/ent/varia/rabinowi.pdf

WHO Prevention of Noise Induced Hearing Loss Report, 1997 http://www.who.int/pbd/deafness/en/noise.pdf

HSE NIHL in the workspace http://www.hse.gov.uk/food/noise.htm

It’s a Noisy Planet: Protect their hearing http://www.noisyplanet.nidcd.nih.gov/Pages/Default.aspx

National Institute of Deafness and Other Communication Disorders, NIHL http://www.nidcd.nih.gov/health/hearing/pages/noise.aspx

Deafness Research.co.uk http://www.deafnessresearch.org.uk/content/your-hearing/main-types-of-hearing-loss/noise-induced-hearing-loss/

Twitter Mood Light, Instructables http://www.instructables.com/id/Twitter-Mood-Light-The-Worlds-Mood-in-a-Box/step7/Programming-step-1-SPI-UART/

CC logic, Physical Computing http://www.cc-logic.com/blog/posts/physical-computing-part-1-of-3-getting-wifi-working/

GPS Tracking, Jeremy Blum, 2012 http://www.jeremyblum.com/2012/07/16/tutorial-15-for-arduino-gps-tracking/

Lightweight Low Power Arduino Library http://www.rocketscream.com/blog/2011/07/04/lightweight-low-power-arduino-library/

Tweet tweet

With the help of Will Skates writing a php script for me to send my values from the Arduino to, and send them on to twitter, it’s finally sending the sensor readings to twitter and flashing the lights.

I had to set this one up as a client to Will’s page instead of a server as before, but it’s all good.

// (Based on Ethernet's WebClient Example)

#include "WiFly.h"


#include "Credentials.h"


byte server[] = { 66, 249, 89, 104 }; // Google
int canConnect = 0;

int ledPin[] = {3,4,5};

int warningLevels[] = {200, 230, 270};
//int warningLevels[] = {20, 50, 100};

int sensorPin = A0;
int sensorValue = 0;

int readCount = 0;

int accumSound = 0;
int aveSound = 0;

int ledLit = 0;

//Client client(server, 80);

Client client(server, 80);

void setup() {
  
  Serial.begin(9600);

  WiFly.begin();
  
  Serial.println("associating");
  if (!WiFly.join(ssid, passphrase)) {
    Serial.println("Association failed.");
    while (1) {
      // Hang on failure.
    }
  }else{
    Serial.println("Association succeeded.");
  }  

  Serial.println("connecting...");

  if (client.connect()) {
    Serial.println("connected");
    canConnect = 1;
    client.println("GET /new?msg=openConn&pwd=(password) HTTP/1.1");
    client.println();
  } else {
    Serial.println("connection failed");
  }
  
}

void loop() {
  
  Serial.println("attempting request");
  
  
  delay(5000);
  
  //read sensor
  sensorValue = analogRead(sensorPin);
  //reread if values are not between our thresholds
  while(sensorValue == 0 || sensorValue > 350){
    sensorValue = analogRead(sensorPin); 
  }
  
  //add to readCount
  readCount ++;
          
  //add to accumulative sound
  accumSound += sensorValue;
  
  //work out average sound per minute
  aveSound = accumSound/readCount;
  
  //check against set levels
  for (int i=0; i<(sizeof(warningLevels)/2); i++){
    if (aveSound > warningLevels[i]){
      ledLit = i+1;
    }
  }
  
  //light LEDs
  for (int i=0; i<ledLit; i++){
    digitalWrite(ledPin[i], HIGH); 
  }
  
  client.stop();
  if (client.connect()) {
    String req = "GET /new?msg=";
    req += sensorValue;
    req += "&pwd=(password)";
    client.println(req);
    client.println();
  } else {
    Serial.println("connection failed");
  }

}

You can see the tweets here: https://twitter.com/decibear
Although now, being half 2am, I think it’s time for bed, which means no visualization, but we have a working blogject!

Code update so far

I’ve been working on the wifly stuff, and I’ve had some big issues, namely with the IP address, not being set from the router which is my phone. Finally fixed it now, so hopefully if I don’t change anything tonight on my phone or wiFly shield settings, it should work tomorrow!

This script still does the thing with the lights, but it also sends the information over the wiFly’s server, so I can read it on my phone while I’m out and about wearing the bear scarf!

The only real bug with this is that for some reason I can’t change the delay without messing up the client, so it’s currently reading every 10 ms rather than 30s, but I’m still working on that!

/*
 * Web Server
 *
 * (Based on Ethernet's WebServer Example)
 *
 * A simple web server that shows the value of the analog input pins.
 */

#include "WiFly.h"

char passphrase[] = "pass";
char ssid[] = "ssid";

int ledPin[] = {3,4,5};

int warningLevels[] = {200, 230, 270};
//int warningLevels[] = {20, 50, 100};

int sensorPin = A0;
int sensorValue = 0;

int readCount = 0;

int accumSound = 0;
int aveSound = 0;

int ledLit = 0;

Server server(80);

void setup() {
  
  for (int i=0; i<(sizeof(ledPin)/2); i++){
   pinMode(ledPin[i], OUTPUT); 
  }
  
  WiFly.begin();

  if (!WiFly.join(ssid, passphrase)) {
    while (1) {
      // Hang on failure.
    }
  }

  Serial.begin(9600);
  Serial.print("IP: ");
  Serial.println(WiFly.ip());
  
  server.begin();
}

void loop() {
  
  //read sensor
  sensorValue = analogRead(sensorPin);
  //reread if values are not between our thresholds
  while(sensorValue == 0 || sensorValue > 350){
    sensorValue = analogRead(sensorPin); 
  }
  
  //add to readCount
  readCount ++;
          
  //add to accumulative sound
  accumSound += sensorValue;
  
  //work out average sound per minute
  aveSound = accumSound/readCount;
  
  //check against set levels
  for (int i=0; i<(sizeof(warningLevels)/2); i++){
    if (aveSound > warningLevels[i]){
      ledLit = i+1;
    }
  }
  
  //light LEDs
  for (int i=0; i<ledLit; i++){
    digitalWrite(ledPin[i], HIGH); 
  }
  
  Client client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean current_line_is_blank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if we've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so we can send a reply
        if (c == '\n' && current_line_is_blank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          
          //output the sensor values
          client.print("sensor value: ");
          client.print(sensorValue);
          client.print("<br/><br/>");
          
          //output the accumulative values
          client.print("You have had ");
          client.print(accumSound);
          client.print(" over ");
          client.print(readCount);
          client.print(" minutes.");
          client.println("<br />");
          
          //output the average values
          client.print("This is an average of ");
          client.print(aveSound);
          client.print(" per minute");
          client.println("<br/><br/>");
          
          //warn if over final level
          if (ledLit == 3){
           client.print("This is over your recommended allowance by ");
           client.print(aveSound - warningLevels[2]);
           client.print("<br/>"); 
          } else {
           client.print("This is under your recommended allowance by ");
           client.print(warningLevels[2] - aveSound);
           client.print("<br/>");
          }
          
          break;
        }
        if (c == '\n') {
          // we're starting a new line
          current_line_is_blank = true;
        } else if (c != '\r') {
          // we've gotten a character on the current line
          current_line_is_blank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(100);
    //delay(30000);
    client.stop();
  }
}

Now I’m at another stage where we could present if necessary, although I really would like to get it sending to twitter, or have some sort of visualization, or preferably both! I will keep working on it for a while, but I’ll need to get some sleep soonish as I barely slept last night, and tomorrow is the big day!

Sleepy-time

We were really hoping to be able to put the arduino to sleep and wake it up every 30 seconds or minute to scan for sound, then wake it up again, but it turns out this won’t be possible.

We thought it was a good idea in order to help make it more portable, in that the battery would last a lot longer, but according to everything I have managed to read about it, it seems that 8s is the longest you can put an arduino to sleep for without an external clock attached, which we have no hope of getting at this point.

Hopefully though, it won’t matter as we have already tested the system for 10 minutes off battery with a simple delay in, and it could have lasted even longer but I got bored!