Lampeggio su display

Salve ragazzi è la prima domanda e spero che stia postando nella sezione giusta .

Non sono molto esperto di arduino e piano piano mi sto avvicinando alla realizzazione di un automazione per acquari ...dai basilari per poi ampliare in futuro quando acquisiro' piu' esperienza.

Ho montato un arduino mega 2560 settato un RTC visualizzando orario -data e giorno della settimana sul display e fin qui tutto bene ,ho inserito una sonda di temperatura per liquidi ed esattamente la DS18B20 provata separtamente con uno sketch specifico e tutto funzionava benissimo,al momento che ho inglobato i due sketch e cioe' quello dell'RTC e della sonda noto un leggero lampeggio solo sul valore di temp con frequenza di circa 1sec e cioe' il tempo di aggiornamento dell'RTC.Lampeggio molto evidente se vedo il display da un angolazione traversa mentre se lo vedo frontale e alzando il contrasto è quasi inpercettibile ma c'è.Il display che ho montato è un lcd 20x4.
Volevo chiedervi secondo voi è un problema di sketch o di qualche interferenza ???? Il tutto è montato sulla basetta millefori.
Non sapendo se devo inserire il codice per farvelo visionare intanto ringrazio anticipatamente

Il tuo problema mi ricorda qualcosa.... anche se improbabile che dipenda da questo io ci provo:
Se non ho capito male hai eseguito un merge tra lo sketch dell' rtc+display e lo sketch del ds18b20.
Se ad ogni aggiornamento leggi anche dal bus 1-wire del ds18b20 e scrivi la temperatura su una singola riga proverei ad assegnare il valore di temperatura ad una variabile temporanea e disabiliterei la lettura dal ds18b20. Se il problema non si presenta era dovuto al tempo di lettura del sensore.
P.S. Ho il ds18b20 in acquario dolce da qualche mese, per il momento tutto ok, non sembra aver rilasciato sostanze tossiche.

Ogni quanto stampi le informazioni sul display?
A me pare che sia un problema di refresh troppo elevato e quindi vedi sfarfallare l'immagine.

Aggiorna le info ogni 500/1000 ms e vedrai che risolvi.

il delay è impostato ha 1000 ho provato a variarlo ma se lo scendo l'oscillazione aumenta se lo salgo diminuisce come intensita' ma anche l'RTC aggiorna l'orario con la stessa cadenza......volete che inserisco lo sketch magari gli date un occhiata ?

Immagino che sulla prima riga del diaplay visualizzi l'ora e sulla seconda la temperatura.
Potrebbe essere un problema di Serial.println che va evitato se possibile, ma sarebbe meglio vedere lo sketch.

archimede70:
il delay è impostato ha 1000

Se metti lo sketch è meglio, perché non possiamo indovinare :wink:

eccolo

#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68

// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
  return ( (val/10*16) + (val%10) );
}

// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return ( (val/16*10) + (val%16) );
}

// Stops the DS1307, but it has the side effect of setting seconds to 0
// Probably only want to use this for testing
/*void stopDs1307()
{
  Wire.beginTransmission(DS1307_I2C_ADDRESS);
  Wire.write(0);
  Wire.write(0x80);
  Wire.endTransmission();
}*/

// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock
// Assumes you're passing in valid numbers
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.write(0);
   Wire.write(decToBcd(second));    // 0 to bit 7 starts the clock
   Wire.write(decToBcd(minute));
   Wire.write(decToBcd(hour));      // If you want 12 hour am/pm you need to set
                                   // bit 6 (also need to change readDateDs1307)
   Wire.write(decToBcd(dayOfWeek));
   Wire.write(decToBcd(dayOfMonth));
   Wire.write(decToBcd(month));
   Wire.write(decToBcd(year));
   Wire.endTransmission();
}

// Gets the date and time from the ds1307
void getDateDs1307(byte *second,
          byte *minute,
          byte *hour,
          byte *dayOfWeek,
          byte *dayOfMonth,
          byte *month,
          byte *year)
{
  // Reset the register pointer
  Wire.beginTransmission(DS1307_I2C_ADDRESS);
  Wire.write(0);
  Wire.endTransmission();
  
  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

  // A few of these need masks because certain bits are control bits
  *second     = bcdToDec(Wire.read() & 0x7f);
  *minute     = bcdToDec(Wire.read());
  *hour       = bcdToDec(Wire.read() & 0x3f);  // Need to change this if 12 hour am/pm
  *dayOfWeek  = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month      = bcdToDec(Wire.read());
  *year       = bcdToDec(Wire.read());
}

/*
  LiquidCrystal Library - Hello World
 
 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the 
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.
 
 This sketch prints "Hello World!" to the LCD
 and shows the time.
 
  The circuit:
 * 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
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 
 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe
 
 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

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

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

#include <OneWire.h>
#include <LiquidCrystal.h>
 
#define BUTTON A0
 
int DS18B20_Pin = 6;
 
OneWire ds(DS18B20_Pin);


void setup() 
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  Wire.begin();
  /*
  // Modificare i seguenti valori per impostare il vostro orologio ad ogni avvio del programma.
  // Probabilmente si desidera impostare solo l'orologio una volta e quindi rimuovere
  // la chiamata setDateDs1307 .
  second = 00;
  minute = 04;
  hour = 01;
  dayOfWeek = 5;
  dayOfMonth = 27;
  month = 6;
  year = 14;
  setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);// chiamata per settare l'orologio
 */ 
   Serial.begin(9600);
 
  lcd.begin(20, 4);
}


void loop()
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  lcd.begin(20, 4);  
  lcd.clear(); // clear LCD screen
  lcd.setCursor(6,1);
  lcd.print(" ");
  lcd.print(hour, DEC);
  lcd.print(":");

 if (minute<10)
{
  lcd.print("0");
}
  lcd.print(minute, DEC);
  lcd.print(":");
  if (second<10)
{
  lcd.print("0");
}
  lcd.print(second, DEC);
  lcd.setCursor(0,0);
  lcd.print(" ");
  switch(dayOfWeek){
  case 1:
  lcd.print("Lunedi");
  break;
  case 2:
  lcd.print("Martedi");
  break;
  case 3:
  lcd.print("Mercoledi");
  break;
  case 4:
  lcd.print("Giovedi");
  break;
  case 5:
  lcd.print("Venerdi");
  break;
  case 6:
  lcd.print("Sabato");
  break;
  case 7:
  lcd.print("Domenica");
  break;
}  
  lcd.print(" ");   
  lcd.print(dayOfMonth, DEC);  
  lcd.print("/");
    if (month<10)
{
  lcd.print("0");
}
  lcd.print(month, DEC);  
  lcd.print("/20");
  lcd.print(year, DEC); 
lcd.setCursor(5,2); 
lcd.print("archimede70");

float temperature = getTemp();
  Serial.println(temperature);
 
  lcd.setCursor(0,3);
  lcd.print("Temp.:");
  lcd.setCursor(7,3);
  lcd.print(temperature);
delay(1000);
}

float getTemp(){
  //returns the temperature from one DS18B20 in DEG Celsius
 
  byte data[12];
  byte addr[8];
 
  if ( !ds.search(addr)) {
      //no more sensors on chain, reset search
      ds.reset_search();
      return -1000;
  }
 
  if ( OneWire::crc8( addr, 7) != addr[7]) {
      Serial.println("CRC is not valid!");
      return -1000;
  }
 
  if ( addr[0] != 0x10 && addr[0] != 0x28) {
      Serial.print("Device is not recognized");
      return -1000;
  }
 
  ds.reset();
  ds.select(addr);
  ds.write(0x44,1); // start conversion, with parasite power on at the end
 
  byte present = ds.reset();
  ds.select(addr);   
  ds.write(0xBE); // Read Scratchpad
 
  for (int i = 0; i < 9; i++) { // we need 9 bytes
    data[i] = ds.read();
  }
 
  ds.reset_search();
 
  byte MSB = data[1];
  byte LSB = data[0];
 
  float tempRead = ((MSB << 8) | LSB); //using two's compliment
  float TemperatureSum = tempRead / 16;
 
  return TemperatureSum;

}

Edit: il codice va incluso usando gli appositi tag.

Il listato è un po' pasticciato e mi sono permesso di mettrelo un po' a posto.
Formalmente è corretto, ma non ho avuto la possibilità di testarlo.
Nota che ora hai guadagnato una riga in più sul display.

#include "Wire.h"
#include <LiquidCrystal.h>
#include <OneWire.h>
#include <LiquidCrystal.h>

#define DS1307_I2C_ADDRESS 0x68
#define BUTTON A0

int DS18B20_Pin = 6;
float temperature = 0.0;
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
OneWire ds(DS18B20_Pin);

void setup() {
  Wire.begin();
  Serial.begin(9600);
  lcd.begin(20, 4);

  // Modificare i seguenti valori per impostare il vostro orologio ad ogni avvio del programma.
  // Probabilmente si desidera impostare solo l'orologio una volta e quindi rimuovere
  // la chiamata setDateDs1307 .
  //   second = 00;
  //   minute = 04;
  //   hour = 01;
  //   dayOfWeek = 5;
  //   dayOfMonth = 27;
  //   month = 6;
  //   year = 14;
  //   setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);// chiamata per settare l'orologio
}

void loop() {

  temperature = getTemp();
  getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);

  lcd.clear(); // clear LCD screen

  lcd.setCursor(5,0); // prima riga
  lcd.print("archimede70");

  lcd.setCursor(0,1); // seconda riga ---> www DD/MM/YYYY hh.mm
  switch(dayOfWeek){
  case 1:
    lcd.print("Lun");
    break;
  case 2:
    lcd.print("Mar");
    break;
  case 3:
    lcd.print("Mer");
    break;
  case 4:
    lcd.print("Gio");
    break;
  case 5:
    lcd.print("Ven");
    break;
  case 6:
    lcd.print("Sab");
    break;
  case 7:
    lcd.print("Dom");
    break;
  }  
  lcd.print(" ");
  lcd.print(dayOfMonth, DEC);  
  lcd.print("/");
  if (month < 10) lcd.print("0");
  lcd.print(month, DEC);  
  lcd.print("/20");
  lcd.print(year, DEC); 
  lcd.print(" ");
  lcd.print(hour, DEC);
  lcd.print(".");
  if (minute < 10) lcd.print("0");
  lcd.print(minute, DEC);
  lcd.print(".");
  if (second < 10) lcd.print("0");
  lcd.print(second, DEC);

  lcd.setCursor(0,3);  // quarta riga
  lcd.print("Temp.: ");
  lcd.print(temperature);

  Serial.println(temperature);

  delay(1000);
}

float getTemp() {   //returns the temperature from one DS18B20 in DEG Celsius

  byte data[12];
  byte addr[8];

  if (!ds.search(addr)) {
    //no more sensors on chain, reset search
    ds.reset_search();
    return -1000;
  }

  if (OneWire::crc8(addr, 7) != addr[7]) {
    Serial.println("CRC is not valid!");
    return -1000;
  }

  if (addr[0] != 0x10 && addr[0] != 0x28) {
    Serial.print("Device is not recognized");
    return -1000;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44,1); // start conversion, with parasite power on at the end

  byte present = ds.reset();
  ds.select(addr);   
  ds.write(0xBE); // Read Scratchpad

  for (int i = 0; i < 9; i++) { // we need 9 bytes
    data[i] = ds.read();
  }

  ds.reset_search();

  byte MSB = data[1];
  byte LSB = data[0];

  float tempRead = ((MSB << 8) | LSB); //using two's compliment
  float TemperatureSum = tempRead / 16;

  return TemperatureSum;
}


byte decToBcd(byte val) {   // Convert normal decimal numbers to binary coded decimal
  return ((val/10*16) + (val%10));
}


byte bcdToDec(byte val) {   // Convert binary coded decimal to normal decimal numbers
  return ((val/16*10) + (val%16));
}

// Stops the DS1307, but it has the side effect of setting seconds to 0
// Probably only want to use this for testing
void stopDs1307() {
  Wire.beginTransmission(DS1307_I2C_ADDRESS);
  Wire.write(0);
  Wire.write(0x80);
  Wire.endTransmission();
}

// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock
// Assumes you're passing in valid numbers
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.write(0);
  Wire.write(decToBcd(second));    // 0 to bit 7 starts the clock
  Wire.write(decToBcd(minute));
  Wire.write(decToBcd(hour));      // If you want 12 hour am/pm you need to set
  // bit 6 (also need to change readDateDs1307)
  Wire.write(decToBcd(dayOfWeek));
  Wire.write(decToBcd(dayOfMonth));
  Wire.write(decToBcd(month));
  Wire.write(decToBcd(year));
  Wire.endTransmission();
}

// Gets the date and time from the ds1307
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
  // Reset the register pointer
  Wire.beginTransmission(DS1307_I2C_ADDRESS);
  Wire.write(0);
  Wire.endTransmission();

  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

  // A few of these need masks because certain bits are control bits
  *second     = bcdToDec(Wire.read() & 0x7f);
  *minute     = bcdToDec(Wire.read());
  *hour       = bcdToDec(Wire.read() & 0x3f);  // Need to change this if 12 hour am/pm
  *dayOfWeek  = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month      = bcdToDec(Wire.read());
  *year       = bcdToDec(Wire.read());
}

grazie mille cyberhs
hai fatto benissimo e uno splendido lavoro
L'ho subito provato e ho visto che effettivamente il lampeggio è sparito guardandolo frontalmente se invece lo si guarda di traverso lo si intravede molto poco .......ma sono contento del risultato ottenuto.

Grazie mille dell'aiuto celere e molto esaustivo adesso attendo che mi arrivi il modulo rele' e la sonda ph per continuare altre implementazioni sperando che vada tutto bene .........grazie ancora a tutti.