A Java application to communicate with the WattsUp? to get the available power measurements. The communication is based on the protocol description available at https://www.wattsupmeters.com/secure/downloads/CommunicationsProtocol090824.pdf
Here is a class that connects to the power meter during three minutes and print the measurements data on output console.
public final class WattsUpTest
{
/**
* Creates an {@link WattsUp} for monitoring during three minutes.
*
* @param args
* The reference to the arguments.
* @throws IOException
* If the power meter is not connected.
*/
public static void main(String[] args) throws IOException
{
final SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
final WattsUp meter = new WattsUp(new WattsUpConfig().withPort(args[0]).scheduleDuration(3 * 60));
meter.registerListener(new WattsUpDataAvailableListener()
{
@Override
public void processDataAvailable(final WattsUpDataAvailableEvent event)
{
WattsUpPacket[] values = event.getValue();
System.out.printf("[%s] %s\n", format.format(new Date()), Arrays.toString(values));
}
});
meter.connect();
}
}
java -cp lib/nrjavaserial-3.8.8.jar wattsup.jsdk.example.test.WattsUpTest /dev/ttyUSB0
This project uses the nrjavaserial and Java 7.