Saturday, November 13, 2010

The $2 Thermistor Temperature Sensor

A thermistor makes for a very inexpensive temperature sensor, under $2 for the thermistor and the 10k ohm resistor, not counting the $45 for the Arduino and LCD display:



#include <LiquidCrystal.h>
#include <math.h>

/*
LCD Connections:
rs (LCD pin 4) to Arduino pin 12
rw (LCD pin 5) to Arduino pin 11
enable (LCD pin 6) to Arduino pin 10
LCD pin 15 to Arduino pin 13
LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2

Thermistor Connections:
Thermistor Pin 1 to +5v
Thermistor Pin 2 to Analog Pin 0
10k ohm resistor pin 1 to Analog Pin 0
10k ohm resistor pin 2 to Gnd
*/

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
int backLight = 13;    // pin 13 will control the backlight



void setup(void) {
  pinMode(backLight, OUTPUT);
  digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
  lcd.begin(20, 4);              // rows, columns.  use 16,2 for a 16x2 LCD, etc.
  lcd.clear();                   // start with a blank screen
  lcd.setCursor(0,0);            // set cursor to column 0, row 0
}

double Thermistor(int RawADC) {
  double Temp;
  // See See http://en.wikipedia.org/wiki/Thermistor for explanation of formula
  Temp = log(((10240000/RawADC) - 10000));
  Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
  Temp = Temp - 273.15;           // Convert Kelvin to Celcius
  return Temp;
}

void printTemp(void) {
  double fTemp;
  double temp = Thermistor(analogRead(0));  // Read sensor on Pin 0
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Temperature is:");
  lcd.setCursor(0,1);
  lcd.print(temp);
  lcd.print(" C, ");
  fTemp = (temp * 1.8) + 32.0;    // Convert to Fahrenheit
  lcd.print(fTemp);
  lcd.print(" F");
  if (fTemp > 68 && fTemp < 78) {
    lcd.setCursor(0,3);
    lcd.print("Very comfortable");
  }
}

void loop(void) {
  printTemp();
  delay(1000);
}

Thermistors, Ethernet Shields, and More

Yesterday I received a package in the mail from Hacktronics. Call it an early Christmas present. Inside was a package of Thermistors, 10k ohm resistors, a breadboard, and a Ethernet/Micro SD card Shield. Stay tuned for a variety of projects (including web based access to our weather station) based on these devices, and check out the tutorials listed on the product pages.

Monday, November 8, 2010

Garduino Upgrade, Now with more Twitter!

I found a new Instructable that's pretty amazing. Lot's of Arduino goodness!

From http://www.instructables.com/id/Garduino-Upgrade-Now-with-more-Twitter/

A couple months ago I came across two great instructables. The first was the Garduino, an arduino controlled garden to help you grow plants at home. The second was the Tweet-a-Watt, a project that teaches you how to monitor your home power usage using Xbees and Twitter. I read about both these projects here at Instructables and in Make Magazine, Vol 18.

I thought it would be great to combine both these projects and build myself an indoor garden that I could monitor from work via Twitter. Thus began an adventure in gardening and electronics that taught me a lot and took me much longer than perhaps it should have. Fortunately for you I'm going to write down all the steps so you can get started right away. Maybe you'll follow up with this project and upgrade your garden or use this as a guide to start on a similar project. Either way, I hope you'll let me know what you get up to.

If you're ready then head to the next step and begin the process!

Sunday, November 7, 2010

Light Sensors

I've been working on a project that will allow me to determine the number of sun hours available in a given spot, and track that over time, as a component of solar power installation design. The idea is to get a light detector in the sun, record the number of hours it is lit at full intensity, and map that to photovoltaic equivalence. One could use a pv cell, but there are other alternatives. The CdS cell, photodiode and others come to mind. We will try each of these methods and post our results, meanwhile, here is a great tutorial on the options:

http://www.electronics-tutorials.ws/io/io_4.html

Light Sensors are used to measure the radiant energy that exists in a very narrow range of frequencies basically called "light", and which ranges in frequency from "Infrared" to "Visible" up to "Ultraviolet" light. Light sensors are passive devices that convert this "light energy" whether visible or in the infrared parts of the spectrum into an electrical signal output. Light sensors are more commonly known as "Photoelectric Devices" or "Photosensors" which can be grouped into two main categories, those which generate electricity when illuminated, such as Photovoltaics or Photoemissives etc, and those which change their electrical properties such as Photoresistors or Photoconductors. This leads to the following classification of devices.

For more info, see http://www.ecs.umass.edu/ece/m5/tutorials/CdS_Flex_Sensor.html