has solucionado tu problema
Tengo un problema, todo funciona bien pero de vez en cuando, la lectura del reloj la hace mal y lee horas raras como por ejemplo las 165:165 165/165/165 y al siguiente segundo ya lo lee correctamente pero claro, esta mala lectura me provoca que se apaguen los led un segundo.
¿Alguien sabe porque puede pasar esto?
Solo pasa de vez en cuando y durante un solo segundo
Gracias!!
A mi me paso lo mismo y fue porque la soldadura entre el rtc y el arduino estaba mala,
lo que hice fue volver a soldarla y dejo de pasar, en especifico fue la soldadura del rtc
del SCL, si se movia un poco me ponia esa hora de 165:165, al darle reset ya regresaba
pero volvia a pasar, desolde y me fije de soldar bien y se soluciono, haz la prueba y espero
se corrija el problema
Buenas nito, estoy planteandome hacer una pantalla para mi 450l. según mi litros creo que pondría 96 led espectro completo. pero mi pregunta más bien va encaminada a tanto a la fuente que necesitaría (led 3w 700ma), una sola o las meanweall?. y sobre el controlador arduino me gustaría que controlara la pantalla, nivel de agua, ph ( pero para empezar la pantalla),
Que material necesitaría, como fuente alimentación, arduino, lcd, etc.
Anteriormente monte una pantalla led para un nano, pero facil con una fuente meanwell y un potenciometro. de arduino cortito, pero me gusta hacer bricos.
Gracias de antemano
#include <OneWire.h>
#include <Wire.h>
#include "RTClib.h" // Incluye la librería RTClib
#define DS1307_I2C_ADDRESS 0x68
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
boolean HoraRetrasa;
void setup()
{
Serial.begin(9600);
Wire.begin();
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
pinMode(9, OUTPUT); // ajudicamos esa salida a la serie (tip 141)
/* Solo queremos poner en hora el reloj una vez y luego quitar la llamada de setDateDs1307. Activar esta parte y luego quitarla */
/*
second = 00;
minute = 50;
hour = 17;
dayOfWeek = 5;
dayOfMonth = 28;
month = 3;
year = 14;
setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
*/
}
void loop()
{
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year); //Obtenemos la hora
Pot(minute, hour); // declaramos fase,tiempos , hora y minutos para la fase
if (minute != minutoMemory) //Si es un nuevo minuto comprobamos cambio de hora
{
ActualizaMinuto();
}
Luces(minute, hour);
}
void ActualizaMinuto() //Cambiar hora verano-invierno
{
//Adelanta la hora a partir del dia 25 de Marzo, busca el primer domingo
//y cuando se han las 2 de la noche adelanta el reloj una hora
if (month==3)
{
if (dayOfMonth >= 26)
{
if (dayOfWeek = 7)
{
if (hour==2)
{
hour = 3;
setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
}
}
}
}
//Retrasa la hora a partir del dia 25 de Octubre, busca el primer domingo
//y cuando se han las 2 de la noche retrasa el reloj una hora
if (month==10)
{
if (dayOfMonth >= 26)
{
if (dayOfWeek = 7)
{
if ((hour==2)&&(HoraRetrasa==false))
{
hour = 1;
HoraRetrasa=true;
setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
}
}
}
}
if (hour==3)
{
HoraRetrasa=false;
}
minutoMemory=minute;
}
void Luces(int minutos, int horas)
{
///////////tiempos de progamacion//////////
int PotLED;
int InicioAmanecerLED=720; //12:00
int FinAmanecerLED=780; //13:00 //
int InicioAnochecerLED=1320; //22:00//
int FinAnochecerLED=1380; //23:00//
int MaxLED=125; //Maximo que vamos a encender los LED sobre 255
int Tiempo;
Tiempo=horas*60+minutos;
if (Tiempo < 60)
{
Tiempo=Tiempo+1440;
}
//Noche
if (Tiempo < InicioAmanecerLED )
{
PotLED=0;
Serial.println(PotLED);
}
//Amanecer
if (Tiempo >= InicioAmanecerLED && Tiempo <= FinAmanecerLED)
{
PotLED=map(Tiempo,InicioAmanecerLED,FinAmanecerLED,0,MaxLED);
Serial.println(PotLED);
}
//Dia
if ((Tiempo > FinAmanecerLED) && (Tiempo < InicioAnochecerLED))
{
PotLED=MaxLED;
Serial.println(PotLED);
}
//Anochecer
if (Tiempo >= InicioAnochecerLED && Tiempo <= FinAnochecerLED)
{
PotLED=map(Tiempo,InicioAnochecerLed,FinAnochecerLED,MaxLED,0);
Serial.println(PotLED);
}
//Control
if(PotLED < 0)
{
PotLED=0;
}
if(PotLED >MaxLED)
{
PotLED=MaxLED;
}
analogWrite(9, PotLED);
delay(1000);
}
byte bcdToDec(byte val) // Convierte BCD (binario decimal codificado) a números normales decimales
{
return ( (val/16*10) + (val%16) );
}
void setDateDs1307 (byte second, // 0-59
byte minute, // 0-59
byte hour, // 1-23
byte dayOfWeek, // 1-7
byte dayOfMonth, // 1-28/29/30/31
byte month, // 1-12
byte year) // 0-99
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.send(decToBcd(second)); // 0 a bit 7 inicia el reloj
Wire.send(decToBcd(minute));
Wire.send(decToBcd(hour));
Wire.send(decToBcd(dayOfWeek));
Wire.send(decToBcd(dayOfMonth));
Wire.send(decToBcd(month));
Wire.send(decToBcd(year));
Wire.endTransmission();
}
// Establece la fecha y el tiempo del ds1307
void getDateDs1307 (byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Resetea el registro puntero
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
// Alguno de estos necesitan enmascarar porque ciertos bits son bits de control
*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f);
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}
[/QUOTE]Hola soy nuevo en este foro y espero me puedan ayudar, eh estado leyendo sobre el tema y la verdad es que no se mucho de programación pero leyendo y viendo videos pude realizar lo del reloj con un RTC y mostrarlo en un LCD 16x2 pero tengo la necesidad de realizar el cambio de horario verano/invierno, copie este ejemplo pensando que eso resolveria mi problema pero al momento de tratar de compilar me pone lo siguiente:
'setDateDs1307' was not declared in this scope, tambien note que dayOfMonth no se pone de color naraja como las otras palabra como dayOfWeek, o las otras como second,minute,hour y todo eso. es la unica que no se torna en color naraja. si alguien me puede ayudar se lo agradeceria muchisimo.
PHP:#include <OneWire.h> #include <Wire.h> #include "RTClib.h" // Incluye la librería RTClib #define DS1307_I2C_ADDRESS 0x68 byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; boolean HoraRetrasa; void setup() { Serial.begin(9600); Wire.begin(); byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; pinMode(9, OUTPUT); // ajudicamos esa salida a la serie (tip 141) /* Solo queremos poner en hora el reloj una vez y luego quitar la llamada de setDateDs1307. Activar esta parte y luego quitarla */ /* second = 00; minute = 50; hour = 17; dayOfWeek = 5; dayOfMonth = 28; month = 3; year = 14; setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year); */ } void loop() { getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year); //Obtenemos la hora Pot(minute, hour); // declaramos fase,tiempos , hora y minutos para la fase if (minute != minutoMemory) //Si es un nuevo minuto comprobamos cambio de hora { ActualizaMinuto(); } Luces(minute, hour); } void ActualizaMinuto() //Cambiar hora verano-invierno { //Adelanta la hora a partir del dia 25 de Marzo, busca el primer domingo //y cuando se han las 2 de la noche adelanta el reloj una hora if (month==3) { if (dayOfMonth >= 26) { if (dayOfWeek = 7) { if (hour==2) { hour = 3; setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year); } } } } //Retrasa la hora a partir del dia 25 de Octubre, busca el primer domingo //y cuando se han las 2 de la noche retrasa el reloj una hora if (month==10) { if (dayOfMonth >= 26) { if (dayOfWeek = 7) { if ((hour==2)&&(HoraRetrasa==false)) { hour = 1; HoraRetrasa=true; setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year); } } } } if (hour==3) { HoraRetrasa=false; } minutoMemory=minute; } void Luces(int minutos, int horas) { ///////////tiempos de progamacion////////// int PotLED; int InicioAmanecerLED=720; //12:00 int FinAmanecerLED=780; //13:00 // int InicioAnochecerLED=1320; //22:00// int FinAnochecerLED=1380; //23:00// int MaxLED=125; //Maximo que vamos a encender los LED sobre 255 int Tiempo; Tiempo=horas*60+minutos; if (Tiempo < 60) { Tiempo=Tiempo+1440; } //Noche if (Tiempo < InicioAmanecerLED ) { PotLED=0; Serial.println(PotLED); } //Amanecer if (Tiempo >= InicioAmanecerLED && Tiempo <= FinAmanecerLED) { PotLED=map(Tiempo,InicioAmanecerLED,FinAmanecerLED,0,MaxLED); Serial.println(PotLED); } //Dia if ((Tiempo > FinAmanecerLED) && (Tiempo < InicioAnochecerLED)) { PotLED=MaxLED; Serial.println(PotLED); } //Anochecer if (Tiempo >= InicioAnochecerLED && Tiempo <= FinAnochecerLED) { PotLED=map(Tiempo,InicioAnochecerLed,FinAnochecerLED,MaxLED,0); Serial.println(PotLED); } //Control if(PotLED < 0) { PotLED=0; } if(PotLED >MaxLED) { PotLED=MaxLED; } analogWrite(9, PotLED); delay(1000); } byte bcdToDec(byte val) // Convierte BCD (binario decimal codificado) a números normales decimales { return ( (val/16*10) + (val%16) ); } void setDateDs1307 (byte second, // 0-59 byte minute, // 0-59 byte hour, // 1-23 byte dayOfWeek, // 1-7 byte dayOfMonth, // 1-28/29/30/31 byte month, // 1-12 byte year) // 0-99 { Wire.beginTransmission(DS1307_I2C_ADDRESS); Wire.send(0); Wire.send(decToBcd(second)); // 0 a bit 7 inicia el reloj Wire.send(decToBcd(minute)); Wire.send(decToBcd(hour)); Wire.send(decToBcd(dayOfWeek)); Wire.send(decToBcd(dayOfMonth)); Wire.send(decToBcd(month)); Wire.send(decToBcd(year)); Wire.endTransmission(); } // Establece la fecha y el tiempo del ds1307 void getDateDs1307 (byte *second, byte *minute, byte *hour, byte *dayOfWeek, byte *dayOfMonth, byte *month, byte *year) { // Resetea el registro puntero Wire.beginTransmission(DS1307_I2C_ADDRESS); Wire.send(0); Wire.endTransmission(); Wire.requestFrom(DS1307_I2C_ADDRESS, 7); // Alguno de estos necesitan enmascarar porque ciertos bits son bits de control *second = bcdToDec(Wire.receive() & 0x7f); *minute = bcdToDec(Wire.receive()); *hour = bcdToDec(Wire.receive() & 0x3f); *dayOfWeek = bcdToDec(Wire.receive()); *dayOfMonth = bcdToDec(Wire.receive()); *month = bcdToDec(Wire.receive()); *year = bcdToDec(Wire.receive()); }