B4J Question Raspberry PI GPIO and DHT11 sensor with B4J

giggetto71

Active Member
Licensed User
Longtime User
Hi,
does anyone have some example on how to get temperature and humidity out of the DHT11 using Raspberry PI GPIO and B4J? I have seen some example with B4R but I am looking to the possibility to use RPi in this case.
thanks?
 

rwblinn

Well-Known Member
Licensed User
Longtime User
Not trivial to solve. One solution is to run a Python script and capture the output. This can be acomplished by using the adafruit dht11 libary.

Please find attached example containing the adafruit library and a B4J non-ui application. The B4J non-ui applications runs the python script and captures the output.
Solution successfully tested on a Raspberry Pi via the B4J Bridge. DHT11 connected to GPIO23.
Please read the readme.txt for the installation steps on the raspberry pi.

B4X:
Application Started with Argument: simpletest.py
Python Script successfully executed. Output:
Temp=17.0*C  Humidity=40.0%

There might be other solutions.

Good Luck.
 

Attachments

  • DHT11ShellPython.zip
    109.9 KB · Views: 376
Upvote 0

giggetto71

Active Member
Licensed User
Longtime User
rwblinn,
I have just finished to test your solution and it worked like a charm! THANKS!! I did not know how easy was to have B4J interacting with python. thanks!
 
Upvote 0
Top