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 SimpleIPConfig Object

import com.devmel.storage.SimpleIPConfig;
import com.devmel.tools.IPAddress;


public class AirSendExample {
	public static void main(String[] args) {
		
		//Enter your configuration name
		SimpleIPConfig deviceConfig = new SimpleIPConfig("MyConfigName");
		
		//Enter the AirSend Link Local Unique IP
		deviceConfig.setIp(IPAddress.toBytes("fe80::90de:6eff:fe00:af42"));
		//Enter the AirSend Password
		deviceConfig.setPassword("+aYN5g$AZv2Hf9xz");

	}
}

Get and Display temperature

import com.devmel.devices.AirSend;
import com.devmel.storage.SimpleIPConfig;
import com.devmel.tools.IPAddress;


public class AirSendExample {
	public static void main(String[] args) {
		
		//Enter your configuration name
		SimpleIPConfig deviceConfig = new SimpleIPConfig("MyConfigName");
		
		//Enter the AirSend Link Local Unique IP
		deviceConfig.setIp(IPAddress.toBytes("fe80::90de:6eff:fe00:af42"));
		//Enter the AirSend Password
		deviceConfig.setPassword("+aYN5g$AZv2Hf9xz");

		//We must use a devices.AirSend Object
		AirSend airsend = new AirSend(deviceConfig);
		try {

			//Open the communication
			if(airsend.open()){

				//Read the temperature in Kelvins
				double tmp = airsend.getTemperature();

				//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.