Boa tarde, sou novo no forum e prcisava da vossa ajuda para um projeto uma vez que não percebo nada de livraria de arduinos, automatizar o meu aquario com o arduino.
Material que tenho:
Arduino uno
LCD 2x16
sensor temperatura Dallas DS18B20
Modulo de 8 canais para arduino(para ligar as bombas de agua luzes comedores e fertilizante)
RTC DS3231 AT24C32 llC
pretendo ver no LCD as horas e a data
a temperatura
e ligar as luzes com o timer por exemplo as 14h00 e desligar as 24h00
dar de comer 2 vezez ao dia
fertelizar em dias alternados (exp 2ªfeira ,4ª , 6ª )
tenho só um rele ligado ao pino 13 para ir tentando
Já tentei com outros exemplos e não consigo está muito confuso
obrigado pela voss atenção.
/*
DS3231_test.pde
Eric Ayars
4/11
Test/demo of read routines for a DS3231 RTC.
Turn on the serial monitor after loading this to check if things are
working as they should.
*/
#include <OneWire.h>
#include <LiquidCrystal.h> //Inclui a biblioteca do LCD
#include <DS3231.h>
#include <Wire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 10
#define RELAY13 //pino do rele
OneWire oneWire(ONE_WIRE_BUS);
unsigned long UtlTime;
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer = { 0x28, 0xDF, 0x63, 0x51, 0x05, 0x00, 0x00, 0xC3 };
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
DS3231 Clock;
bool Century=false;
bool h12;
bool PM;
byte ADay, AHour, AMinute, ASecond, ABits;
bool ADy, A12h, Apm;
int pinorelay13 = 13;
byte year, month, date, DoW, hour, minute, second;
void setup() {
pinMode(pinorelay13, OUTPUT); //Define o pino como saida
sensors.begin();
sensors.setResolution(insideThermometer, 10);
// Start the I2C interface
Wire.begin();
Clock.setSecond(10);//Set the second
Clock.setMinute(50);//Set the minute
Clock.setHour(18); //Set the hour
Clock.setDoW(8); //Set the day of the week
Clock.setDate(7); //Set the date of the month
Clock.setMonth(8); //Set the month of the year
Clock.setYear(14); //Set the year (Last two digits of the year)
// Start the serial interface
Serial.begin(115200);
lcd.begin(16, 2);
lcd.clear(); // start with a blank screen
}
void ReadDS3231()
{
int second,minute,hour,date,month,year,temperature;
second=Clock.getSecond();
minute=Clock.getMinute();
hour=Clock.getHour(h12, PM);
date=Clock.getDate();
month=Clock.getMonth(Century);
year=Clock.getYear();
Serial.print("20");
Serial.print(year,DEC);
Serial.print('-');
Serial.print(month,DEC);
Serial.print('-');
Serial.print(date,DEC);
Serial.print(' ');
Serial.print(hour,DEC);
Serial.print(':');
Serial.print(minute,DEC);
Serial.print(':');
Serial.print(second,DEC);
Serial.print('\n');
lcd.setCursor(0,0);
lcd.print("20");
lcd.print(year,DEC);
lcd.print('-');
lcd.print(month,DEC);
lcd.print('-');
lcd.print(date,DEC);
lcd.print(' ');
lcd.setCursor(0,1);
lcd.print(hour,DEC);
lcd.print(':');
lcd.print(minute,DEC);
lcd.print(':');
lcd.print(second,DEC);
lcd.print('\n');
lcd.setCursor(11,0);
lcd.print("Temp");
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
lcd.print("Error");
}
else
{
lcd.setCursor(10,1);
lcd.print(tempC);
lcd.print("C");
lcd.print(DallasTemperature::toFahrenheit(tempC));
}
}
void loop()
{
//Aciona o rele
digitalWrite(pinorelay13, HIGH);
delay(50); //Aguarda 2 Horas
//Desliga o rele
digitalWrite(pinorelay13, LOW);
delay(50); //Aguarda 5 segundos e reinicia o processo
ReadDS3231();
delay(1000);
sensors.requestTemperatures();
printTemperature(insideThermometer);
lcd.setCursor(0,1);
delay(04/33/20); //
//Desliga o rele
delay(04/36/20); //Aguarda 5 segundos
// send what's going on to the serial monitor.
// Start with the year
/* Serial.print("2");
if (Century) { // Won't need this for 89 years.
Serial.print("1");
} else {
Serial.print("0");
}
Serial.print(Clock.getYear(), DEC);
Serial.print('-');
// then the month
Serial.print(Clock.getMonth(Century), DEC);
Serial.print('-');
// then the date
Serial.print(Clock.getDate(), DEC);
Serial.print(' ');*/
// and the day of the week
/*Serial.print(Clock.getDoW(), DEC);
Serial.print(' ');*/
// Finally the hour, minute, and second
/*Serial.print(Clock.getHour(h12, PM), DEC);
Serial.print(':');
Serial.print(Clock.getMinute(), DEC);
Serial.print(':');
Serial.print(Clock.getSecond(), DEC);
// Add AM/PM indicator
if (h12) {
if (PM) {
Serial.print(" PM ");
} else {
Serial.print(" AM ");
}
} else {
Serial.print(" 24h ");
}
} else {
Serial.print(" O-");
}*/
// Indicate whether an alarm went off
/*if (Clock.checkIfAlarm(1)) {
Serial.print(" A1!");
}
if (Clock.checkIfAlarm(10)) {
Serial.print(" 10!");
}*/
// New line on display
//Serial.print('\n');
// delay(1000);
// Display Alarm 1 information
/* Serial.print("Alarm 1: ");
Clock.getA1Time(ADay, AHour, AMinute, ASecond, ABits, ADy, A12h, Apm);
Serial.print(ADay, DEC);
if (ADy) {
Serial.print(" DoW");
} else {
Serial.print(" Date");
}
Serial.print(' ');
Serial.print(AHour, DEC);
Serial.print(' ');
Serial.print(AMinute, DEC);
Serial.print(' ');
Serial.print(ASecond, DEC);
Serial.print(' ');
if (A12h) {
if (Apm) {
Serial.print('pm ');
} else {
Serial.print('am ');
}
}
if (Clock.checkAlarmEnabled(1)) {
Serial.print("enabled");
}
Serial.print('\n');
// Display Alarm 2 information
Serial.print("Alarm 2: ");
Clock.getA2Time(ADay, AHour, AMinute, ABits, ADy, A12h, Apm);
Serial.print(ADay, DEC);
if (ADy) {
Serial.print(" DoW");
} else {
Serial.print(" Date");
}
Serial.print(' ');
Serial.print(AHour, DEC);
Serial.print(' ');
Serial.print(AMinute, DEC);
Serial.print(' ');
if (A12h) {
if (Apm) {
Serial.print('pm');
} else {
Serial.print('am');
}
}
if (Clock.checkAlarmEnabled(2)) {
Serial.print("enabled");
}*/
/* display alarm bits
Serial.print('\n');
Serial.print('Alarm bits: ');
Serial.print(ABits, DEC);
*/
/*
Serial.print('\n');
Serial.print('\n');
delay(1000);
// Display the time once more as a test of the getTime() function
Clock.getTime(year, month, date, DoW, hour, minute, second);
Serial.print(year, DEC);
Serial.print("/");
Serial.print(month, DEC);
Serial.print("/");
Serial.print(date, DEC);
Serial.print("day of the week :");
Serial.println(DoW, DEC);
Serial.print(hour, DEC);
Serial.print(":");
Serial.print(minute, DEC);
Serial.print(":");
Serial.println(second, DEC);*/
}
Tags:
Minhas sugestões :
Faça teste de cada coisa separadamente, e depois implemente a sua aplicação:
Verifique se as ligações estão corretas.
RTC :
https://github.com/rodan/ds3231
http://www.instructables.com/id/Arduino-Aquaponics-Real-Time-Clock-...
Termometro:
http://labdegaragem.com/profiles/blogs/tutorial-como-utilizar-o-sen...
LCD:
http://labdegaragem.com/profiles/blogs/tutorial-lcd-com-arduino
Bem-vindo a
Laboratorio de Garagem (arduino, eletrônica, robotica, hacking)
© 2024 Criado por Marcelo Rodrigues. Ativado por