Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e5a160b
Showing
5 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="lib" path="D:/!IOTPI_App_Code/IOTAPP_Pi/lib/pi4j-core.jar"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>DHT12_Pi</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
There are supposed to be 5 bytes returned: | ||
0x00 = Humidity | ||
0x01 = Humidity decimal places | ||
0x02 = Temperature | ||
0x03 = Temperature decimal places | ||
0x04 = Checksum (sum 0x00,0x01,0x02,0x03) | ||
|
||
Arduino example returns data like this: | ||
45,6,24,0,75 - which means 45.6 %RH, 24.0 deg C, (valid checksum 45+6+24+0=75) | ||
45,6,23,9,83 - which means 45.6 %RH, 23.9 deg C, (valid checksum 45+6+23+9=83) | ||
45,7,23,9,84 - which means 45.7 %RH, 23.9 deg C, (valid checksum 45+7+23+9=84) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package in.weargenius.main; | ||
|
||
import com.pi4j.io.i2c.I2CBus; | ||
import com.pi4j.io.i2c.I2CDevice; | ||
import com.pi4j.io.i2c.I2CFactory; | ||
|
||
public class Main { | ||
|
||
private static I2CDevice dev = null; | ||
static boolean x =false; | ||
public static void main(String[] args) throws Exception{ | ||
System.out.println("DHT12 Pi4j Example."); | ||
I2CBus bus = I2CFactory.getInstance(I2CBus.BUS_1); // | ||
|
||
dev = bus.getDevice(0x5c); //Address for MCp23017 change if A0,A1,A2 are connected to diff potenrial | ||
byte data[] = new byte[5]; | ||
dev.read(0x00,data, 0,5); | ||
if(x){ | ||
System.out.println(data[0]); //Humidity | ||
System.out.println(data[1]); //HUmidity decimal places | ||
System.out.println(data[2]); //Temperature | ||
System.out.println(data[3]); //Temperature decimal places | ||
System.out.println(data[4]); // Checksum = data[0]+data[1]+data[2]+data[3] | ||
} | ||
|
||
if(data[4]==(data[0]+data[1]+data[2]+data[3])){ | ||
|
||
double humidity=Double.parseDouble(data[0]+"."+data[1]); | ||
double temperature=Double.parseDouble(data[2]+"."+data[3]); | ||
System.out.println("humidity is : "+humidity+" %RH"); | ||
System.out.println("Temperature is : "+temperature+" °C"); | ||
} | ||
else | ||
System.out.println("Error in communication."); | ||
} | ||
|
||
|
||
} |