Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
two pin two device example added
  • Loading branch information
RobTillaart committed Jul 4, 2015
1 parent 181501c commit ad90160
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions examples/TwoPin_DS18B20/TwoPin_DS18B20.ino
@@ -0,0 +1,45 @@
//
// FILE: TwoPin_DS18B20.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.00
// PURPOSE: two pins for two sensors demo
// DATE: 2014-06-13
// URL: http://forum.arduino.cc/index.php?topic=216835.msg1764333#msg1764333
//
// Released to the public domain
//

#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS_1 2
#define ONE_WIRE_BUS_2 4

OneWire oneWire_in(ONE_WIRE_BUS_1);
OneWire oneWire_out(ONE_WIRE_BUS_2);

DallasTemperature sensor_inhouse(&oneWire_in);
DallasTemperature sensor_outhouse(&oneWire_out);

void setup(void)
{
Serial.begin(9600);
Serial.println("Dallas Temperature Control Library Demo - TwoPin_DS18B20");

sensor_inhouse.begin();
sensor_outhouse.begin();
}

void loop(void)
{
Serial.print("Requesting temperatures...");
sensor_inhouse.requestTemperatures();
sensor_outhouse.requestTemperatures();
Serial.println(" done");

Serial.print("Inhouse: ");
Serial.println(sensor_inhouse.getTempCByIndex(0));

Serial.print("Outhouse: ");
Serial.println(sensor_outhouse.getTempCByIndex(0));
}

0 comments on commit ad90160

Please sign in to comment.