Hi Guys!
Here is a pic of what I have:
As you can see the left sensor is connected in a normal power mode, the right one in parasite power mode.
The issue is the left sensor doesn't work in the parasite power mode if I connect its Vdd to the ground rail (with or without the right sensor connected) . The 1-wire example sketch throwing "No more adresses" in both cases, so the right sensor stops working.
Do all DS18B20 support parasite power mode? The problematic sensor says 18B20 1602C4 +233AA, the working fine one says 18B20 1516C4 +760AA. I suppose they are pretty much the same though.
Another question is in the current setup I use DallasTemperature library and haven't found anything regarding the power mode to be set up in there (as against the 1-wire example where we've got:
ds.write(0x44, 1); // start conversion, with parasite power on at the end
to have parasite mode "enabled"
The sketch of mine is:
#include <OneWire.h>
#include <LiquidCrystal.h>
#include <DallasTemperature.h>
OneWire ds(2); // on pin 2 (a 4.7K resistor is necessary)
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
DeviceAddress firstTermometer = { 0x28, 0xFF, 0xA5, 0x05, 0x83, 0x15, 0x02, 0x01 };
DeviceAddress secondTermometer = { 0x28, 0xF5, 0x68, 0x08, 0x00, 0x00, 0x80, 0x38 };
DallasTemperature sensors(&ds);
const int numReadings = 10;
int readings[numReadings];
int readIndex = 0;
int total = 0;
int average = 0;
int FAN = 3;
int FAN_pwm = 110; //140-2V minimum without sound
int POWER = 4;
void setup(void) {
Serial.begin(9600);
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.write("AIR: ");
sensors.begin();
sensors.setResolution(firstTermometer, 10);
pinMode(6, OUTPUT); //LCD brightness
pinMode(FAN, OUTPUT);
pinMode(POWER, OUTPUT);
analogWrite(6, 1);
analogWrite(FAN, FAN_pwm);
digitalWrite(POWER, HIGH);
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = 0;
}
}
void loop(void) {
delay(1000);
int ldr = 0;
int ldrReading;
sensors.requestTemperatures();
Serial.print("Temperature for first Therm =");
float temp1 = sensors.getTempC(firstTermometer);
float temp2 = sensors.getTempC(secondTermometer);
Serial.println(temp1);
lcd.setCursor(4,0);
lcd.print(temp2);
lcd.print((char)223);
total = total - readings[readIndex];
readings[readIndex] = analogRead(ldr);
total = total + readings[readIndex];
readIndex = readIndex + 1;
if (readIndex >= numReadings) {
average = total / numReadings;
//Serial.print("Avg Reading = ");
//Serial.println(average);
if (average == 0) average = 1;
if (average > 400) average = 255;
analogWrite(6, average);
//Serial.print("Avg applied = ");
//Serial.println(average);
readIndex = 0;
}
}
Is it OK that I use two power modes simultaneously?