Tu masz z termometrami ale jak odczytać numer czujnika to sobie sam poszukaj
albo niech ci będzie tutaj masz gotowca
http://arduino-info.wikispaces.com/Brick...individual
Kod:
//#include <ShiftRegLCD123.h>
//ShiftRegLCD123 lcd( 7, 6, SRLCD123);
#include <Wire.h>
#include "RTClib.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlightpin, polarity
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 8
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress Termo1 = { 0x28, 0x6E, 0xC0, 0x03, 0x00, 0x00, 0x80, 0xE8 }; // tutaj i poniżej musisz wstawić numer swojego czujnika bo nie zadziała
DeviceAddress Termo2 = { 0x28, 0x7D, 0xC8, 0x03, 0x00, 0x00, 0x80, 0xD4 };
RTC_DS1307 rtc;
int rok ;
byte miesiac ;
byte dzien ;
byte godzina ;
byte minuta ;
byte sekunda ;
long pm ;
long zm ;
byte Lcd = 3;
int POM[10];
byte x = 0 ;
long Pm = 0 ;
byte Srednia = 0 ;
byte LPG = 0 ;
void setup () {
lcd.begin(16,2);
lcd.backlight();
lcd.clear();
sensors.begin();
sensors.setResolution(Termo1, 10);
sensors.setResolution(Termo2, 10);
Serial.begin(9600);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running!");
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
rtc.adjust(DateTime(2016, 5, 6, 18, 15, 0));
}
}
void loop () {
sensors.requestTemperatures();
long cm = millis();
if ( cm - zm > 10000 ){
Lcd ++ ;lcd.clear();zm = cm;
if (Lcd > 3)Lcd = 1;
}
DateTime now = rtc.now();
rok = now.year(),DEC;
miesiac = now.month(),DEC;
dzien = now.day(),DEC;
godzina = now.hour(),DEC;
minuta = now.minute(),DEC;
sekunda = now.second(),DEC;
if ( cm - pm >= 500 ){
int pom = analogRead(A0)/4;
POM[x] = pom ;
x = x + 1 ;
pm = cm ;
}
if ( x > 9 ){
Srednia = (POM[0]+POM[1]+POM[2]+POM[3]+POM[4]+
POM[5]+POM[6]+POM[7]+POM[8]+POM[9])/10 ;
x = 0;}
LPG = map( Srednia,9,201,0,100 ); // podstaw za 2 pierwsze zmienne dla 0 min odczyt z czujnika
switch(Lcd){
case 1:
lcd.setCursor(3, 0);
lcd.print(zero(dzien));
lcd.print('/');
lcd.print(zero(miesiac));
lcd.print("/");
lcd.print(rok);
lcd.print(" ");
lcd.setCursor(4, 1);
lcd.print(zero(godzina));
lcd.print(":");
lcd.print(zero(minuta));
lcd.print(":");
lcd.print(zero(sekunda));
lcd.print(" ");
break;
case 2:
lcd.setCursor(0, 0);
lcd.print("Poziom LPG");
lcd.setCursor(0, 1);
lcd.print("zbiornika");
lcd.setCursor(11, 1);
lcd.print(sto(LPG));
lcd.print('%');
break;
case 3:
float tempC1 = sensors.getTempC(Termo1);
float tempC2 = sensors.getTempC(Termo2);
lcd.setCursor(0, 0);
lcd.print("Tem Zew");
lcd.setCursor(9, 0);
if ( tempC1 == -127.00 ){lcd.print("Error");}
else {lcd.print(tempC1);}
lcd.print(' ');
lcd.setCursor(0, 1);
lcd.print("Tem Wew");
lcd.setCursor(9, 1);
if ( tempC2 == -127.00 ){lcd.print("Error");}
else {lcd.print(tempC2);}
lcd.print(' ');
break;
}
}
int zero(int number) {
if (number < 10){lcd.print('0');}
return number;}
int sto(int number) {
if (number < 100){lcd.print('0');}
if (number < 10){lcd.print('0');}
return number;}
albo niech ci będzie tutaj masz gotowca
http://arduino-info.wikispaces.com/Brick...individual
Ważne aby robić co się lubi albo lubić co się robi .
Arduino UNO, TINY, PRO MINI
Pomoc nagradzamy punktami reputacji
Arduino UNO, TINY, PRO MINI
Pomoc nagradzamy punktami reputacji