WiFi Barometer pt. 2

This video outlines the whole project. From creating the housing to the actual implementation. After getting the wood piece back from the laser cutter, I stained the wood and made some holes for the glass vials. I wanted to put the LEDs inside something to keep it from looking simply like a huge wooden breadboard. I also used some of the leftover stain and sandpaper to age the vials a bit.

The entire circuit features a photosensor that is attached to a light-tight tube over the LED that blinks when the router is in use. To convert that binary signal (the LED is only on or off) to the 3-step display on my barometer, I had the Arduino average the results of the light reading over a certain amount of time. For instance, if the light had blinked 15 times in the past 10 seconds, only the first step would be activated. If the light had blinked 30 times, the first and the second step would be activated.

This is by no means scientific. I calibrated it so that the results were as accurate as I could tell, but ultimately even the general readings from this photosensor aren’t always consistent. The project has a function but is primarily about the form and aesthetic.

I’ve included the source code below for any interested. Feel free to comment if you are interested in seeing some more detailed documentation on the circuit itself.


  nate rudolph
  WiFi Barometer Sketch for Arduino
  This sketch is based on the following source code:
  Created 22 April 2007
  By David A. Mellis  <dam@mellis.org>
  This example code is in the public domain.


// Define the number of samples to keep track of.  The higher the number,
// the more the readings will be smoothed, but the slower the output will
// respond to the input.  Using a constant rather than a normal variable lets
// use this value to determine the size of the readings array.
const int numReadings = 800;

// the digital pins that the LEDs are connected to
const byte grePin = 2;          
const byte yelPin = 4;
const byte redPin = 6;

int readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average

int inputPin = A0;

void setup()
  // initialize serial communication with computer:
  // initialize all the readings to 0: 
  for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;   

  // set the (color)Pin as output
  pinMode(grePin, OUTPUT); 
  pinMode(yelPin, OUTPUT);
  pinMode(redPin, OUTPUT);

void loop() {
  // Decide what LEDs should be on
  // Will definitely need to be calibrated to match average data from photo sensor
  if (average > -20){
  digitalWrite(grePin, HIGH);
    digitalWrite(grePin, LOW);
  if (average > 0){
   digitalWrite(yelPin, HIGH); 
    digitalWrite(yelPin, LOW);
  if (average > 20){
   digitalWrite(redPin, HIGH); 
    digitalWrite(redPin, LOW);

  // subtract the last reading:
  total= total - readings[index];         
  // read from the sensor:  
  readings[index] = analogRead(inputPin); 
  // add the reading to the total:
  total= total + readings[index];       
  // advance to the next position in the array:  
  index = index + 1;                    

  // if we're at the end of the array...
  if (index >= numReadings)              
    // ...wrap around to the beginning: 
    index = 0;                           

  // calculate the average:
  average = total / numReadings;         
  // send it to the computer (as ASCII digits) 
  Serial.println(average, DEC);               

Leave a Reply