1

There are several questions about getting the temperature but non of them covers a solution for java. I want to build al little weather station in java to gett temp values, unfortunatly i am not that much into soldering and stuff, so i am looking for a simple/ready to use solution. The java libray Pi4j offers access to analogue inputs but which extension board should i use? The soulution should be power saving, cause the station runs with accu's and a small solarcell.

1

I would suggest you check the DS18B20 1-wire sensors, which are digital, and have working kernel drivers. Adafruit has a tutorial on how to get them working. You can use up to 10 sensors on the same pin at this time (this is a hardcoded kernel driver limit, as is using the pin it uses. This tutorial has it right, just follow it).

As for reading the results, it is as easy as finding a file with a predefined name pattern and then opening the file for read and parsing 2 lines of content. Using 2 sensors is as easy as duplicating the procedure for reading one. Each sensor will be made available in a different file in the file system.

There is no need for any Java-specific libraries, procedures or tricks altogether. Just open a file with a particular name pattern for reading. If you use the same sensor, the filename will be the same between readings, so you only need to find the filename that the kernel driver creates once for each of the sensors throughout the sensor's lifespan.

As for an expansion board any that makes pin GPIO 4 (which is P1-7) available is okay. That is the fixed pin number used by the 1-wire kernel driver. The Pi Cobbler from Adafruit is one of the many that will do that.

2
  • Thanks for your answer, seems like the tutorial is no longer available, i get an 404.
    – Chriss
    Apr 15 '14 at 6:08
  • That was quick. Just updated the link and should work now.
    – Marco Poli
    Apr 15 '14 at 6:16
0

There is also a Pi-Weather Station Board available at 28$, that is connected to the I2C-Bus. The board provides two 1-Wire temperature ports to measure the outside temperature with DS18B20 sensors. Onboard are a humidity sensor, a pressure sensor and an internal temperature sensor.

enter image description here

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.