Hey!
i'm new to both the forum and the Arduino, so pleace be gental with me ;). And if the post is in the wrong subforum, or that something else is wrong. Pleace let me know!
My problem is that i what to read the value of the 1wire-sensors, and with that info making a If-statement. The ways i've been trying only mesure the volt on the pin, not the value from the sensors. I have tryed googling, but I don't realy know what to google. So the things that I have tried to google gave me nothing.
i dont know if it meens anything, but I'm running the Funduino Uno board.
// What librarys that are loaded
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
#define ONE_WIRE_BUS 13 // what pin the temp-sensors are connected to
OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices
DallasTemperature sensors(&oneWire); // Pass our oneWire reference to Dallas Temperature.
DeviceAddress insideThermometer = { 0x28, 0xFF, 0xC9, 0x6F, 0x72, 0x15, 0x01, 0x7E }; //Address temp-sensor1
DeviceAddress insideThermometer2 = { 0x28, 0xFF, 0x7D, 0xB6, 0x62, 0x15, 0x03, 0x4A }; //Address temp-sensor2
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // The pins that are used for the LCD (16x2)
void setup(void)
{
sensors.begin(); // Start up the library
sensors.setResolution(insideThermometer, 10); // set the resolution to 10 bit (good enough?)
lcd.begin(16,2); // size of the LED-display
Serial.begin(9600);
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.0) { // Error-message if the temp is under -127c
lcd.print("Error");
} else {
lcd.print(tempC,1); // tempc = temp. The 1 is for 1 decimal. no number meens 2 decial
}
}
void loop(void)
{
delay(500); // Delay for the update on the temp-sensors
sensors.requestTemperatures();
lcd.setCursor(0, 0); // First line, first "box" on the LCD-display
lcd.print("Temp1: "); // The text before the actual reading
printTemperature(insideThermometer); // What sensor that should be written
lcd.setCursor(0, 1); // Second line, first "box" on the LCD-display
lcd.print("Temp2: "); // The text before the actual reading
printTemperature(insideThermometer2); // What sensor that should be written
}