B4R Question How to read Temperature value from Digital Pin

Discussion in 'B4R Questions' started by pokhraj_d, Aug 22, 2018.

  1. pokhraj_d

    pokhraj_d Member

    Hello All,

    I am working on DHT11 temp sensor. I have connected the sensor on pin10. Now when I am trying to read the value from pin10 , the value is one(1).

    please suggest how can I get the raw temperature value from pin10.
    Please find below the sketch..

    Code:
    #Region Project Attributes
        
    #AutoFlushLogs: True
        
    #CheckArrayBounds: True
        
    #StackBufferSize: 300
    #End Region

    Sub Process_Globals
        
        
    Public Serial1 As Serial
        
    Private timer1 As Timer
        
    Private pin10 As Pin
    End Sub

    Private Sub AppStart
        Serial1.Initialize(
    115200)
        
    Log("AppStart")
        pin10.Initialize(
    10,pin10.MODE_INPUT)
        timer1.Initialize(
    "temp_calc",1000)
        timer1.Enabled=
    True
    End Sub

    Private Sub temp_calc
        
    'Dim temp As Boolean = pin10.DigitalRead
        Log("The Read value is :",pin10.DigitalRead)
    End Sub
     
  2. mark35at

    mark35at Well-Known Member Licensed User

    Not sure if this helps but have a look at post #36, here. Or this post here.
     
    Peter Simpson likes this.
  3. pokhraj_d

    pokhraj_d Member

    After lot of reading I download the file rDht from b4x libraries. I followed the below Steps:

    1. Download rDht.zip
    2. Download DHT11 Library from github form arduino
    3. Unzip rDht.zip and copy to main b4r library folder
    4. Unzip and copy the DHT11 library to arduino library folder
    5. Change rDht.h file from //Define to <dht.h> to #include <dht.h>
    6. Change at .xml file.

    Still I am facing the below error :

    upload_2018-8-23_10-45-14.png

    Below is my Sketch...
    Code:
    #Region Project Attributes
        
    #AutoFlushLogs: True
        
    #CheckArrayBounds: True
        
    #StackBufferSize: 300
    #End Region

    Sub Process_Globals
        
    Public Serial1 As Serial
        
    Private timer1 As Timer
        
    Public DHT11sensor As dht
        
    Private pin10 As Pin
    End Sub

    Private Sub AppStart
        Serial1.Initialize(
    115200)
        
    Log("AppStart")
        pin10.Initialize(
    10,pin10.MODE_INPUT)
        timer1.Initialize(
    "temp_calc",1000)
        timer1.Enabled=
    True
    End Sub

    Private Sub temp_calc
        
    'Dim temp As Boolean = pin10.DigitalRead
        DHT11sensor.Read11(pin10.PinNumber)
        
    Dim temperature As Double
        temperature = DHT11sensor.GetTemperature
        
    Log("The temp is now : " , temperature)
    End Sub
    Please advice how to fix the error

    Thanks-
    Pokhraj Das
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    This library doesn't include the referenced library (it is a mistake).

    1. You don't need to change anything in the library.
    2. You do need to open Arduino IDE and install the relevant library from the libraries manager.
     
  5. pokhraj_d

    pokhraj_d Member

    @Erel
    It is still not clear to me. Then how do I make a referenced library.
    Could you please advice on steps I need to follow. As I Am a newbie at B4r

    Thanks
    Pokhraj Das
     
  6. tigrot

    tigrot Well-Known Member Licensed User

    More than B4R this is related to Arduino compiler package. From the GUI you must search for the library and install. It'a simple process. I'm now on mobile and I cannot show the path. Google "install library on arduino environment".
     
  7. tigrot

    tigrot Well-Known Member Licensed User

  8. pokhraj_d

    pokhraj_d Member

    Hi Tigrot
    Thanks for the suggestion. I would like to know how do I prepare or create a wrapper for b4r. As what I found for arduino libraries it is better to create wrapper instead of inline c/c++.
    I hv downloaded .jar files for wrapper. While running I am getting error.
    Please help.

    Thanks
    Pokhraj Das
     
  9. tigrot

    tigrot Well-Known Member Licensed User

  10. pokhraj_d

    pokhraj_d Member

    Hi,
    I have tried B4RH2xml.jar to create a wrapper for DHT11. But no luck.
    Please find the error details and DHT library for arduino attached...
     

    Attached Files:

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice