B4R Question How to read Temperature value from Digital Pin

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..

B4X:
#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
 

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...
B4X:
#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
 
Upvote 0

pokhraj_d

Member
@Erel
This library doesn't include the referenced library (it is a mistake).
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
 
Upvote 0

tigrot

Well-Known Member
Licensed User
Longtime 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".
 
Upvote 0

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
 
Upvote 0

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...
 

Attachments

  • Error.JPG
    Error.JPG
    85.8 KB · Views: 207
  • DHT-sensor-library-master.zip
    13.9 KB · Views: 213
Upvote 0
Top