Devmel Company

Beginner’s Tutorial

This tutorial leads you through the creation of a simple app that uses the Devmel SDK to get and display the room temperature in Kelvins and Celcius.

Before You Begin
Constructing a SimpleIPLocator Object

import com.devmel.content.SimpleIPLocator;
public class AirSendExample {
	public static void main(String[] args) {

		//Enter your unique locator
		SimpleIPLocator cfg = new SimpleIPLocator("sp://1234567890123456@[fe80::dcf6:e5ff:fe:1]?gw=y");

	}
}

Get and Display temperature

import com.devmel.content.SimpleIPLocator;
import com.devmel.devices.AirSend;

public class AirSendExample {

	public static void main(String[] args) {
		//Enter your unique locator
		SimpleIPLocator cfg = new SimpleIPLocator("sp://1234567890123456@[fe80::dcf6:e5ff:fe:1]?gw=y");
		//Create an AirSend Object
		AirSend airsend = new AirSend(cfg);
		try {
			//Open the communication
			if(airsend.open()){
				//Read the temperature in Kelvins
				double tmp = airsend.readTemperature();
				//Display the result
				if (tmp >= 0) {
					double tmpCelcius = Math.round((tmp - 273.15) * 10.0) / 10.0;
					System.out.println("Temperature : "+String.format("%.1f\u00B0K",tmp));
					System.out.println("Temperature : "+String.format("%.1f\u00B0C",tmpCelcius));
				} else if (tmp < 0) {
					System.out.println("Error");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			//Close the communication
			airsend.close();
		}
	}
}

Displaying the Result

Finally, launch the program and see you room temperature in real time.