Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Error unknown typ name 'DS18B20'
Forum Updated to NodeBB v4.3 + New Features

Error unknown typ name 'DS18B20'

Scheduled Pinned Locked Moved Solved Mobile and Embedded
93 Posts 4 Posters 33.1k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A AlexKrammer
    11 Jul 2020, 12:08

    @mrjj ou i just saw. it looks like that one right?
    "are you using the DS18B20::DS18B20(const char* address) version"

    M Offline
    M Offline
    mrjj
    Lifetime Qt Champion
    wrote on 11 Jul 2020, 16:09 last edited by
    #41

    @AlexKrammer
    Heh yes but on this is says it should work with PI
    and it has more includes.
    So maybe this will actually work once we find out what that address should be :)

    A 1 Reply Last reply 13 Jul 2020, 10:43
    0
    • M mrjj
      11 Jul 2020, 16:09

      @AlexKrammer
      Heh yes but on this is says it should work with PI
      and it has more includes.
      So maybe this will actually work once we find out what that address should be :)

      A Offline
      A Offline
      AlexKrammer
      wrote on 13 Jul 2020, 10:43 last edited by
      #42

      @mrjj
      Now i tried to evaluate the temperatur with the c++ library.
      The code looks good. There is no error, but if i run the projekt. its going to do this step

      char w1_address [ 16 ];
      DS18B20 w1Device1 (w1_address);
      tempNow = w1Device1. getTemp ();
      

      its going to crash. So i think there is a mistake in the adress.
      i put in the raspberry pin.

      M 1 Reply Last reply 13 Jul 2020, 12:00
      0
      • A AlexKrammer
        13 Jul 2020, 10:43

        @mrjj
        Now i tried to evaluate the temperatur with the c++ library.
        The code looks good. There is no error, but if i run the projekt. its going to do this step

        char w1_address [ 16 ];
        DS18B20 w1Device1 (w1_address);
        tempNow = w1Device1. getTemp ();
        

        its going to crash. So i think there is a mistake in the adress.
        i put in the raspberry pin.

        M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 13 Jul 2020, 12:00 last edited by
        #43

        @AlexKrammer
        im not sure a pin is right there.
        Try read some the many tuts and see what they use for adress.

        A 1 Reply Last reply 14 Jul 2020, 10:04
        0
        • M mrjj
          13 Jul 2020, 12:00

          @AlexKrammer
          im not sure a pin is right there.
          Try read some the many tuts and see what they use for adress.

          A Offline
          A Offline
          AlexKrammer
          wrote on 14 Jul 2020, 10:04 last edited by AlexKrammer
          #44

          @mrjj
          Now it works.
          i reached the slave-address each sensor, made a code like this

          char w1_address[16];
          const char* adr1  = "10-000803673bfb";
          DS18B20 w1Device1 (adr1);
          actualTemp1 = w1Device1.getTemp();
          

          And it's working.
          But unfortunately if i add a new sensor. i have to find out his address and add it to the code. its not only plug and play^^

          But now a basic c++ problem.
          I created a class:
          checktemperature.h

          #ifndef CHECKTEMPERATURE_H
          #define CHECKTEMPERATURE_H
          
          #include <settemperature.h>
          #include <readtemperature.h>
          #include <wiringPi.h>
          
          class CheckTemperature
          {
          private:
              SetTemperature S;
              ReadTemperature R;
          public:
              void CheckTemp();
              float TempEin;
              float TempAus;
          };
          
          #endif // CHECKTEMPERATURE_H
          
          

          checktemperature.cpp

          #include "checktemperature.h"
          
          void CheckTemperature::CheckTemp()
          {
              TempEin = S.getHystTemperature();
              TempAus = S.getHystTemperature();
          
              if (R.actualTemp1 <= TempEin) digitalWrite(31, LOW);
              else if (R.actualTemp1 >= TempAus) digitalWrite(31, HIGH);
          
              if (R.actualTemp2 <= TempEin) digitalWrite(26, LOW);
              else if (R.actualTemp2 >= TempAus) digitalWrite(26, HIGH);
          
              if (R.actualTemp3 <= TempEin) digitalWrite(27, LOW);
              else if (R.actualTemp3 >= TempAus) digitalWrite(27, HIGH);
          
              if (R.actualTemp4 <= TempEin) digitalWrite(28, LOW);
              else if (R.actualTemp4 >= TempAus) digitalWrite(28, HIGH);
          
              if (R.actualTemp5 <= TempEin) digitalWrite(29, LOW);
              else if (R.actualTemp5 >= TempAus) digitalWrite(29, HIGH);
          }
          
          

          i call that funktion every 500ms in loop.
          But the values of R.actualTemp and S.getHystTemperature the value does not adjust, so they still at the moment when i start the program.
          Do you know whats wrong, cause i call that funktion every 500ms and at the beginning "TempEin= ..." and S.getHystTemperature(); is already changing^

          M 1 Reply Last reply 14 Jul 2020, 10:22
          0
          • A AlexKrammer
            14 Jul 2020, 10:04

            @mrjj
            Now it works.
            i reached the slave-address each sensor, made a code like this

            char w1_address[16];
            const char* adr1  = "10-000803673bfb";
            DS18B20 w1Device1 (adr1);
            actualTemp1 = w1Device1.getTemp();
            

            And it's working.
            But unfortunately if i add a new sensor. i have to find out his address and add it to the code. its not only plug and play^^

            But now a basic c++ problem.
            I created a class:
            checktemperature.h

            #ifndef CHECKTEMPERATURE_H
            #define CHECKTEMPERATURE_H
            
            #include <settemperature.h>
            #include <readtemperature.h>
            #include <wiringPi.h>
            
            class CheckTemperature
            {
            private:
                SetTemperature S;
                ReadTemperature R;
            public:
                void CheckTemp();
                float TempEin;
                float TempAus;
            };
            
            #endif // CHECKTEMPERATURE_H
            
            

            checktemperature.cpp

            #include "checktemperature.h"
            
            void CheckTemperature::CheckTemp()
            {
                TempEin = S.getHystTemperature();
                TempAus = S.getHystTemperature();
            
                if (R.actualTemp1 <= TempEin) digitalWrite(31, LOW);
                else if (R.actualTemp1 >= TempAus) digitalWrite(31, HIGH);
            
                if (R.actualTemp2 <= TempEin) digitalWrite(26, LOW);
                else if (R.actualTemp2 >= TempAus) digitalWrite(26, HIGH);
            
                if (R.actualTemp3 <= TempEin) digitalWrite(27, LOW);
                else if (R.actualTemp3 >= TempAus) digitalWrite(27, HIGH);
            
                if (R.actualTemp4 <= TempEin) digitalWrite(28, LOW);
                else if (R.actualTemp4 >= TempAus) digitalWrite(28, HIGH);
            
                if (R.actualTemp5 <= TempEin) digitalWrite(29, LOW);
                else if (R.actualTemp5 >= TempAus) digitalWrite(29, HIGH);
            }
            
            

            i call that funktion every 500ms in loop.
            But the values of R.actualTemp and S.getHystTemperature the value does not adjust, so they still at the moment when i start the program.
            Do you know whats wrong, cause i call that funktion every 500ms and at the beginning "TempEin= ..." and S.getHystTemperature(); is already changing^

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 14 Jul 2020, 10:22 last edited by
            #45

            @AlexKrammer
            Hi
            So it works fine the first time you run ?
            Have you checked with debugger what happens when you read and set
            R.actualTemp1 ?

            Its hard to guess from this code.

            A 1 Reply Last reply 14 Jul 2020, 10:29
            0
            • M mrjj
              14 Jul 2020, 10:22

              @AlexKrammer
              Hi
              So it works fine the first time you run ?
              Have you checked with debugger what happens when you read and set
              R.actualTemp1 ?

              Its hard to guess from this code.

              A Offline
              A Offline
              AlexKrammer
              wrote on 14 Jul 2020, 10:29 last edited by AlexKrammer
              #46

              @mrjj
              yes it works. its still working. Thats a other problem.
              So R.actualTemp is the temperature from the sensor.
              if i show the R.actualTemp is changing his value.
              So if i show S.getHystTemperature(); its changing the value too.

              But if i show e.g. TempEin its not changing the Value its always the value as i run the program.

              A other example. If i put R,actualTemp into a variable in this class and im going to show the variable. its dont change the value too. If i show R.actualTemp its changing.

              Are you understanding my problem?

              M 1 Reply Last reply 14 Jul 2020, 10:41
              0
              • A AlexKrammer
                14 Jul 2020, 10:29

                @mrjj
                yes it works. its still working. Thats a other problem.
                So R.actualTemp is the temperature from the sensor.
                if i show the R.actualTemp is changing his value.
                So if i show S.getHystTemperature(); its changing the value too.

                But if i show e.g. TempEin its not changing the Value its always the value as i run the program.

                A other example. If i put R,actualTemp into a variable in this class and im going to show the variable. its dont change the value too. If i show R.actualTemp its changing.

                Are you understanding my problem?

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 14 Jul 2020, 10:41 last edited by
                #47

                @AlexKrammer
                Hi
                Your naming confuses me a bit. :)
                So S.getHystTemperature(); changes but
                TempEin = S.getHystTemperature(); dont ?

                A 1 Reply Last reply 14 Jul 2020, 10:58
                0
                • M mrjj
                  14 Jul 2020, 10:41

                  @AlexKrammer
                  Hi
                  Your naming confuses me a bit. :)
                  So S.getHystTemperature(); changes but
                  TempEin = S.getHystTemperature(); dont ?

                  A Offline
                  A Offline
                  AlexKrammer
                  wrote on 14 Jul 2020, 10:58 last edited by
                  #48

                  @mrjj
                  Ohhh im sry TempEin means TempOn, TempAus means TempOff:)
                  I like to show you my completely code but i dont know how:P

                  yes if i try to: qDebug() << S.getHystTemperature(); in mainwindow.cpp
                  the value is changing in relation when im moving the horizontal slider.
                  The same with R.actualTemp.
                  But if i try to: qDebug() << S.getHystTemperature(); in checktemperature.cpp
                  its taking the value of the veriable when i run the program. e.g. i declared in setTemperature.h "float HystTemperature;" So its got value 0;
                  So qDebug() just show 0.

                  In conclusion it can be said that in class CheckTemperature the variable and values do not adapt to the current values. They stuck on the values when the program start to run.

                  M 1 Reply Last reply 14 Jul 2020, 11:02
                  0
                  • A AlexKrammer
                    14 Jul 2020, 10:58

                    @mrjj
                    Ohhh im sry TempEin means TempOn, TempAus means TempOff:)
                    I like to show you my completely code but i dont know how:P

                    yes if i try to: qDebug() << S.getHystTemperature(); in mainwindow.cpp
                    the value is changing in relation when im moving the horizontal slider.
                    The same with R.actualTemp.
                    But if i try to: qDebug() << S.getHystTemperature(); in checktemperature.cpp
                    its taking the value of the veriable when i run the program. e.g. i declared in setTemperature.h "float HystTemperature;" So its got value 0;
                    So qDebug() just show 0.

                    In conclusion it can be said that in class CheckTemperature the variable and values do not adapt to the current values. They stuck on the values when the program start to run.

                    M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 14 Jul 2020, 11:02 last edited by
                    #49

                    @AlexKrammer
                    And you only have one instance of the CheckTemperature class?
                    since S.getHystTemperature(); in mainwindow.cpp Works
                    it should also in CheckTemperature so i wonder if you have 2 of them or something like that ?

                    A 1 Reply Last reply 14 Jul 2020, 11:24
                    0
                    • M mrjj
                      14 Jul 2020, 11:02

                      @AlexKrammer
                      And you only have one instance of the CheckTemperature class?
                      since S.getHystTemperature(); in mainwindow.cpp Works
                      it should also in CheckTemperature so i wonder if you have 2 of them or something like that ?

                      A Offline
                      A Offline
                      AlexKrammer
                      wrote on 14 Jul 2020, 11:24 last edited by AlexKrammer
                      #50

                      @mrjj
                      no i only have one instance.
                      i only have one checktemp in class CheckTemperature, one gethysttemperature() in class SetTemperature, and one actualTemp in class ReadTemperature.
                      thats why im wondering too.
                      cause im calling checktemp() every 500ms in loop mainwindow.

                      Is there any possibility that i can't call object in a method of a single class. But there is no sense

                      M 1 Reply Last reply 14 Jul 2020, 11:28
                      0
                      • A AlexKrammer
                        14 Jul 2020, 11:24

                        @mrjj
                        no i only have one instance.
                        i only have one checktemp in class CheckTemperature, one gethysttemperature() in class SetTemperature, and one actualTemp in class ReadTemperature.
                        thats why im wondering too.
                        cause im calling checktemp() every 500ms in loop mainwindow.

                        Is there any possibility that i can't call object in a method of a single class. But there is no sense

                        M Offline
                        M Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on 14 Jul 2020, 11:28 last edited by
                        #51

                        @AlexKrammer
                        That is very odd then.
                        The 500ms loop is a QTimer?

                        Sorry I cant guess what could be wrong. It sounds like the parts are working but
                        not in all use cases.

                        A 1 Reply Last reply 14 Jul 2020, 11:31
                        0
                        • M mrjj
                          14 Jul 2020, 11:28

                          @AlexKrammer
                          That is very odd then.
                          The 500ms loop is a QTimer?

                          Sorry I cant guess what could be wrong. It sounds like the parts are working but
                          not in all use cases.

                          A Offline
                          A Offline
                          AlexKrammer
                          wrote on 14 Jul 2020, 11:31 last edited by
                          #52

                          @mrjj yes for sure. other thing in the loop are working. e.g. if i call directly in the loop every 500ms "ui->temperature4lable->setText(QString::number(S.getHystTemperature()));"
                          the value changes every 500ms if i change the horizontal slider.

                          M 1 Reply Last reply 14 Jul 2020, 11:33
                          0
                          • A AlexKrammer
                            14 Jul 2020, 11:31

                            @mrjj yes for sure. other thing in the loop are working. e.g. if i call directly in the loop every 500ms "ui->temperature4lable->setText(QString::number(S.getHystTemperature()));"
                            the value changes every 500ms if i change the horizontal slider.

                            M Offline
                            M Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on 14 Jul 2020, 11:33 last edited by
                            #53

                            Hi
                            Ok but that
                            S.getHystTemperature()
                            seems out side of the CheckTemperature class, correct ?

                            so you have
                            SetTemperature S;
                            ReadTemperature R;

                            in mainwindow too ? and those works but
                            inside the CheckTemperature they are not ?

                            A 1 Reply Last reply 14 Jul 2020, 11:37
                            0
                            • M mrjj
                              14 Jul 2020, 11:33

                              Hi
                              Ok but that
                              S.getHystTemperature()
                              seems out side of the CheckTemperature class, correct ?

                              so you have
                              SetTemperature S;
                              ReadTemperature R;

                              in mainwindow too ? and those works but
                              inside the CheckTemperature they are not ?

                              A Offline
                              A Offline
                              AlexKrammer
                              wrote on 14 Jul 2020, 11:37 last edited by
                              #54

                              @mrjj yes. right.
                              but i have:
                              SetTemperature S;
                              ReadTemperature R;

                              in CheckTemperature too

                              M 1 Reply Last reply 14 Jul 2020, 11:42
                              0
                              • A AlexKrammer
                                14 Jul 2020, 11:37

                                @mrjj yes. right.
                                but i have:
                                SetTemperature S;
                                ReadTemperature R;

                                in CheckTemperature too

                                M Offline
                                M Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on 14 Jul 2020, 11:42 last edited by
                                #55

                                @AlexKrammer
                                and that's the part that really bugs me as if those classes work alone in MainWindow, i cannot see a reason they should not work in that other class just the same ??

                                void CheckTemperature::CheckTemp()
                                could just have well been

                                void MainWindow::CheckTemp()

                                and the difference is really small.

                                A 1 Reply Last reply 14 Jul 2020, 11:56
                                0
                                • M mrjj
                                  14 Jul 2020, 11:42

                                  @AlexKrammer
                                  and that's the part that really bugs me as if those classes work alone in MainWindow, i cannot see a reason they should not work in that other class just the same ??

                                  void CheckTemperature::CheckTemp()
                                  could just have well been

                                  void MainWindow::CheckTemp()

                                  and the difference is really small.

                                  A Offline
                                  A Offline
                                  AlexKrammer
                                  wrote on 14 Jul 2020, 11:56 last edited by
                                  #56

                                  @mrjj no in MainWindow is no CheckTemp() methode.

                                  M 1 Reply Last reply 14 Jul 2020, 11:58
                                  0
                                  • A AlexKrammer
                                    14 Jul 2020, 11:56

                                    @mrjj no in MainWindow is no CheckTemp() methode.

                                    M Offline
                                    M Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on 14 Jul 2020, 11:58 last edited by
                                    #57

                                    @AlexKrammer
                                    Yes that is ganz klar.
                                    Im just saying its odd that inside CheckTemperature the
                                    same classes dont work but outside in mainwindow it seems fine.
                                    I cant guess on why. Seems odd.

                                    A 1 Reply Last reply 14 Jul 2020, 12:11
                                    0
                                    • M mrjj
                                      14 Jul 2020, 11:58

                                      @AlexKrammer
                                      Yes that is ganz klar.
                                      Im just saying its odd that inside CheckTemperature the
                                      same classes dont work but outside in mainwindow it seems fine.
                                      I cant guess on why. Seems odd.

                                      A Offline
                                      A Offline
                                      AlexKrammer
                                      wrote on 14 Jul 2020, 12:11 last edited by
                                      #58

                                      @mrjj
                                      Is there a possibility to share a code with you?
                                      I just created a simple code to show my problem.

                                      M 1 Reply Last reply 14 Jul 2020, 12:14
                                      0
                                      • A AlexKrammer
                                        14 Jul 2020, 12:11

                                        @mrjj
                                        Is there a possibility to share a code with you?
                                        I just created a simple code to show my problem.

                                        M Offline
                                        M Offline
                                        mrjj
                                        Lifetime Qt Champion
                                        wrote on 14 Jul 2020, 12:14 last edited by
                                        #59

                                        @AlexKrammer
                                        Yes even i cant really run it i can look it over and see if i get a hint.
                                        use https://wetransfer.com/
                                        click the (...) button and switch to link type
                                        then drag zipped project to there
                                        and paste link here.

                                        A 1 Reply Last reply 14 Jul 2020, 13:40
                                        0
                                        • M mrjj
                                          14 Jul 2020, 12:14

                                          @AlexKrammer
                                          Yes even i cant really run it i can look it over and see if i get a hint.
                                          use https://wetransfer.com/
                                          click the (...) button and switch to link type
                                          then drag zipped project to there
                                          and paste link here.

                                          A Offline
                                          A Offline
                                          AlexKrammer
                                          wrote on 14 Jul 2020, 13:40 last edited by
                                          #60

                                          @mrjj link text

                                          Now i created the project on Windows.
                                          You should be able to run it.

                                          The two commented debug lines in checktemperature.cpp and mainwindow.cpp show the misstake.
                                          if you are uncomment one in checktemperature.cpp its still stay at 0.
                                          Also if you uncomment this: //qDebug() << C.TempEin; //must be the value of the horizontal slider in mainwindow.cpp. its still stay at 0.

                                          Try to run that example

                                          M 1 Reply Last reply 14 Jul 2020, 13:44
                                          1

                                          50/93

                                          14 Jul 2020, 11:24

                                          • Login

                                          • Login or register to search.
                                          50 out of 93
                                          • First post
                                            50/93
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved