OpenSprinkler Forums Hardware Questions DIY Kit Assembly Questions Arduino LCD displays weird character after a while

  • This topic has 1 reply, 2 voices, and was last updated 8 years ago by Ray.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #44570

    Chuoi
    Participant

    Hello,I having some issues with an LCD.

    I have made a climatic control system that controls some relays (output) and receives some input from water pipe sensor and ambient temperature/humidity. This was done using 2 PT100 (manually calibrate) and 1 DHT11.

    All the data is displayed on a 16×2 LCD that works fine, but after a while (I can’t say after a specific event) starts to print weird strings. When I power off and than on the LCD works fine, this thing suggest me that probably is not a matter of bad soldering of LCD pins.

    The system is working and I can see it from serial communication, so seems only a problem of LCD.

    ALIMENTATION: The LCD alimentation comes from 5V arduino and which is powered by a 12v power source. The 5v power source is connected also to a DHT11 and two PT100 in series with 1k resistors like this http://www.kynix.com/Detail/75/RL7520WS-R10-F.html so the current absorption should be not much (0,01A for both pt100, plus Dht11). I didn’t connected any condenser in parallel to 5V arduino power source, maybe I should put one.

    I will appreciate any suggestion.

    Explanation of code:

    dewpoint function: calculus of dewpoint
    temp_acqua_mand: calculus of PT100 voltage divisor water to terminals
    temp_acqua_rito: calculus of PT100 voltage divisor water back from terminals
    trevie: object that controls output 1-5V for a three ways valve
    AvviamentoImpianto: function that starts freezing or warming machines and pumps
    ArrestoImpianto: power off freezing/warming machines and pumps
    Thanks

    double dewPoint(double celsius, double humidity)
    {
    double A0= 373.15/(273.15 + celsius);
    double SUM = -7.90298 * (A0-1);
    SUM += 5.02808 * log10(A0);
    SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;
    SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;
    SUM += log10(1013.246);
    double VP = pow(10, SUM-3) * humidity;
    double T = log(VP/0.61078); // temp var
    return (241.88 * T) / (17.558-T);
    }

    double temp_acqua_mand(int pinInput)
    {
    Serial.print(“Temp Mandata PIN “);
    float letturaPin=analogRead(pinInput);
    Serial.println(letturaPin);
    return (float)(-0.2083*(19.06-letturaPin));
    }
    double temp_acqua_rito(int pinInput)
    {
    Serial.print(“Temp Ritorno PIN “);
    float letturaPin=analogRead(pinInput);
    Serial.println(letturaPin);
    return (float)(-1.258*(92.7-letturaPin));
    }

    class val_Trevie
    {
    private:
    int pinOut;
    int apertura; //0 = Chiuso(completo ricircolo)
    //100= Aperto (Nessun ricircolo)
    public:
    val_Trevie(int pin) //COSTRUTTORE
    {
    pinOut=pin;
    }
    //~val_Trevie(); //DISTRUTTORE
    int read()
    {
    return apertura;
    }
    void set(int percentuale) //SET
    {
    apertura=percentuale;
    analogWrite(pinOut, map(apertura,0,100,50,255)); //OUT 1-5V
    Serial.print(“Settaggio Trevie al “);Serial.println(apertura);
    }
    void aumenta()
    {
    if (apertura>=90)
    this->set(100);
    else
    {
    apertura+=10;
    this->set(apertura);
    }
    }
    void diminuisci()
    {
    if (apertura<=30)
    this->set(30);
    else
    {
    apertura-=10;
    this->set(apertura);
    }
    }

    };

    #include <dht11.h>
    #include <LiquidCrystal.h>

    #define DHTLIB_OK 0
    #define DHTLIB_ERROR_CHECKSUM -1
    #define DHTLIB_ERROR_TIMEOUT -2

    //Assegnazione PIN 0-13

    #define RELE_PdC 7
    #define RELE_Pompe 8
    #define RELE_Pompa_Inverno 9
    #define TREVIE 10
    #define DHT11PIN A5

    #define LCD_RS 12
    #define LCD_E 11
    #define LCD_D4 6
    #define LCD_D5 5
    #define LCD_D6 4
    #define LCD_D7 2

    //Assegnazione PIN A0-A5
    #define Temp_Mandata A1
    #define Temp_Ritorno A0
    #define Chiamata_acqua A2
    #define Estate_Inverno A4

    //SENSORE DHT11
    dht11 DHT11;
    //LCD
    LiquidCrystal lcd(LCD_RS,LCD_E,LCD_D4,LCD_D5,LCD_D6,LCD_D7);
    //TREVIE
    val_Trevie trevie(TREVIE);
    //DEFINIZIONI COSTANTI
    #define ESTATE 1 //SUMMER
    #define INVERNO 0 //WINTER
    #define SET_POINT 35

    //DEFINIZIONE VARIABILI
    double inFunzione=0;
    boolean stagione; //SEASON

    void AvviamentoImpianto()
    {
    trevie.set(50); //Apertura Valvola 3 vie

    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(“Start Circuiti”);
    lcd.setCursor(0,1);

    delay(10000);

    boolean stagione=analogRead(Estate_Inverno)>500;

    if (stagione) //ESTATE
    {digitalWrite(RELE_PdC,HIGH); Serial.println(“Avviamento Pompa Circuito Estivo”);
    lcd.print(“Prim EST”);}
    else //INVERNO
    {digitalWrite(RELE_Pompa_Inverno,HIGH);Serial.println(“Avviamento Pompa Circuito Invernale”);
    lcd.print(“Prim INV”);}
    delay(4000);

    digitalWrite(RELE_Pompe,HIGH);Serial.println(“Avviamento Pompa Circuito Secondario”);
    lcd.print(” Second”);

    delay(10000);
    inFunzione++;
    }

    void ArrestoImpianto()
    {
    digitalWrite(RELE_PdC,LOW);
    digitalWrite(RELE_Pompa_Inverno,LOW);
    digitalWrite(RELE_Pompe,LOW);
    Serial.println(“Spegnimento Impianto”);
    inFunzione=0;

    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(“Spegnimento”);
    delay (10000);
    }

    void setup()
    {
    delay (5000);
    Serial.begin(9600);
    Serial.println(“CLIMADUINO START “);
    Serial.println();
    //INIZIALIZZAZIONE USCITE
    pinMode (RELE_PdC,OUTPUT);
    pinMode (RELE_Pompe,OUTPUT);
    pinMode (RELE_Pompa_Inverno,OUTPUT);
    //INIZIALIZZAZIONE ENTRATE
    //INIZIALIZZAZIONE LCD
    lcd.begin(16,2);
    lcd.print(“CLIMADUINO”);
    //ANALISI STAGIONE ESTATE/INVERNO
    boolean stagione=analogRead(Estate_Inverno)>500;
    lcd.setCursor(0,1);
    if (stagione)
    lcd.print(“ESTATE”);
    else
    lcd.print (“INVERNO”);
    delay (5000);
    }

    void loop()
    {
    //LETTURA VALORI SENSORI

    float t_mandata= temp_acqua_mand(Temp_Mandata); //TEMPERATURA DI MANDATA

    float t_ritorno= temp_acqua_rito(Temp_Ritorno); //TEMPERATURA DI RITORNO
    // String str_out= String(“Temp Mand “)+String(t_mandata,2);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(“Tm “); lcd.print(String(t_mandata,1));
    lcd.print(” Tr “); lcd.print(String(t_ritorno,1));
    lcd.setCursor(0,1);
    lcd.print(“Trevie “);lcd.print(trevie.read());

    delay(6000);

    float t_ambiente,h_ambiente,t_rugiada;

    if (DHT11.read(DHT11PIN)==DHTLIB_OK)
    {
    t_ambiente=(float) DHT11.temperature+3;
    h_ambiente=(float) DHT11.humidity;
    Serial.println(“Umidita’ %”); Serial.println(h_ambiente,DEC);
    t_rugiada=dewPoint(t_ambiente, DHT11.humidity);
    Serial.println(“Acquisizione Temperatura e Umidità Ambiente”);
    Serial.println(t_ambiente);

    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(“T Amb “); lcd.print(String(t_ambiente,1));
    lcd.setCursor(0,1);
    lcd.print(“H% “); lcd.print(String(h_ambiente,0));lcd.print(” Trug “);lcd.print(String(t_rugiada,0));
    }
    else
    {
    t_rugiada=15.0;
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(“T amb ERRORE”);
    }

    //CONTROLLO CHIAMATA ACQUA

    boolean chiamata_Acqua = analogRead(Chiamata_acqua)<500;
    Serial.println(analogRead(Chiamata_acqua));
    if (chiamata_Acqua)
    {
    Serial.println(“Richiesta acqua”);
    if (inFunzione==0) AvviamentoImpianto(); //SE L’IMPIANTO E’ SPENTO LO AVVIA
    }
    else {
    if (inFunzione==1) ArrestoImpianto(); //SE L’IMPIANTO E’ ACCESO LO SPEGNE
    }

    //ALGORITMO DI DECISIONE
    if (inFunzione==1)
    {
    //delta = DIFFERENZA DI TEMPERATURA AL SET POINT
    float delta=0;

    if (stagione==INVERNO)
    {
    delta=SET_POINT-5-t_mandata;
    }
    else
    {
    delta=t_mandata-(t_rugiada+2);
    }

    if (delta < -5)
    {
    trevie.diminuisci();
    trevie.diminuisci();
    }
    else if (delta < 0)
    {
    trevie.diminuisci();
    }
    else if (delta > 5)
    {
    trevie.aumenta();
    }
    }
    delay(6000);
    }

    #44639

    Ray
    Keymaster

    Hi, I will need to know which type of LCD you have on your OpenSprinkler. The older versions (from 1.x to 2.2) use LCD1602 with 16 pins and direct IO access. The more recently OpenSprinkler 2.3 uses I2C type with 4 pins (same LCD1602 but with a circuit board at the back to provide I2C interface).

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

OpenSprinkler Forums Hardware Questions DIY Kit Assembly Questions Arduino LCD displays weird character after a while