collapse

* Posts Recentes

Emulador NES em ESP32 por dropes
[Ontem às 15:31]


Arame de Estendal por almamater
[18 de Abril de 2024, 16:16]


O que é isto ? por SerraCabo
[12 de Abril de 2024, 14:20]


Amplificador - Rockboard HA 1 In-Ear por almamater
[11 de Abril de 2024, 20:46]


Meu novo robô por josecarlos
[29 de Março de 2024, 18:30]


Bateria - Portátil por almamater
[25 de Março de 2024, 22:14]


Escolher Osciloscópio por jm_araujo
[06 de Fevereiro de 2024, 23:07]


TP4056 - Dúvida por dropes
[31 de Janeiro de 2024, 14:13]


Leitura de dados por Porta Serie por jm_araujo
[22 de Janeiro de 2024, 14:00]


Distancia Cabo por jm_araujo
[08 de Janeiro de 2024, 16:30]

Autor Tópico: Controlo de estufa.  (Lida 25715 vezes)

0 Membros e 1 Visitante estão a ver este tópico.

Offline jony-kid

  • Mini Robot
  • *
  • Mensagens: 54
Re: Controlo de estufa.
« Responder #30 em: 23 de Fevereiro de 2012, 22:59 »
já guardei nas library's agora o que tenho de fazer?

Tenho estes 2 codigos.

Código: [Seleccione]
// Simple date conversions and calculations

#include <Wire.h>
#include "RTClib.h"

void showDate(const char* txt, const DateTime& dt) {
    Serial.print(txt);
    Serial.print(' ');
    Serial.print(dt.year(), DEC);
    Serial.print('/');
    Serial.print(dt.month(), DEC);
    Serial.print('/');
    Serial.print(dt.day(), DEC);
    Serial.print(' ');
    Serial.print(dt.hour(), DEC);
    Serial.print(':');
    Serial.print(dt.minute(), DEC);
    Serial.print(':');
    Serial.print(dt.second(), DEC);
   
    Serial.print(" = ");
    Serial.print(dt.unixtime());
    Serial.print("s / ");
    Serial.print(dt.unixtime() / 86400L);
    Serial.print("d since 1970");
   
    Serial.println();
}

void setup () {
    Serial.begin(57600);
   
    DateTime dt0 (0, 1, 1, 0, 0, 0);
    showDate("dt0", dt0);

    DateTime dt1 (1, 1, 1, 0, 0, 0);
    showDate("dt1", dt1);

    DateTime dt2 (2009, 1, 1, 0, 0, 0);
    showDate("dt2", dt2);

    DateTime dt3 (2009, 1, 2, 0, 0, 0);
    showDate("dt3", dt3);

    DateTime dt4 (2009, 1, 27, 0, 0, 0);
    showDate("dt4", dt4);

    DateTime dt5 (2009, 2, 27, 0, 0, 0);
    showDate("dt5", dt5);

    DateTime dt6 (2009, 12, 27, 0, 0, 0);
    showDate("dt6", dt6);

    DateTime dt7 (dt6.unixtime() + 3600); // one hour later
    showDate("dt7", dt7);

    DateTime dt8 (dt6.unixtime() + 86400L); // one day later
    showDate("dt8", dt8);

    DateTime dt9 (dt6.unixtime() + 7 * 86400L); // one week later
    showDate("dt9", dt9);
}

void loop () {
}

Código: [Seleccione]
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib

#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 RTC;

void setup () {
    Serial.begin(57600);
    Wire.begin();
    RTC.begin();

  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
}

void loop () {
    DateTime now = RTC.now();
   
    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();
   
    Serial.print(" since midnight 1/1/1970 = ");
    Serial.print(now.unixtime());
    Serial.print("s = ");
    Serial.print(now.unixtime() / 86400L);
    Serial.println("d");
   
    // calculate a date which is 7 days and 30 seconds into the future
    DateTime future (now.unixtime() + 7 * 86400L + 30);
   
    Serial.print(" now + 7d + 30s: ");
    Serial.print(future.year(), DEC);
    Serial.print('/');
    Serial.print(future.month(), DEC);
    Serial.print('/');
    Serial.print(future.day(), DEC);
    Serial.print(' ');
    Serial.print(future.hour(), DEC);
    Serial.print(':');
    Serial.print(future.minute(), DEC);
    Serial.print(':');
    Serial.print(future.second(), DEC);
    Serial.println();
   
    Serial.println();
    delay(3000);
}


Offline jony-kid

  • Mini Robot
  • *
  • Mensagens: 54
Re: Controlo de estufa.
« Responder #31 em: 24 de Fevereiro de 2012, 19:41 »
Então pessoal estou mesmo a precisar de ajuda...

Offline senso

  • Global Moderator
  • Mini Robot
  • *****
  • Mensagens: 9.733
  • Helpdesk do sitio
Re: Controlo de estufa.
« Responder #32 em: 24 de Fevereiro de 2012, 22:13 »
Agora vês se o rtc funciona como deve e incluis no teu código as partes que queres.
Avr fanboy

Offline jony-kid

  • Mini Robot
  • *
  • Mensagens: 54
Re: Controlo de estufa.
« Responder #33 em: 24 de Fevereiro de 2012, 22:32 »
Boas, obrigado pela tua disponibilidade para ajudar.

O RTC está a funcionar, o meu problema prende-se em juntar os 2 codigos.
Já tentei e não consigo entender come o devo de fazer...

Offline senso

  • Global Moderator
  • Mini Robot
  • *****
  • Mensagens: 9.733
  • Helpdesk do sitio
Re: Controlo de estufa.
« Responder #34 em: 24 de Fevereiro de 2012, 22:34 »
O que é que queres aproveitar de cada bocado mesmo?
O primeiro simplesmente define várias datas/horas e mostra isso mesmo no terminal serial com a função showDate, o segundo faz praticamente o mesmo.
Avr fanboy

Offline jony-kid

  • Mini Robot
  • *
  • Mensagens: 54
Re: Controlo de estufa.
« Responder #35 em: 24 de Fevereiro de 2012, 22:39 »
Tenho este codigo...
Código: [Seleccione]
// Arduino LCD Ambient Temperature Monitor.

// Displays Current, 8 sec Average, Max and Min Temperature.

// To wire your LED screen to your Arduino, connect the following pins:
// LCD RS pin to digital pin 12
// LCD Enable pin to digital pin 11
// LCD D4 pin to digital pin 5
// LCD D5 pin to digital pin 4
// LCD D6 pin to digital pin 3
// LCD D7 pin to digital pin 2
// Additionally, wire a 10K pot to +5V and GND, with it's wiper (output) to LCD screens VO pin (pin3).
// We used the on board power source (5v and Gnd) to power the LM35 and analog pin 0 (zero) to read the analog output from the sensor.

// 17 January 2011

// include the library code:
#include <LiquidCrystal.h>  // include the LCD driver library

//declare variables
float tempC = 0;  // variable for holding Celcius temp (floating for decimal points precision)
float tempf = 0;  // variable for holding Fareghneit temp
int tempPin = 0;  // Declaring the Analog input to be 0 (A0) of Arduino board.
float samples[8]; // array to hold 8 samples for Average temp calculation
float maxi = 0,mini = 100; // max/min temperature variables with initial values. LM35 in simple setup only measures Temp above 0.
int i;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
pinMode(13, OUTPUT);  // The Red arduino led
lcd.begin(20, 4); // set up the LCD's number of columns and rows:

lcd.setCursor(0, 0); // set LCD cursor position (column, row)
lcd.print("Joao Oliveira "); // print text to LCD
lcd.setCursor(0, 1);
lcd.print("Temperature Project");
delay(5000); // wait 500ms
lcd.clear(); // clear LCD display
lcd.setCursor(0, 0);
lcd.print("LCD Ambient Temp");
lcd.setCursor(0, 1);
lcd.print(" Digital Monitor ");                                                                                                                                                                                                                                                                                                                                                                                                                             
delay(5000);
lcd.clear();


}

void loop()
{
digitalWrite(13, LOW);   // set the LED on

// Start of calculations FOR loop.
for(i = 0;i<=7;i++){ // gets 8 samples of temperature
samples[i] = ( 4.4 * analogRead(tempPin) * 100.0) / 1024.0; // conversion math of LM35 sample to readable temperature and stores result to samples array. 1024 is the Bit depth (quantization) of Arduino.
// 5 is the supply volts of LM35. Change appropriatelly to have correct measurement. My case is 4.4Volts.
// Serial.println(samples[i]);
Serial.print("."); // print a dot for every sample at serial monitor

// Display Current Celcius Temp to LCD
// ( LCD note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 0); // set LCD cursor position
lcd.print("Temp. Atual: "); // print to LCD
lcd.setCursor(12, 0);
lcd.print(samples[i]);  // print current Temp sample to LCD

tempC = tempC + samples[i]; // do the addition for average temperature
delay(800); // wait 800ms
} // END of FOR loop

Serial.println(""); // Like and CR at serial monitor
Serial.println("");
tempC = tempC/8.0; // calculated the averare of 8 samples in Celcius

tempf = (tempC * 9)/ 5 + 32; // converts to fahrenheit

if(tempC > maxi) {maxi = tempC;} // set max temperature
if(tempC < mini) {mini = tempC;} // set min temperature

// Send Results to Serial Monitor
Serial.println("New measurement");
Serial.print(" Average Temperature in Celcius is " );             //send the data to the computer
Serial.println(tempC);//send the data to the computer
Serial.print(" Average Temperature in Farenait is " );             //send the data to the computer
Serial.println(tempf);//send the data to the computer
Serial.print(" MAX Temperature in Celcius is " );             //send the data to the computer
Serial.println(maxi);//send the data to the computer
Serial.print(" MIN Temperature in Celcius is " );             //send the data to the computer
Serial.println(mini);//send the data to the computer

// Send results to LCD.
lcd.setCursor(0, 1);
lcd.print(" Av.T   Max   Min");

// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 2);
// print the measured temp average
lcd.print(tempC);
lcd.setCursor(6, 2);
// print the maximum temp
lcd.print(maxi);
lcd.setCursor(12, 2);
// print the minimum temp
lcd.print(mini);
digitalWrite(13, HIGH);    // set the LED off
delay(3000);   // Wait about 3 seconds to display the results to LCD screen befor starting the loop again
tempC = 0; // Set tempC to 0 so calculations can be done again

}

E agora queria por exemplo pôr a data e hora na 4ª linha do lcd

Offline senso

  • Global Moderator
  • Mini Robot
  • *****
  • Mensagens: 9.733
  • Helpdesk do sitio
Re: Controlo de estufa.
« Responder #36 em: 24 de Fevereiro de 2012, 22:41 »
Basicamente alteras isto:
Código: [Seleccione]
    Serial.print(txt);
    Serial.print(' ');
    Serial.print(dt.year(), DEC);
    Serial.print('/');
    Serial.print(dt.month(), DEC);
    Serial.print('/');
    Serial.print(dt.day(), DEC);
    Serial.print(' ');
    Serial.print(dt.hour(), DEC);
    Serial.print(':');
    Serial.print(dt.minute(), DEC);
    Serial.print(':');
    Serial.print(dt.second(), DEC);

Para em vez de ter Serial.print ter lcd.print, antes fazes um lcd.goto para meter na linha 4 e não é muito mais que isso.
Avr fanboy

Offline jony-kid

  • Mini Robot
  • *
  • Mensagens: 54
Re: Controlo de estufa.
« Responder #37 em: 24 de Fevereiro de 2012, 22:57 »
Não estou a conseguir...

Código: [Seleccione]
// Arduino LCD Ambient Temperature Monitor.

// Displays Current, 8 sec Average, Max and Min Temperature.

// To wire your LED screen to your Arduino, connect the following pins:
// LCD RS pin to digital pin 12
// LCD Enable pin to digital pin 11
// LCD D4 pin to digital pin 5
// LCD D5 pin to digital pin 4
// LCD D6 pin to digital pin 3
// LCD D7 pin to digital pin 2
// Additionally, wire a 10K pot to +5V and GND, with it's wiper (output) to LCD screens VO pin (pin3).
// We used the on board power source (5v and Gnd) to power the LM35 and analog pin 0 (zero) to read the analog output from the sensor.

// 17 January 2011

// include the library code:
#include <LiquidCrystal.h>  // include the LCD driver library

//declare variables
float tempC = 0;  // variable for holding Celcius temp (floating for decimal points precision)
float tempf = 0;  // variable for holding Fareghneit temp
int tempPin = 0;  // Declaring the Analog input to be 0 (A0) of Arduino board.
float samples[8]; // array to hold 8 samples for Average temp calculation
float maxi = 0,mini = 100; // max/min temperature variables with initial values. LM35 in simple setup only measures Temp above 0.
int i;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
pinMode(13, OUTPUT);  // The Red arduino led
lcd.begin(20, 4); // set up the LCD's number of columns and rows:

lcd.setCursor(0, 0); // set LCD cursor position (column, row)
lcd.print("Joao Oliveira "); // print text to LCD
lcd.setCursor(0, 1);
lcd.print("Temperature Project");
delay(5000); // wait 500ms
lcd.clear(); // clear LCD display
lcd.setCursor(0, 0);
lcd.print("LCD Ambient Temp");
lcd.setCursor(0, 1);
lcd.print(" Digital Monitor ");                                                                                                                                                                                                                                                                                                                                                                                                                             
delay(5000);
lcd.clear();


}

void loop()
{
digitalWrite(13, LOW);   // set the LED on

// Start of calculations FOR loop.
for(i = 0;i<=7;i++){ // gets 8 samples of temperature
samples[i] = ( 4.4 * analogRead(tempPin) * 100.0) / 1024.0; // conversion math of LM35 sample to readable temperature and stores result to samples array. 1024 is the Bit depth (quantization) of Arduino.
// 5 is the supply volts of LM35. Change appropriatelly to have correct measurement. My case is 4.4Volts.
// Serial.println(samples[i]);
Serial.print("."); // print a dot for every sample at serial monitor

// Display Current Celcius Temp to LCD
// ( LCD note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 0); // set LCD cursor position
lcd.print("Temp. Atual: "); // print to LCD
lcd.setCursor(12, 0);
lcd.print(samples[i]);  // print current Temp sample to LCD

tempC = tempC + samples[i]; // do the addition for average temperature
delay(800); // wait 800ms
} // END of FOR loop

Serial.println(""); // Like and CR at serial monitor
Serial.println("");
tempC = tempC/8.0; // calculated the averare of 8 samples in Celcius

tempf = (tempC * 9)/ 5 + 32; // converts to fahrenheit

if(tempC > maxi) {maxi = tempC;} // set max temperature
if(tempC < mini) {mini = tempC;} // set min temperature

// Send Results to Serial Monitor
Serial.println("New measurement");
Serial.print(" Average Temperature in Celcius is " );             //send the data to the computer
Serial.println(tempC);//send the data to the computer
Serial.print(" Average Temperature in Farenait is " );             //send the data to the computer
Serial.println(tempf);//send the data to the computer
Serial.print(" MAX Temperature in Celcius is " );             //send the data to the computer
Serial.println(maxi);//send the data to the computer
Serial.print(" MIN Temperature in Celcius is " );             //send the data to the computer
Serial.println(mini);//send the data to the computer

// Send results to LCD.
lcd.setCursor(0, 1);
lcd.print(" Av.T   Max   Min");

// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 2);
// print the measured temp average
lcd.print(tempC);
lcd.setCursor(6, 2);
// print the maximum temp
lcd.print(maxi);
lcd.setCursor(12, 2);
// print the minimum temp
lcd.print(mini);
digitalWrite(13, HIGH);    // set the LED off
delay(3000);   // Wait about 3 seconds to display the results to LCD screen befor starting the loop again
tempC = 0; // Set tempC to 0 so calculations can be done again

lcd.setCursor(0, 3);

 Serial.print(txt);
    lcd.print(' ');
    lcd.print(dt.year(), DEC);
    lcd.print('/');
    lcd.print(dt.month(), DEC);
    lcd.print('/');
    lcd.print(dt.day(), DEC);
    lcd.print(' ');
    lcd.print(dt.hour(), DEC);
    lcd.print(':');
    lcd.print(dt.minute(), DEC);
    lcd.print(':');
    lcd.print(dt.second(), DEC);
delay(1000);
}

O que tentei fazer está na ultima parte.

Offline senso

  • Global Moderator
  • Mini Robot
  • *****
  • Mensagens: 9.733
  • Helpdesk do sitio
Re: Controlo de estufa.
« Responder #38 em: 24 de Fevereiro de 2012, 23:19 »
Convinha seres mais explicito, que a minha bola de cristal hoje está um pouco enevoada..
Não leves a mal, mas diz o que acontece, e o que achas que devia acontecer, e o que queres que aconteça, dizer não estou a conseguir não ajuda de todo em nada de nada.
Avr fanboy

Offline jony-kid

  • Mini Robot
  • *
  • Mensagens: 54
Re: Controlo de estufa.
« Responder #39 em: 24 de Fevereiro de 2012, 23:31 »
Obrigado pela tua paciência...

Eu tenho o Codigo:

Código: [Seleccione]
// Arduino LCD Ambient Temperature Monitor.

// Displays Current, 8 sec Average, Max and Min Temperature.

// To wire your LED screen to your Arduino, connect the following pins:
// LCD RS pin to digital pin 12
// LCD Enable pin to digital pin 11
// LCD D4 pin to digital pin 5
// LCD D5 pin to digital pin 4
// LCD D6 pin to digital pin 3
// LCD D7 pin to digital pin 2
// Additionally, wire a 10K pot to +5V and GND, with it's wiper (output) to LCD screens VO pin (pin3).
// We used the on board power source (5v and Gnd) to power the LM35 and analog pin 0 (zero) to read the analog output from the sensor.

// 17 January 2011

// include the library code:
#include <LiquidCrystal.h>  // include the LCD driver library

//declare variables
float tempC = 0;  // variable for holding Celcius temp (floating for decimal points precision)
float tempf = 0;  // variable for holding Fareghneit temp
int tempPin = 0;  // Declaring the Analog input to be 0 (A0) of Arduino board.
float samples[8]; // array to hold 8 samples for Average temp calculation
float maxi = 0,mini = 100; // max/min temperature variables with initial values. LM35 in simple setup only measures Temp above 0.
int i;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
pinMode(13, OUTPUT);  // The Red arduino led
lcd.begin(20, 4); // set up the LCD's number of columns and rows:

lcd.setCursor(0, 0); // set LCD cursor position (column, row)
lcd.print("Joao Oliveira "); // print text to LCD
lcd.setCursor(0, 1);
lcd.print("Temperature Project");
delay(5000); // wait 500ms
lcd.clear(); // clear LCD display
lcd.setCursor(0, 0);
lcd.print("LCD Ambient Temp");
lcd.setCursor(0, 1);
lcd.print(" Digital Monitor ");                                                                                                                                                                                                                                                                                                                                                                                                                             
delay(5000);
lcd.clear();


}

void loop()
{
digitalWrite(13, LOW);   // set the LED on

// Start of calculations FOR loop.
for(i = 0;i<=7;i++){ // gets 8 samples of temperature
samples[i] = ( 4.4 * analogRead(tempPin) * 100.0) / 1024.0; // conversion math of LM35 sample to readable temperature and stores result to samples array. 1024 is the Bit depth (quantization) of Arduino.
// 5 is the supply volts of LM35. Change appropriatelly to have correct measurement. My case is 4.4Volts.
// Serial.println(samples[i]);
Serial.print("."); // print a dot for every sample at serial monitor

// Display Current Celcius Temp to LCD
// ( LCD note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 0); // set LCD cursor position
lcd.print("Temp. Atual: "); // print to LCD
lcd.setCursor(12, 0);
lcd.print(samples[i]);  // print current Temp sample to LCD

tempC = tempC + samples[i]; // do the addition for average temperature
delay(800); // wait 800ms
} // END of FOR loop

Serial.println(""); // Like and CR at serial monitor
Serial.println("");
tempC = tempC/8.0; // calculated the averare of 8 samples in Celcius

tempf = (tempC * 9)/ 5 + 32; // converts to fahrenheit

if(tempC > maxi) {maxi = tempC;} // set max temperature
if(tempC < mini) {mini = tempC;} // set min temperature

// Send Results to Serial Monitor
Serial.println("New measurement");
Serial.print(" Average Temperature in Celcius is " );             //send the data to the computer
Serial.println(tempC);//send the data to the computer
Serial.print(" Average Temperature in Farenait is " );             //send the data to the computer
Serial.println(tempf);//send the data to the computer
Serial.print(" MAX Temperature in Celcius is " );             //send the data to the computer
Serial.println(maxi);//send the data to the computer
Serial.print(" MIN Temperature in Celcius is " );             //send the data to the computer
Serial.println(mini);//send the data to the computer

// Send results to LCD.
lcd.setCursor(0, 1);
lcd.print(" Av.T   Max   Min");

// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 2);
// print the measured temp average
lcd.print(tempC);
lcd.setCursor(6, 2);
// print the maximum temp
lcd.print(maxi);
lcd.setCursor(12, 2);
// print the minimum temp
lcd.print(mini);
digitalWrite(13, HIGH);    // set the LED off
delay(3000);   // Wait about 3 seconds to display the results to LCD screen befor starting the loop again
tempC = 0; // Set tempC to 0 so calculations can be done again

}

Agora na 4ª linha queria colocar a data e hora.
Mas não estou mesmo a ver como se faz!!!
Não entendo como devo de juntar o codigo que puses-te no post a cima.
Neste momento todo o codigo acima está a funcionar corretamente.

Pesso desculpa mas eu não percebo mesmo dada disto e entendo que estar a explicar a "burros" é complicado, isto de ser serralheiro e gostar destas coisas não é facil, isto já me tem tirado umas horas de sone em vão.

Não queria desistir mas já estive mais longe...



Offline jony-kid

  • Mini Robot
  • *
  • Mensagens: 54
Re: Controlo de estufa.
« Responder #40 em: 26 de Fevereiro de 2012, 16:17 »
Por fim e com a ajuda de um amigo  lá consegui pôr o bicho a funcionar.

Penso que a funcionar corretamente...
Usei uma pilha que tinha aqui por casa de um comando do alarme de um carro com a referencia CR2016 Lithium Battery, tudo funciona mas quando deixo de alimentar o arduino a bateria não faz o seu papel, não consegue guardar a hora atual.
Lá fui eu então até ao supermercado tentar encontrar uma pilha para a substituir.

Foi então que encontrei uma com a referência igual á do topico do tr3s http://lusorobotica.com/index.php?topic=681.0 mas com uma diferença....
A que comprei não é de Lithium mas sim Li-Mn, qual é o meu espanto quando a experimento e ela não funciona corretamente.

No Serialprint aparece:

RTC is NOT running!
2165/165/165 165:165:85
 since midnight 1/1/1970 = 1399160785s = 16193d
 now + 7d + 30s: 2014/5/10 23:46:55

Será que é da bateria?
Quando coloco a antiga funciona corretamente...

Com os melhores comprimentos.
João Oliveira

Offline Hugu

  • Mini Robot
  • *
  • Mensagens: 5.602
  • Keyboard not found. Press any key to continue.
    • [url=www.g7electronica.net]G7 Electrónica.net[/url]
Re: Controlo de estufa.
« Responder #41 em: 26 de Fevereiro de 2012, 19:34 »
já agora partilha o codigo completo e correcto que ja fica pra outros users k keiram fazer algo do género..  8)

Offline jony-kid

  • Mini Robot
  • *
  • Mensagens: 54
Re: Controlo de estufa.
« Responder #42 em: 27 de Fevereiro de 2012, 00:03 »
Estou a tentar fazer um video com o telemovel mas o lcd é muito claro e não aparecem as letras.

Offline tops72

  • Mini Robot
  • *
  • Mensagens: 263
  • Robotica é uma Arte
    • MicroTops
Re: Controlo de estufa.
« Responder #43 em: 27 de Fevereiro de 2012, 13:05 »
Tente partilha o codigo tenho gente interessada e fazer uma coisa paracida!!
Nao há impossiveis, na Robotica
http://microtops.allalla.com/index.html
ToPs SaNtoS

Offline jony-kid

  • Mini Robot
  • *
  • Mensagens: 54
Re: Controlo de estufa.
« Responder #44 em: 27 de Fevereiro de 2012, 19:14 »
Então cá vai o codigo que estou a usar neste momento.
De lembrar que este codigo não foi feito por mim, visto os meus conhecimentos não serem os melhores.
Excertos retirados de varios sitios.

Código: [Seleccione]
// Projeto Arduino Primeiro por George Mentzikof.
// Arduino Monitor LCD temperatura ambiente.

// Mostra atuais, 8 seg Média, Max e Min temperatura.

// Para ligar o seu ecrã LED para o Arduino, conecte os pinos seguintes:
// LCD RS pino para pino digital 12
// LCD Habilitar pinos ao pino digital 11
// LCD D4 pinos ao pino digital 5
// LCD D5 pinos para o sistema digital 4
// LCD D6 pinos ao pino digital 3
// LCD D7 pinos ao pino digital 2
// Além disso, ligar um pote de 10K para +5 V e GND, com a sua limpeza (de saída) para ecrãs LCD VO pino (pin3).
// Usamos a placa da fonte de alimentação (5v e GND) para o poder. LM35 e pino analógico 0 (zero) para ler a saída analógica do sensor

// 17 janeiro de 2011

// Incluir o código da biblioteca:
#include <LiquidCrystal.h>  // Inclui a biblioteca para LCD
#include <Wire.h>           // Biblioteca para RTC 
#include "RTClib.h"

// Declarar variaveis

RTC_DS1307 RTC;
float tempC = 0;  // Variável para a realização de Celcius temp (flutuante de precisão decimal pontos)
float tempf = 0;  // Variável para a realização de Fareghneit temperatura
int tempPin = 0;  // Declarando a entrada analógica para ser 0 (A0) da placa Arduino.
float samples[8]; // Array para armazenar 8 amostras para o cálculo da temperatura média
float maxi = 0,mini = 100; // Max / min variáveis ??de temperatura, com valores iniciais. LM35 na configuração simples só mede acima de 0 Temp.
int i3;


// Inicializar a biblioteca com os números dos pinos da interface
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
Wire.begin(); // Iniciar Biblioteca para RTC   
RTC.begin();


Serial.begin(9600); //abre a porta serial, define a taxa de dados a 9600 bps
pinMode(13, OUTPUT);  // Led Branco

lcd.begin(20, 4); // Numero de linhas e colunas do LCD:

lcd.setCursor(0, 0); // Posição co corsor (linha e coluna)
lcd.print("Joao Oliveira"); // Escreve no LCD
lcd.setCursor(0, 1);
lcd.print("Arduino project");
delay(2000); // Espera 2 segundos
lcd.clear(); // clear LCD display
lcd.setCursor(0, 0);
lcd.print("LCD Ambient Temp");  //Escreve no LCD
lcd.setCursor(0, 1);
lcd.print("Monitor Digital ");  //escreve no LCD     
lcd.setCursor(0, 2);
lcd.print("Ver. 1.3");  //Escreve no LCD   
delay(2000);
lcd.clear();


}

void loop()
{
DateTime now = RTC.now();


 
digitalWrite(13, LOW);   // Liga Led branco
Serial.println(analogRead(tempPin)); // Mostra no monitor serial o valor amostrado antes da conversão para leitura da temperatura real,
// Começa os cálculos para circuito.
for(i3 = 0;i3<=7;i3++){ // obtém 8 amostras de temperatura
samples[i3] = ( 4.4 * analogRead(tempPin) * 100.0) / 1024.0; // matemática conversão do LM35 amostra à temperatura legível e armazena o resultado em array amostras. 1024 é a profundidade de bits (quantização) do Arduino.
// 5 is the supply volts of LM35. Change appropriatelly to have correct measurement. My case is 4.4Volts.
// Serial.println(samples[i3]);
Serial.print("."); // print a dot for every sample at serial monitor

// Display Current Celcius Temp to LCD
// ( LCD note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 0); // set LCD cursor position
lcd.print("Temp.atual: "); // Escreve no LCD
lcd.setCursor(12, 0);
lcd.print(samples[i3]);  //imprime Temperatura atual no LCD

lcd.setCursor(0, 3); // Posição do cursor



tempC = tempC + samples[i3]; // Calcula a temperatura média
delay(800); // Espera 800ms


     DateTime now = RTC.now();
 
    lcd.print(now.hour(), DEC);
    lcd.print(':');
    lcd.print(now.minute(), DEC);
    lcd.print(':');
    lcd.print(now.second(), DEC);
    lcd.print("  ");
    lcd.print(now.day(), DEC);
    lcd.print('/');
    lcd.print(now.month(), DEC);
    lcd.print('/');
    lcd.print(now.year(), DEC);
    lcd.print(' ');
} // END of FOR loop

Serial.println(""); // Like and CR at serial monitor
Serial.println("");
tempC = tempC/8.0; // calculated the averare of 8 samples in Celcius

tempf = (tempC * 9)/ 5 + 32; // converts to fahrenheit

if(tempC > maxi) {maxi = tempC;} // set max temperature
if(tempC < mini) {mini = tempC;} // set min temperature


// Send results to LCD.
lcd.setCursor(0, 0);
lcd.print("Av.T   Max    Min");

// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the measured temp average
lcd.print(tempC);
lcd.setCursor(6, 1);
// print the maximum temp
lcd.print(maxi);
lcd.setCursor(12, 1);
// print the minimum temp
lcd.print(mini);
digitalWrite(13, HIGH);    // set the LED off
delay(1000);   // Wait about 0.8 seconds to display the results to LCD screen befor starting the loop again
tempC = 0; // Set tempC to 0 so calculations can be done again



}