CIRC10 only works when you are connected to the serial monitor. Let's free your board from wires and make a free-standing circuit!

This is a bonus circuit!! We are going to make a free-standing alarm to alert us if it's too hot/cold. 

Running the Metro Express off a 9V Battery

One of the included parts in the Experimenter's Kit is the 9V battery clip.

If you have a 9V battery, snap it into the clip and plug the clip into the barel-jack of the Metro:

Our temperature sensor is now running off of a 9V battery. This is awesome, but we still have no way to be alerted of temperatures getting too hot/cold.

Add a Piezo!

The Piezo element was first introduced in CIRC06. You send it digital output and it buzzes. Next up is buzzing the piezo when it exceeds a certain temperature. The Piezo can be used as an alarm with minimal modifications to the circuit:

Code for the temperature alarm is below (copy and paste it into a blank Arduino sketch), compile and upload it to your Metro:

/* CIRC10.5: Temperature Alarm
 *  (a bonus circuit for MetroX)
 *  
 *  by Brent Rubell for Adafruit Industries
 */

#define ANALOGREFVOLTAGE 5.555

// TMP36 Pin 
int temperaturePin = A0;

// Piezo Pin 
int piezoPin = 8;
// Freezing
float freezeTemp = 0;
// Boiling
float boilTemp = 26;

void setup()
{
  // Start the Serial connection
  Serial.begin(9600); 
}

void loop() 
{
   float temperature = 0;
   
   temperature = getVoltage(temperaturePin);
  
  // Convert to degrees C
  temperature = (temperature - .5) * 100; 
  Serial.println(temperature);
  
  if(temperature < freezeTemp) {
  tone(piezoPin, 1100, 1000);
  }
  else if(temperature > boilTemp) {
  tone(piezoPin, 1100, 1000);
  }
  
  delay(1000); 
}

float getVoltage(int pin) { 
  
  return(float(analogRead(pin))* float(ANALOGREFVOLTAGE/1023.000));  
}

Changing the variables

We predefined freezing and boiling variables in Celsius, but if you want to use Fahrenheit (or kelvin just change the variables below to other values:

     float freezeTemp = 0;

     float boilTemp = 26;

This guide was first published on Aug 18, 2017. It was last updated on Jun 30, 2017.

This page (CIRC10.5: Temperature Alarm) was last updated on Jul 05, 2017.

Text editor powered by tinymce.