I was playing with B4R + ESP32 DEVKIT V1 + DHT22 sensor.
Previously was using rDHT version 2.0 library , and result always 0.
Previously I used this library at UNO and success.
Here is my code module :
Then I found this thread : https://www.b4x.com/android/forum/threads/dht-11-example-for-esp32.82783/
I copy paste Native method to my code module :
But compilation will failed with attached logs .
What might wrong ?
I am new to B4R. Please help
Previously was using rDHT version 2.0 library , and result always 0.
Previously I used this library at UNO and success.
Here is my code module :
B4X:
Sub Process_Globals
Private Led As Pin
Private dht_pin As Pin
Private dht_sensor As dht
Private dht_temperature As Double
Private dht_humidity As Double
Private dht_read_result As Int
Private timerdht As Timer
End Sub
Public Sub Init
Led.Initialize(2,Led.MODE_OUTPUT)
Led_Blink
dht_pin.Initialize(4, dht_pin.MODE_INPUT)
timerdht.Initialize("timerdht_Tick",5000)
timerdht.Enabled=True
End Sub
Private Sub timerdht_Tick
dht_temperature = 0
dht_humidity = 0
dht_read_result = dht_sensor.Read11(dht_pin.PinNumber)
dht_temperature = dht_sensor.GetTemperature
dht_humidity = dht_sensor.GetHumidity
Log("Read Result : ",dht_read_result," Temp : ",dht_temperature," Humidity : ",dht_humidity)
Led_Blink
End Sub
Public Sub Led_Blink
Led.DigitalWrite(True)
CallSubPlus("Led_Off",200,0)
End Sub
Private Sub Led_Off(unused As Byte)
Led.DigitalWrite(False)
End Sub
Then I found this thread : https://www.b4x.com/android/forum/threads/dht-11-example-for-esp32.82783/
I copy paste Native method to my code module :
B4X:
#if C
#include "DHT.h"
#define DHTPIN 4 // what digital pin we're connected to
#define DHTTYPE DHT22 // DHT 22
DHT dht(DHTPIN, DHTTYPE);
void setupdht(B4R::Object* o){
dht.begin();
}
void readdht (B4R::Object* o) {
b4r_main::_humidity = dht.readHumidity();
b4r_main::_temperature = dht.readTemperature();
}
#End if
But compilation will failed with attached logs .
What might wrong ?
I am new to B4R. Please help