DS18B20 Sensor Interfacing with Rsapberry Pi using JAVA

DS18B20 Sensor Interfacing with Rsapberry Pi using JAVAThis video is around Raspberry Pi to showcase the usage of Raspberry Pi in IOT projects and that’s using JAVA. This is going to be a series of video including  Sensor interfacing using pi4J, REST API usage with JAVA, MQTT usage with JAVA and finally adding all to the same project and running over Raspberry Pi. So this video is going to be the first part of it where we will see how to interface DS18B20 one wire temperature sensor with Raspberry Pi by using JAVA with the help of the pi4J library. I will upload the rest of the videos in the series soon.


Code:

 

import com.pi4j.component.temperature.TemperatureSensor;
import com.pi4j.io.w1.W1Master;
import com.pi4j.temperature.TemperatureScale;


public class WaterTemperatureSensor {
  public double getWaterTemperature(){
        W1Master w1Master = new W1Master();

       // System.out.println(w1Master);

        for (TemperatureSensor device : w1Master.getDevices(TemperatureSensor.class)) {
          //  System.out.printf("%-20s %3.1f°C %3.1f°F\n", device.getName(), device.getTemperature(),
                   // device.getTemperature(TemperatureScale.CELSIUS));
            if(device.getName().contains("28-0115155154ff"))
            	return device.getTemperature(TemperatureScale.CELSIUS);
        }
    return 0;
  }

}

 

Links :
Github Repo: bit.ly/2sxXweP
Schematic: bit.ly/2qJ0M6x

I2C Communication on Pi: bit.ly/2jswlgD
16×2 LCD with Pi: bit.ly/2kgR7o8
Java Application on Pi Playlist: bit.ly/2eB1O2K
Schematic: bit.ly/2jsCadP

Download Pi4J Library: bit.ly/2j32blF

Bikash Panda
Catch Me On

Bikash Panda

Blogger / Embedded System Developer at WeArGenius
A techie, tinkerer and tech lover, who loves to blog and feels everyone can learn tech provided they have the right attitude towards learning and passion. By profession, I am an IOT developer working in Smart Home/ Smart Grid domain.
Bikash Panda
Catch Me On

Latest posts by Bikash Panda (see all)

Bikash Panda

A techie, tinkerer and tech lover, who loves to blog and feels everyone can learn tech provided they have the right attitude towards learning and passion. By profession, I am an IOT developer working in Smart Home/ Smart Grid domain.