Uz aj ja som hrdim vlastnnikom Arduina.Obraciam sa na vas.Nevedel by mi niekdo pomoct spravit podmienku?Moja predstava je ak v bojleru 1 bude teplota 60 c nezapinaj rele ak bude viac ako 60 zapny.Pripojene mam 2x DS18B20.Dakujem
- Kód: Vybrat vše
#include <OneWire.h>
#include <DallasTemperature.h>
#include <PCD8544.h>
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html
DeviceAddress insideThermometer = { 0x28, 0x6C, 0x2B, 0x24, 0x03, 0x00, 0x00, 0xB2 };
DeviceAddress outsideThermometer = { 0x28, 0x48, 0x24, 0x24, 0x03, 0x00, 0x00, 0xB7 };
// The dimensions of the LCD (in pixels)...
static const byte LCD_WIDTH = 84;
static const byte LCD_HEIGHT = 48;
static PCD8544 lcd;
const int LED = 13;
// A bitmap graphic (10x2) of a thermometer...
static const byte THERMO_WIDTH = 10;
static const byte THERMO_HEIGHT = 2;
static const byte thermometer[] = { 0x00, 0x00, 0x48, 0xfe, 0x01, 0xfe, 0x00, 0x02, 0x05, 0x02,
0x00, 0x00, 0x62, 0xff, 0xfe, 0xff, 0x60, 0x00, 0x00, 0x00};
// --------------------------------------------------------------------------------------------------
void setup(void)
{
lcd.clear();
pinMode(LED, OUTPUT);
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(insideThermometer, 10);
sensors.setResolution(outsideThermometer, 10);
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
lcd.print(tempC);
lcd.print(" ");
if (tempC > 22.00 ) // podmienka na zopnutie rele
digitalWrite(LED, HIGH);
else
digitalWrite(LED, LOW);
}
void loop(void)
{
delay(500);
sensors.requestTemperatures();
lcd.setCursor(10,1);
lcd.print("Bojler (1): ");
printTemperature(insideThermometer);
lcd.setCursor(10,5);
lcd.print("Bojler (2): ");
printTemperature(outsideThermometer);
// Draw the thermometer bitmap at the bottom left corner...
lcd.setCursor(0,0);
lcd.drawBitmap(thermometer, THERMO_WIDTH, THERMO_HEIGHT);
lcd.setCursor(0,4);
lcd.drawBitmap(thermometer, THERMO_WIDTH, THERMO_HEIGHT);
}