B4R Question ESP8266 with DHT11 Not showing Data to Webpage

Discussion in 'B4R Questions' started by AndroidMadhu, Sep 27, 2019.

  1. AndroidMadhu

    AndroidMadhu Active Member Licensed User

    Hello,
    I am trying to send DHT11 humid and temp to my test website page. While I am hardcoding the values for humid and temperature it is working fine.
    But while I am replacing the hardcode value with the humid and temperature value from dht11, it is not working, instead the value shown in website is text like
    -------------
    temperature humid
    temperature humid
    temperature humid
    ------------
    Below is the code snippet:
    Code:
    #Region Project Attributes
        
    #AutoFlushLogs: True
        
    #CheckArrayBounds: True
        
    #StackBufferSize: 300
    #End Region

    Sub Process_Globals
        
    'These global variables will be declared once when the application starts.
        'Public variables can be accessed from all modules.
        Public Serial1 As Serial
        
    Private MyEsp As ESP8266WiFi
        
    Private d1pin As D1Pins
        
    Private D1 As Pin
        
    Dim humid,temperature As Float
      
    End Sub

    Private Sub AppStart
        Serial1.Initialize(
    115200)
        D1.Initialize(d1pin.D1,D1.MODE_OUTPUT)
        
    Log("AppStart")
        MyEsp.Connect2(
    "MyWifi","xxxx")
        
    If MyEsp.IsConnected=True Then
            
    Log("Router Connected Successfully!!")
        
    Else
            
    Log("Failed To connect to Router!!")
            
    Return
        
    End If
        RunNative(
    "setup",Null)
        
    HttpJob.Initialize("Test")
        
    HttpJob.Download("http://test.com")
    End Sub

    Sub JobDone(Job As JobResult)
        RunNative(
    "read",Null)
        Delay(
    2000)
        
    ''HttpJob.Download("http://test.com/addTemperature.php?temperature=13.7&humidity=45.5")  --->> This is working.
        HttpJob.Download("http://test.com/addTemperature.php?temperature=temperature&humidity=humid") --->> This is not working. Only the text "temperature" and "humid" is coming at the website
        
    Log("Humid: ",humid) -->this is fine
        
    Log("Tempa: ",temperature)  -->this is fine
    End Sub



    #if C
    #include "DHT.h"
    #define DHTPIN 5  //GPIO5(D1) at ESP8266
    #define DHTTYPE DHT11
    DHT dht(DHTPIN, DHTTYPE);
    void setup(B4R::Object* o){
    dht.begin();
    }
    void read (B4R::Object* o) {
       b4r_main::_humid = dht.readHumidity();
       b4r_main::_temperature =dht.readTemperature();
    }
    #End if
    Please advice
     

    Attached Files:

  2. janderkan

    janderkan Active Member Licensed User

  3. AndroidMadhu

    AndroidMadhu Active Member Licensed User

    @janderkan , The numberformat is not working. But your suggestion worked without numberformat.
    What I have done is as below :
    Code:
    Dim s As String=JoinStrings(Array As String("http://test.com/addTemperature.php?temperature=",temperature,"&humidity=",humid))
    It is working. But why the numberformat is not working? As it is required to format the temp or humidity upto 2 decimal.
    How Do I achieve this? Please suggest.
     
  4. janderkan

    janderkan Active Member Licensed User

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