OneWire is a widely used protocol for home automation. It is used by sensors like thermometers.
This implementation directly talks to the OneWire busmaster, e.g. a DS9490R USB dongle, without requiring the OneWire File System (OWFS). It therefore requires the natively compiled C library by the manufacturer of the OneWire chip Maxim Integrated. This library is then accessed using Java JNI.
To compile the native library follow the guide on https://www.maximintegrated.com/en/design/technical-documents/app-notes/5/5917.html.
-
Download the OneWireViewer-Linux.zip file
-
Unzip the file (
unzip OneWireViewer-Linux.zip
) -
Prepare compile environment (
sudo apt-get install libusb-dev build-essential
) -
Install Java JDK (e.g.
sudo apt-get install openjdk-8-jdk
) -
Compile (
cd OneWireViewer-Linux/PDKAdapterUSB && make && sudo make install
)
The library needs exclusive access to the busmaster.
-
Unload the default Linux driver:
rmmod ds2490
-
Block the driver from loading on next boot
echo blacklist ds2490 > /etc/modprobe.d/ds2490.conf
The OneWire Bridge provides a JSON-RPC Request that reads all devices connected to the OneWire bus.
Example: read via OpenEMS Backend
{
"method": "edgeRpc",
"params": {
"edgeId": "edge0",
"payload":{
"method": "componentJsonApi",
"params": {
"componentId": "onewire0",
"payload": {
"method": "getDevices",
"params": {}
}
}
}
}
}
Example Response:
{
"jsonrpc":"2.0",
"id":"UUID",
"result":{
"payload":{
"jsonrpc":"2.0",
"id":"UUID",
"result":{
"devices":[
{
"address":"4D0000094xxxxxxx",
"name":"DS18B20",
"alternateName":"DS1820B, DS18B20X",
"description":"Digital thermometer measures temperatures from -55C to 125C in 0.75 seconds (max). +/- 0.5C accuracy between -10C and 85C. Thermometer resolution is programmable at 9, 10, 11, and 12 bits. ",
"details":{
"type":"TemperatureContainer",
"temperature":17.5625
}
},
{
"address":"6F0000022xxxxxxx",
"name":"DS2438",
"alternateName":"Smart Battery Monitor",
"description":"1-Wire device that integrates the total current charging or discharging through a battery and stores it in a register. It also returns the temperature (accurate to 2 degrees celsius), as well as the instantaneous current and voltage and also provides 40 bytes of EEPROM storage.",
"details":{
"type":"TemperatureContainer",
"temperature":19.3125
}
}
]
}
}
}
}