This library contains support to read out a Cube 350 Smart meter through two-wire Modbus (RS485)
This library allows you to communicate to a Northern Design Cube 350 Smart meter through two-wired modbus (RS485)
These instructions will allows you to get the library up and running on your local machine.
* A minimum of Java 8 is required for this library.
* If running on Linux, you will need to add your user to the dialout group.
* Cheap CH340 USB to RS485 converter (about 1.5$) or other variants
* Cube 350 Kwh meter or other variants
To able to access the serial port, you need to add your user that you want to run this library to the dialout group.
This will add your current user to the dialout group.
sudo adduser $USER dialout
(See Section 4. Programming of the Cube350 A4 Operating Manual July 2006 A4.pdf)
(SW) properties are required as input parameters for this library.
Quick summary:
Depending you have set a security code through Modbus or the programming menu, you will or will not have to provide a code.
You can use this library to read out one or multiple Cube 350 Modbus energy meter(s).
Through readEnergyModbusRegister()
it is possible to directly access the Modbus registers.
It is also possible to read out the calculated energy value through CombinedEnergyRegister
.
This gives you a correct result like Kwh, Kvarh & many more values.
This library has been written with simplicity in mind meaning you are in full control of threads, schedulers, …
import static com.github.mdevloo.cube.modbus.register.energy.energy.CombinedEnergyRegister.KWH;
final class Application {
void cubeReadout() {
final int id = 5;
final ModbusConfiguration modbusConfiguration = new ModbusSerialConfiguration("/dev/ttyUSB0",
ModbusCommunication.BaudRate.RATE_9600, 10);
final CubeMeter cubeMeter = new CubeMeter.Builder(id, modbusConfiguration)
.registers(InstantaneousModbusRegister.values())
.combinedRegisters(KWH)
.build();
final ModbusService cubeModbusService = new CubeModbusService(cubeMeter);
final List<CombinedModbusResult> cubeEnergyvalue = cubeModbusService.readEnergyModbusRegister(CubeModbusService.Scaler.KWH);
cubeEnergyvalue.forEach(res -> logger.info("Register {} - Energy value :{} KwH", res.getCombinedRegister(), res.calculateEnergyScaling()));
final List<ModbusResult> modbusResults = cubeModbusService.readModbusRegisters();
modbusResults.forEach(mod -> logger.info("Value of Register: {} - {}", mod.getModbusRegister(), mod.getRegister().getValue()));
}
}
[pool-1-thread-1] ERROR com.github.mdevloo.cube.modbus.service.CubeModbusService - Modbus communication error: [Modbus connection exception: [Port [ttyUSB0] cannot be opened or does not exist - Valid ports are: [ttyUSB0]]]
This project is licensed under the MIT License - see the LICENSE file for details