Help me Please. I am so confused.
My DS18b20 uses one wire, and the examples use port 9 as the data line. It appears that I could use 'any Dx' line, even port 2. It requires OneWire.
My DS1307 clock requires the Wire library, uses a convoluted low level setup ( DDRC|=_BV(2) |_BV(3); // POWER:Vcc Gnd
PORTC |=_BV(3); // VCC PINC3.
I2C uses a 4 pin connector with +5V,Grnd, SDA and SCL, and uses A4 and A5.
SLI uses 4 pins, but for a different scheme, but when used negates the use of D0 and D1.
I am trying to build a control that monitors 5 ds18b20s, uses the DS1307 clock and stores the data on an SD card. I am afraid of what devices can be on the same comm system, and how to clearly discriminate between them.
I am sure other newbies have been challanged by this, Can I get a generic discussion on these issues? I do not expect a specific critique of my code below, but a better understanding of where and how these different comm systems are used and relate.
I have tried to integrate example code from Clock and from DS18b20 examples as partially shown below:
#include <WProgram.h>
#include <Wire.h>
#include <DS1307.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// set up Solar cell
const int solarPin = A2; //Analog input pin that the solar cellis attached to
int solarValue = 0; // value read from the SolarCell
float solarvoltsValue = 0; // var for convert to float
// Set up DS18b20 One Wire on digital 2
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 9
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// arrays to hold device addresses
DeviceAddress hotboxThermometer, outsideThermometer, houseThermometer, hotoutThermometer;
// Set up RTC
int rtc[7];
int ledPin = 13;
int fan1Pin = 3; // set Fan1 (low speed) as digital output pin 3
int fan2Pin = 4; // set Fan2 (hi speed) as digital output pin 4
// Enter void setup()
void setup()
{
// these following two lines worke with Clock, but causes failure when //integrated. I have remarked them out, and the program now runs both the clock //and ds18b20.
//
//DDRC|=_BV(2) |_BV(3); // POWER:Vcc Gnd //
//PORTC |=_BV(3); // VCC PINC3
pinMode(ledPin, OUTPUT);
pinMode(fan1Pin, OUTPUT);
pinMode(fan2Pin, OUTPUT); // allow the fans to run for a few seconds for verification.
delay(5000);
digitalWrite(fan2Pin, HIGH);
delay(5000);
digitalWrite(fan1Pin, HIGH);
delay(5000);
Serial.begin(9600);
Serial.println(" Dallas Temperature IC Control Library");
Serial.println(" Real Time Clock Control");
Serial.println(" Read Solar Cell Power");
Serial.println(" Fans turned OFF");
// Do not need to set the clock now
// RTC.stop();
// RTC.set(DS1307_SEC,1);
// RTC.set(DS1307_MIN,40);
// RTC.set(DS1307_HR,20);
// RTC.set(DS1307_DOW,6);
// RTC.set(DS1307_DATE,12);
// RTC.set(DS1307_MTH,8);
// RTC.set(DS1307_YR,11);
// RTC.start();
// Set up the find of all DS18b20s
// Start up the library
sensors.begin();
// locate devices on the bus
Serial.print("Locating devices...");
Serial.print("Found ");
Serial.print(sensors.getDeviceCount(), DEC);
Serial.println(" devices.");
// report parasite power requirements
Serial.print("Parasite power is: ");
if (sensors.isParasitePowerMode()) Serial.println("ON");
else Serial.println("OFF");
oneWire.reset_search();
// assigns the first address found to insideThermometer
if (!oneWire.search(hotboxThermometer)) Serial.println("Unable to find address for hotboxThermometer");
// assigns the seconds address found to outsideThermometer
if (!oneWire.search(outsideThermometer)) Serial.println("Unable to find address for outsideThermometer");
// assigns the seconds address found to outsideThermometer
if (!oneWire.search(houseThermometer)) Serial.println("Unable to find address for houseThermometer");
// assigns the seconds address found to outsideThermometer
if (!oneWire.search(hotoutThermometer)) Serial.println("Unable to find address for hotoutThermometer");