mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 17:31:13 +03:00
java: Added java examples for some sensors
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:

committed by
Mihai Tudor Panu

parent
9d63545d44
commit
5ff625eaf4
33
examples/java/HTU21DSample.java
Normal file
33
examples/java/HTU21DSample.java
Normal file
@ -0,0 +1,33 @@
|
||||
import upm_htu21d.javaupm_htu21dConstants;
|
||||
|
||||
public class HTU21DSample{
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_htu21d");
|
||||
}catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("error in loading native library");
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
float humidity = 0;
|
||||
float temperature = 0;
|
||||
float compRH = 0;
|
||||
|
||||
upm_htu21d.HTU21D sensor = new upm_htu21d.HTU21D(1);
|
||||
sensor.testSensor();
|
||||
|
||||
while (true) {
|
||||
compRH = sensor.getCompRH();
|
||||
humidity = sensor.getHumidity();
|
||||
temperature = sensor.getTemperature();
|
||||
|
||||
System.out.println( "Humidity: " + humidity + ", Temperature: " + temperature + ", compensated RH: " + compRH);
|
||||
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user