METEO Station - struggling with code. I need HELP

Hello guys.
First of all, sorry for my english. Its not my native language.
I would like to ask you for help with my code. I started using Arduino about a year ago, but due to my changing life situation I have very limited time now and i cant catch up where i finished.I started making Arduino Uno "Meteo station". Its combination of Arduino UNO, LCD display, 2 thermometers, RTC module.

My idea is to measure temperature inside and outside ( With aprox. 5M cables, voltage on the end is 4,7V), show temperature on display and show clock on display.

I wrote code and error codes bellow. With first version when i use only one thermometer it works good(i was using library adidax-dht11-b7fbbcd ). But when i tried to use library DHT_sensor_library, thats where problems started.

I would really apreciate some help. I want to finish this project and move with my life. I make a nice box, wiring is no problem, but code. I am not good at it. Please help :slight_smile:

Components:
Arduino UNO R3
LCD Display 1602 IIC
RTC DS1302
DHT 11 (inside temperature)
DHT 22 (outside temperature)
3pin detechable conector

CODE:


//LCD

#include <Wire.h> // Library for I2C communication
#include <LiquidCrystal_I2C.h> // Library for LCD

// Make custom characters:
byte Stupne[] = {
  B00111,
  B00101,
  B00111,
  B00000,
  B00000,
  B00000,
  B00000,
  B00000
};

//byte Kocka[] = {
//  B00010,
//  B00100,
//  B01000,
//  B10001,
//  B00000,
//  B00000,
//  B00000,
//  B00000
//};

//byte Kocka2[] = {
//  B00000,
//  B00000,
//  B00000,
//  B00000,
//  B00000,
//  B00000,
//  B00000,
//  B00000
//};

LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2);
//LCD END

//TEPLOMER
#include <DHT.h>
#define DHTTYPE DHT11
#define DHTPIN 10
dht11 DHT11(DHT11PIN, DHTTYPE);
//TEPLOMER END

//CLOCK START
#include <virtuabotixRTC.h> //Library used

//Wiring SCLK -> 9, I/O -> 10, CE -> 11
//Or CLK -> 9 , DAT -> 10, Reset -> 11

virtuabotixRTC myRTC(8, 6, 7); //If you change the wiring change the pins here also
//CLOCK END

void setup() {
  //Serial.begin(9600);
  // Initiate the LCD:
  lcd.init();
  lcd.backlight();
  // Create new characters:
  lcd.createChar(0, Stupne);
//  lcd.createChar(1, Kocka);
//  lcd.createChar(2, Kocka2);
 //super cool boot sequence 
  lcd.setCursor(5, 0); 
  lcd.print("BOOTING") ; 
  lcd.setCursor(0, 1);

    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(500);

  lcd.clear();

//CLOCK START


 // Set the current date, and time in the following format:
 // seconds, minutes, hours, day of the week, day of the month, month, year
myRTC.setDS1302Time( 00, 04, 16, 3, 30, 12, 2020); //Here you write your actual time/date as shown above 
 //but remember to "comment/remove" this function once you're done
 //The setup is done only one time and the module will continue counting it automatically
 //CLOCK END
}

void loop() 
{
  //DISPLAY PLUS TEPLOMER 
  myRTC.updateTime(); //nacitat cas z RTC

 int chk = DHT11.read(DHT11PIN); //TEPLOMER
 //trosku zlozitejsi kod aby sa na display ukazovali pekne aj nuly ked je napr. cas 02:11:09
        lcd.setCursor(4, 0); 
        if (myRTC.hours<=9){
          lcd.print("0");
          lcd.print(myRTC.hours) ;}
        else {
          lcd.print(myRTC.hours);}
       
        lcd.print(":") ;

        if (myRTC.minutes<=9){        
          lcd.print("0");
          lcd.print(myRTC.minutes) ;}
        else {
          lcd.print(myRTC.minutes) ;}
          
        lcd.print(":") ;
        
        if (myRTC.seconds<=9){        
          lcd.print("0");
          lcd.print(myRTC.seconds) ;}
        else {
          lcd.print(myRTC.seconds) ;}
          // koniec zlozitejsieho kodu  
            
//Teplota
          
       lcd.setCursor(0, 1); //Set the cursor xxx column and the xxx row (counting starts at 0!).

      if ((float)DHT11.temperature<0){        
        lcd.print("-");}

       else {
         lcd.print("+") ;}

        lcd.setCursor(1, 1);

       if ((float)DHT11.temperature<=9){        
         lcd.print("0");
          lcd.print((float)DHT11.temperature, 0) ;}
        else {
         lcd.print((float)DHT11.temperature, 0) ;}

         //Teplota koniec
        
        lcd.write(0);
        lcd.print("C");
        lcd.setCursor(14, 1); 
        lcd.print(":)");  //super cool smajlik na lepsie rano
        

//Vlhkost
       lcd.setCursor(8, 1); //Set the cursor xxx column and the xxx row (counting starts at 0!).
        lcd.print((float)DHT11.humidity, 0);
        lcd.print("%");
       delay(100);
//Vlhost koniec

}

ERROR:

kombinacia_s_klavesnicou_4x4_a_teplomerom:49:1: error: 'dht11' does not name a type
 dht11 DHT11(DHT11PIN, DHTTYPE);
 ^~~~~
C:\Users\Mathew\Desktop\kombinacia_s_klavesnicou_4x4_a_teplomerom\kombinacia_s_klavesnicou_4x4_a_teplomerom.ino: In function 'void loop()':
kombinacia_s_klavesnicou_4x4_a_teplomerom:126:18: error: request for member 'read' in '11', which is of non-class type 'int'
  int chk = DHT11.read(DHT11PIN); //TEPLOMER
                  ^~~~
kombinacia_s_klavesnicou_4x4_a_teplomerom:126:23: error: 'DHT11PIN' was not declared in this scope
  int chk = DHT11.read(DHT11PIN); //TEPLOMER
                       ^~~~~~~~
C:\Users\Mathew\Desktop\kombinacia_s_klavesnicou_4x4_a_teplomerom\kombinacia_s_klavesnicou_4x4_a_teplomerom.ino:126:23: note: suggested alternative: 'DHTPIN'
  int chk = DHT11.read(DHT11PIN); //TEPLOMER
                       ^~~~~~~~
                       DHTPIN
kombinacia_s_klavesnicou_4x4_a_teplomerom:156:24: error: request for member 'temperature' in '11', which is of non-class type 'int'
       if ((float)DHT11.temperature<0){
                        ^~~~~~~~~~~
kombinacia_s_klavesnicou_4x4_a_teplomerom:164:25: error: request for member 'temperature' in '11', which is of non-class type 'int'
        if ((float)DHT11.temperature<=9){
                         ^~~~~~~~~~~
kombinacia_s_klavesnicou_4x4_a_teplomerom:166:34: error: request for member 'temperature' in '11', which is of non-class type 'int'
           lcd.print((float)DHT11.temperature, 0) ;}
                                  ^~~~~~~~~~~
kombinacia_s_klavesnicou_4x4_a_teplomerom:168:33: error: request for member 'temperature' in '11', which is of non-class type 'int'
          lcd.print((float)DHT11.temperature, 0) ;}
                                 ^~~~~~~~~~~
kombinacia_s_klavesnicou_4x4_a_teplomerom:180:32: error: request for member 'humidity' in '11', which is of non-class type 'int'
         lcd.print((float)DHT11.humidity, 0);
                                ^~~~~~~~
exit status 1
'dht11' does not name a type

When, somehow , i manage to get rid of this error I will have error with libraries Iam using for thermometer.
I am using:
DHT_sensor_library

Take a look at the examples that come with your DHT library, they'll show you how to declare your sensor, but I'll guess you wanted something like this:

DHT dht(DHTPIN, DHTTYPE);

Then you'll have to fix all your other attempts to use the sensor to use dht instead.

Hello
Take a view here.

Thank you for your support. I read some Guides and come to this.
And its working.

//Z minuléj verzie som sa poučil že sa nedá len copy-paste kódy z celého internetu, pretože tie príkazy sú na tie konkrétne knižnice
//Príkazy z knižnice adidax-dht11-b7fbbcd neboli kompatibilné s knižnicou DHT_sensor_library ktorú teraz používam
//všetky príkazy if-else sú len preto, lebo nechcem refrešovať displej(bliká) a músím znaky prepisovať
//Znak "prázdné políčko" nemá aktuálne využitie, ale je tu. Pre prípad.
//Mathew 4.6.2021/20:31

  #include <LiquidCrystal_I2C.h>      //knižnica pre LCD desplej
  LiquidCrystal_I2C lcd(0x27,16,2);   // set the LCD address to 0x27 for a 16 chars and 2 line display

  byte Stupne[] = {                   //custom znak pre "stupen"
    B00111,
    B00101,
    B00111,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000
  };

  byte Prazdne[] = {                   //custom znak pre "prázdne políčko"
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000,
    B00000
  };

  #include "DHT.h"                    //v minuléj verzii som mal inú knižnicu a tým pádom mi nesedeli príkazy
  #define DHT11PIN 10                 //DHT11 je meno ktoré som určil sám
  #define DHT11TYPE DHT11             //typ teplomera s menom DHT11

  DHT dht11(DHT11PIN, DHT11TYPE);    //DHT typ zariadenia, dht11 meno ktoré som určil. takýmto štýlom si možem pridať viac zariadení s potom k nim pridelím iba korešpondujúce PINy a TYPy

  #define DHT22PIN 9
  #define DHT22TYPE DHT22

  DHT dht22(DHT22PIN, DHT22TYPE);

  #include <virtuabotixRTC.h>         //knižnica pre RTC hodniky


  virtuabotixRTC myRTC(8, 6, 7);      //CLK -> 8 , DAT -> 6, Reset -> 7  zapojenie hodiniek v tomto poradí, toto je vlastne to isté ako pri teplomeri.virtuabotixRTC je meno zariadenia, myRTC je mone ktoré som mu určil 
                                    //v zátvorke sú informácie ktoré potrebuje. V tomto prípade PINy zapojenia, takže kludne tu môže byť viacero hodiniek

void setup()
{

   
  //myRTC.setDS1302Time(30, 02, 19, 5, 4, 6, 2021); //nastavenie času na hodinkách, po nastavení je to treba OKOMENTOVAŤ 
                                    // seconds, minutes, hours, day of the week, day of the month, month, year 
  lcd.init();                       // initialize the lcd 
  lcd.backlight();

  dht11.begin();                    //spustenie teplomera s menom dht11
  dht22.begin();                    //spustenie teplomera s menom dht22

  lcd.createChar(0, Stupne);        //vytvorenie custom znaku s menom "0"
  lcd.createChar(1, Prazdne);       //vytvorenie custom znaku s menom "1"
                                    
  lcd.setCursor(5, 0);              //super-cool BOOT sequence
  lcd.print("BOOTING") ; 
  lcd.setCursor(0, 1);

    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(100);
    lcd.print("_");
  delay(500);

  lcd.clear();                    //vyčistenie displeja po BOOT sequencii

  

}


void loop()
{

  myRTC.updateTime();                 // This allows for the update of variables for time or accessing the individual elements.
                                      //trosku zlozitejsi kod aby sa na display ukazovali pekne aj nuly ked je napr. cas 02:11:09
  lcd.setCursor(0, 0);                //nastavenie kurzora na riadok 1, znak 1
  if (myRTC.hours<=9){                //ak sú hodiny menej alebo rovné 9 napíš nula
    lcd.print("0");
    lcd.print(myRTC.hours) ;}
  else {                              //ak sú hiny 10 a viac tak iba napíš hodiny
    lcd.print(myRTC.hours);} 
          
  lcd.print(":") ;

  if (myRTC.minutes<=9){            //zobrazenie minút, tak isto ako hodiny      
    lcd.print("0");
    lcd.print(myRTC.minutes) ;}
  else {
    lcd.print(myRTC.minutes) ;}
          
  lcd.print(":") ;
        
  if (myRTC.seconds<=9){            //zobrazenie sekúnd, tak isto ako hodiny 
    lcd.print("0");
    lcd.print(myRTC.seconds) ;}
  else {
    lcd.print(myRTC.seconds) ;}

  float t11 = dht11.readTemperature();//prečítanie teploty z teplomera dht11 a pomenoval som ju t11, toto meno možem používať pri zobrazovaní na daspleji
  float h11 = dht11.readHumidity();   //vlhkosť z teplomera dht11 s menom h11
  float t22 = dht22.readTemperature();
  float h22 = dht22.readHumidity();


  lcd.setCursor(10,0);               //nastavenie kurzora na riadok 1, znak 11
              
  if (t11<=9){                      //toto je to isté ako s hodinami
    lcd.print("0");
    lcd.print(t11,1) ;}               //zobrazenie teploty t11 z teplomera dht11, jednotka za čiarkou znamená jedno desatinne miesto
  else {
    lcd.print(t11,1) ;}               //zobrazenie teploty t11 z teplomera dht11
    lcd.write(0);                      //napísanie custom znaku pre stupeň
    lcd.print("C");
  
                                    //s teplomerom dht22 to bude trošku zložitejie, kedže ukazuje aj mínusové teploty
  if (t22>=10){                     //ked je teplota t22 vacsia alebo rovná 10 nastaviť kurzor na riadok 2,znak 11
    lcd.setCursor(10,1);
    lcd.print(t22,1) ;}
  
  else if (t22>=0){                //ked je teplota t22 vacsia alebo rovná 0 nastaviť kurzor na riadok 2,znak 11
    lcd.setCursor(10,1);
    lcd.print("0");                //najskorej napisať 0, aby bola teplota napr.: 09°C
    lcd.print(t22,1) ;}
    

  
  else if  (t22<0){               //ked je teplota t22 menšia než 0 nastaviť kurzor na riadok 2,znak 11 aby mohlo byť napísané mínus, napr,: -4.2°C
    lcd.setCursor(10,1);
    lcd.print(t22,1) ;}

  else if (t22<=-10){             //táto časť nefunguje, neviem ako interpretovať negatívne čísla, takže pri teplotách menších ako -9°C bude chýnať znak "C"
    lcd.setCursor(9,1);
    lcd.print(t22,1) ;}


  lcd.write(0);                      //napísanie custom znaku pre stupeň
  lcd.print("C");

  lcd.setCursor(3,1);               //Pekný smajlík na dobré ráno
  lcd.print(":)");

       
  delay(500);                       //čakanie 0,5 sekundy
}

Comments only in Slovakia, sorry :frowning:

1 Like

Working is good!

Main problem was with library and with declaring sensors (two of them). maybe this will help to some one. Instead of clearing displey(it is flickering a lot) i choose to rewrite symbols and some smart positioning. I wasnt able to handle negative temperature numbers in this scenario:

else if (t22<=-10){            
    lcd.setCursor(9,1);
    lcd.print(t22,1) ;}

and also i wasnt able to write temperature like this: -05.5°C but only like this: -5.5°C. Its a small detail but i wanted it. Its good enough for me. I learned a lot.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.