Dallas One Wire Temperature Sensor Library

I have written a library for use with the Arduino that supports a group of Dallas Semiconductor DS18S20 temperature sensors. This library allows the Arduino to search for all of the temperature sensors attached to the One-Wire bus, and then to obtain temperature readings (in Celsius or Fahrenheit) as floating-point numbers from each or any of the sensors.

The library creates a subclass of the OneWire class, which requires the use of the OneWire library, which can be obtained here.

The library contains the following functions:

To download the library, including an example program, click here.

To install the library, unzip the library to a sub-directory of the hardware/libraries sub-directory of the Arduino application directory. Then launch the Arduino environment; you should see the library in the Import Library menu.

To use the library, you must put the following lines at or near the beginning of your sketch...

#include "OneWire.h"
#include "OneWireTempSensor.h"

The example program, which is included with the library, looks like this...

#include <OneWire.h>
#include <OneWireTempSensor.h>

OneWireTempSensor sensors(12);       // the OneWireTempSensor object
int   numdevs;                    // number of devices

/*************************************************************/
/*            Main Code Start here                           */
/*************************************************************/
void setup() 
{ 
  Serial.begin(9600);
  numdevs = sensors.getDevices();    // this searches for all DS1820 devices on the OneWire bus
} 

void loop() 
{
  int currdev;
  float real_temp;
  int   temp;

  // loop through all the DS1820 temp sensors on the bus
  for (currdev = 0; currdev < numdevs; ++currdev) {
    /* get the temperature */
    real_temp = sensors.getTempF(currdev);
    temp = (int) real_temp;
    Serial.print("Temperature of device ");
    Serial.print(currdev,DEC);
    Serial.print(" is ");
    Serial.println(temp,DEC);
  }
}

Seven Segment Display Library

I have written a library for use with the Arduino that supports a bank of Seven-Segment LED displays attached to a set of shift registers. The library was actually developed using a DE-DP001 board from Sure Electronics, but it should support most shift-register attached displays.

The library contains the following functions:

To download the library, including an example program, click here.

To install the library, unzip the library to a sub-directory of the hardware/libraries sub-directory of the Arduino application directory. Then launch the Arduino environment; you should see the library in the Import Library menu.
Note: You may receive the following warning message the first time you start the Arduino IDE after installing the library...

In file included from SevenSegment.cpp:22:
SevenSegment.h:33: warning: only initialized variables can be placed into program memory area
     
This warning is due to a minor compiler bug and should be ignored. It should only occur the first time you run the Arduino IDE after installing the library.

To use the library, you must put the following line at or near the beginning of your sketch...

#include "SevenSegment.h"

The example program, which is included with the library, looks like this...

#include <SevenSegment.h>

#define DIM   11          // This pin turns off the display when set LOW
#define CLK   10          // This is the clock pin
#define DATA  9           // This is the data pin
#define MAXDIGITS 4       // number of display digits

double value = -10.0;     // initial floating point value to be displayed

// Some character data to be displayed
unsigned char data[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'a', 'B', 'b', 
                         'C', 'c', 'D', 'd', 'E', 'e', 'F', 'f', 'G', 'g', 'H', 'h', 'I', 'i', 
                         'J', 'j', 'L', 'l', 'N', 'n', 'O', 'o', 'P', 'p', 'Q', 'q', 'R', 'r',
                         'S' ,'s', 'T', 't', 'U', 'u', 'Y', 'y', '-', '?', '=', '"' };
                         
SevenSegment seg = SevenSegment(DATA,CLK,DIM,MAXDIGITS);    // Create the SevenSegment Object

unsigned char digits[4];  // digit array used to display characters

void setup()
{

}

void loop()
{
  int i;
  // Display some floating point numbers
  while (1) {
     seg.displayNum(value,1,0);   // display the current value with 1 decimal place
     delay(100);                  // wait a bit to allow it to be seen
     value = value + .1;          // increment the value by .1
     if (value > 10.0) break;
  }
  // Display some character values
  for (i = 0; i < sizeof data; ++i ) {
    Serial.print(data[i]);
    digits[0] = data[i];
    digits[1] = data[i];
    digits[2] = data[i];
    digits[3] = data[i];
    seg.displayChars(digits);
    delay(1000);
  }
  // Display a message using the fade capability
  seg.setFadeTime(200);
  for (i = 0; i < 5; ++i) {
  digits[0] = 'H';
  digits[1] = 'E';
  digits[2] = 'L';
  digits[3] = 'P';
  seg.displayChars(digits);
  delay(1000);
  }
  seg.setFadeTime(0);
  value = -10.0;
}