I've the raspberry pi model b and i am trying to connect a temperature sensor(DHT11). I am facing problem on how to fetch the data from the sensor. I am using JAVA. Which API should i use to get this working? What else should i need to know?

  • You will presumably use the same Java API regardless of which processor you use. That's a big Java selling point. The question appears to have nothing to do with the Raspberry Pi. – joan Mar 19 '16 at 16:52

DHT11 is a n analog o/p temp sensor. so its real easy to use. but on the other side it doesn't have a proper datasheet( it has one but its in Chinese). so i will suggest use any temp sensor from TI,AD, Honeywell. i use SHT25 its low cost and it can do temp and humidity. its accuracy is around 1.8% and 0.2'C.

it comes with I2C communication and real easy to use. you can find java,python code here for Pi I2C.


You need a linux driver that you can call from Java and I don't think that there is one for the DHT11. I have used the code in the book Raspberry Pi IoT In C which interfaces directly without any drivers. You could do the same but you would either need to call a C function that read the data or write your own GPIO version in Java using pi4j It is difficult to know if Java is fast enough to do the job.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.