This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

  • 1 voto(s) - 4 Media
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLUCIONADO]ayuda con comando de fecha
#1
hola muy buenas a todos, resulta que al cargar la programación dentro del arduino me tira un error que os adjunto en una foto, haber si alguien sabe como lo puedo solucionar, muchas gracias.


Archivos adjuntos Miniatura(s)
   
  Responder
#2
Para la hora y fecha que usas algun RTC?, tienes declarada la libreria?
  Responder
#3
no tengo mucha idea de trabajar con arduino, pero pensé que como venia el código ya echo no tendría que poner nada, he estado leyendo por varios sitios pero no aclara nada, pensé que quizá habría que poner la fecha en el código y ya esta.
  Responder
#4
Da mas datos, que pretendes hacer como y con que, postea el codigo entero, asi podemos ayudarte mejor compañero

Esque si sin saber que elementos usas y demas no puedo decirte :dale2:
  Responder
#5
jajajaja tienes razón Facepalm perdón. bueno el proyecto es el garduino, aquí os pongo el enlace:

http://makezine.com/projects/make-18/gar...gardening/

y aqui el codigo:

//include the datetime library, so our garduino can keep track of how long the lights are on
#include

//define analog inputs to which we have connected our sensors
int moistureSensor = 0;
int lightSensor = 1;
int tempSensor = 2;

//define digital outputs to which we have connecte our relays (water and light) and LED (temperature)
int waterPump = 7;
int lightSwitch = 8;
int tempLed = 2;

//define variables to store moisture, light, and temperature values
int moisture_val;
int light_val;
int temp_val;

//decide how many hours of light your plants should get daily
float hours_light_daily_desired = 14;

//calculate desired hours of light total and supplemental daily based on above values
float proportion_to_light = hours_light_daily_desired / 24;
float seconds_light = 0;
float proportion_lit;

//setup a variable to store seconds since arduino switched on
float start_time;
float seconds_elapsed;
float seconds_elapsed_total;
float seconds_for_this_cycle;

void setup() {
//open serial port
Serial.begin(9600);
//set the water, light, and temperature pins as outputs that are turned off
pinMode (waterPump, OUTPUT);
pinMode (lightSwitch, OUTPUT);
pinMode (tempLed, OUTPUT);
digitalWrite (waterPump, LOW);
digitalWrite (lightSwitch, LOW);
digitalWrite (tempLed, LOW);

//establish start time
start_time = DateTime.now();
seconds_elapsed_total = 0;

}
void loop() {
// read the value from the moisture-sensing probes, print it to screen, and wait a second
moisture_val = analogRead(moistureSensor);
Serial.print("moisture sensor reads ");
Serial.println( moisture_val );
delay(1000);
// read the value from the photosensor, print it to screen, and wait a second
light_val = analogRead(lightSensor);
Serial.print("light sensor reads ");
Serial.println( light_val );
delay(1000);
// read the value from the temperature sensor, print it to screen, and wait a second
temp_val = analogRead(tempSensor);
Serial.print("temp sensor reads ");
Serial.println( temp_val );
delay(1000);
Serial.print("seconds total = ");
Serial.println( seconds_elapsed_total );
delay(1000);
Serial.print("seconds lit = ");
Serial.println( seconds_light);
delay(1000);
Serial.print("proportion desired = ");
Serial.println( proportion_to_light);
delay(1000);
Serial.print("proportion achieved = ");
Serial.println( proportion_lit);
delay(1000);

//turn water on when soil is dry, and delay until soil is wet
if (moisture_val < 850)
{
digitalWrite(waterPump, HIGH);
}

while (moisture_val < 850)
{
delay(10000);
}

digitalWrite(waterPump, LOW);

//update time, and increment seconds_light if the lights are on
seconds_for_this_cycle = DateTime.now() - seconds_elapsed_total;
seconds_elapsed_total = DateTime.now() - start_time;
if (light_val > 900)
{
seconds_light = seconds_light + seconds_for_this_cycle;
}

//cloudy days that get sunny again: turn lights back off if light_val exceeds 900. this works b/c the supplemental lights aren't as bright as the sunSonrisa
if (light_val > 900)
{
digitalWrite (lightSwitch, LOW);
}

//turn off lights if proportion_lit>proportion_to_light, and then wait 5 minutes
if (proportion_lit > proportion_to_light)
{
digitalWrite (lightSwitch, LOW);
delay (300000);
}

//figure out what proportion of time lights have been on
proportion_lit = seconds_light/seconds_elapsed_total;

//turn lights on if light_val is less than 900 and plants have light for less than desired proportion of time, then wait 10 seconds
if (light_val < 900 and proportion_lit < proportion_to_light)
{
digitalWrite(lightSwitch, HIGH);
delay(10000);
}

//turn on temp alarm light if temp_val is less than 850 (approximately 50 degrees Fahrenheit)
if (temp_val < 850)
{
digitalWrite(tempLed, HIGH);
}

}
  Responder
#6
En ese codigo, al principio donde ves el #include, falta el nombre de la liberia, nose si el arduino la trae ya al bajarte el ide, donde pone eso pon:

#include

Sino tienes que meter la libreria, controlar de meter librerias en el IDE de arduino?
  Responder
#7
que va, soy nivel muy principiante en esto de arduino, pero por lo que creo entender hay librerías estándar para darle ciertas funciones al proyecto que estés creando no?
  Responder
#8
Si, algunas vienen ya cuando instalas el IDE de arduino, prueba con el cambio que te dije, si no te funciona miramos para meter la libreria
  Responder
#9
ya lo he probado y sigue igual
  Responder
#10
Bajate la libreria:

http://playground.arduino.cc/uploads/Code/DateTime.zip

Creo que es esa ya que hay versiones mas nuevas, y lo descomprimes en la carpeta librerias del IDE de arduino, esta en mis documentos si no me falla la memoria, y pones asi el codigo, veras el cambio en los INCLUDES

Código:
//include the datetime library, so our garduino can keep track of how long the lights are on
#include <DateTime.h>
#include <DateTimeStrings.h>

//define analog inputs to which we have connected our sensors
int moistureSensor = 0;
int lightSensor = 1;
int tempSensor = 2;

//define digital outputs to which we have connecte our relays (water and light) and LED (temperature)
int waterPump = 7;
int lightSwitch = 8;
int tempLed = 2;

//define variables to store moisture, light, and temperature values
int moisture_val;
int light_val;
int temp_val;

//decide how many hours of light your plants should get daily
float hours_light_daily_desired = 14;

//calculate desired hours of light total and supplemental daily based on above values
float proportion_to_light = hours_light_daily_desired / 24;
float seconds_light = 0;
float proportion_lit;

//setup a variable to store seconds since arduino switched on
float start_time;
float seconds_elapsed;
float seconds_elapsed_total;
float seconds_for_this_cycle;

void setup() {
//open serial port
Serial.begin(9600);
//set the water, light, and temperature pins as outputs that are turned off
pinMode (waterPump, OUTPUT);
pinMode (lightSwitch, OUTPUT);
pinMode (tempLed, OUTPUT);
digitalWrite (waterPump, LOW);
digitalWrite (lightSwitch, LOW);
digitalWrite (tempLed, LOW);

//establish start time
start_time = DateTime.now();
seconds_elapsed_total = 0;

}
void loop() {
// read the value from the moisture-sensing probes, print it to screen, and wait a second
moisture_val = analogRead(moistureSensor);
Serial.print("moisture sensor reads ");
Serial.println( moisture_val );
delay(1000);
// read the value from the photosensor, print it to screen, and wait a second
light_val = analogRead(lightSensor);
Serial.print("light sensor reads ");
Serial.println( light_val );
delay(1000);
// read the value from the temperature sensor, print it to screen, and wait a second
temp_val = analogRead(tempSensor);
Serial.print("temp sensor reads ");
Serial.println( temp_val );
delay(1000);
Serial.print("seconds total = ");
Serial.println( seconds_elapsed_total );
delay(1000);
Serial.print("seconds lit = ");
Serial.println( seconds_light);
delay(1000);
Serial.print("proportion desired = ");
Serial.println( proportion_to_light);
delay(1000);
Serial.print("proportion achieved = ");
Serial.println( proportion_lit);
delay(1000);

//turn water on when soil is dry, and delay until soil is wet
if (moisture_val < 850)
{
digitalWrite(waterPump, HIGH);
}

while (moisture_val < 850)
{
delay(10000);
}

digitalWrite(waterPump, LOW);

//update time, and increment seconds_light if the lights are on
seconds_for_this_cycle = DateTime.now() - seconds_elapsed_total;
seconds_elapsed_total = DateTime.now() - start_time;
if (light_val > 900)
{
seconds_light = seconds_light + seconds_for_this_cycle;
}

//cloudy days that get sunny again: turn lights back off if light_val exceeds 900. this works b/c the supplemental lights aren't as bright as the sun:)
if (light_val > 900)
{
digitalWrite (lightSwitch, LOW);
}

//turn off lights if proportion_lit>proportion_to_light, and then wait 5 minutes
if (proportion_lit > proportion_to_light)
{
digitalWrite (lightSwitch, LOW);
delay (300000);
}

//figure out what proportion of time lights have been on
proportion_lit = seconds_light/seconds_elapsed_total;

//turn lights on if light_val is less than 900 and plants have light for less than desired proportion of time, then wait 10 seconds
if (light_val < 900 and proportion_lit < proportion_to_light)
{
digitalWrite(lightSwitch, HIGH);
delay(10000);
}

//turn on temp alarm light if temp_val is less than 850 (approximately 50 degrees Fahrenheit)
if (temp_val < 850)
{
digitalWrite(tempLed, HIGH);
}

}
  Responder
#11
madre mia sigue con el mismo error
  Responder
#12
wuasichu escribió:madre mia sigue con el mismo error

Hay que modificar una cosilla en la libreria para que funcione, y te compilara OK, la libreria que usan es antigua, te la voy a subir a drive, borra la que metiste y pon esta, estoy suponiendo que pones bien las librerias, como las metes en el IDE?

Te la dejo subida por media hora, luego la borro:

https://drive.google.com/file/d/0B2mNTyJ...sp=sharing
  Responder
#13
no me deja descargarla
  Responder
#14
Ahora?
  Responder
#15
:nuse: :nuse: :nuse: las copio dentro de la carpeta que me dijiste en arduino me voy a librerías y le copio la carpeta dentro, luego he iniciado el programa de nuevo para que cargara con las librerías ya dentro de arduino y luego le he puesto el código que tu me has enviado, viendo que no funcionaba lo he intentado como me has explicado primero: <DateTime.h>, espero no haberme equivocado en nada......
  Responder
#16
tampoco le estoy dando a download y no hace nada
  Responder
#17
wuasichu escribió:tampoco le estoy dando a download y no hace nada

https://www.dropbox.com/s/7m2iocw7t5cq82...a.rar?dl=0

Aqui?

Hiciste bien, deja el codigo como te dije, borra las dos que metiste antes, y mete estas en su lugar
  Responder
#18
:yeah: :yeah: :yeah: :yeah: :yeah: :yeah: :yeah: :yeah: :yeah: mil gracias triggerr ya me compila perfecto, eres una maquina tio !!!!!!! menos mal porque ya me estaba asustando. un saludo colega, ya te enseñare este cacharro funcionando jejejeje
  Responder
#19
Esperamos el bicho funcionando Gran sonrisa

Era un tema de que la libreria era vieja, y hay que añadirles una libreria para que todo vaya correcto, en concreto la Arduino.h

;D
  Responder