My use of one-wire devices started with a basic weather system but whilst there are several software application available
using one-wire devices (a) none completely satisfied by requirements and (b) I wanted to teach myself application development using
Java. I started this self instruction with the help of the book WeatherToys
by Tim Bitson. The result is a small background Java application that searches a one-wire network for devices and then interrogates
each channel of each device found on a defined schedule and then uploads the data to a database.
A screen shot of the GHowSA application is shown on the right
The GHowSA application was developed from Tim Bitsons's Weather Toys using the NetBeans IDE. The most significant differences between
Weather Toys and GHowSA are:-
- GHowSA uses an Access database instead of SQLite. This is because my existing web applications use Access, SQL or MySQL databases.
Note that to use an access database the application is compiled in 32-bit mode since the odbc drivers are not 64-bit compatible.
- IMPORTANT UPDATE: Following the release of Java version 8.0 the JDBC-ODBC Bridge has been removed from Java SE 8 and is not supported
and so an alternate method is required to transfer data to the Access database. I elected to uses
which is a pure Java JDBC driver that allows read from and write to Access databases without using ODBC. The changeover was fairly simple
except that the UCanAccess driver does not recognise the exponential/scientific notation for large floating point numbers. The source code was
therfore modified to provide a function to provide a string representaion of double values without scientific notation. This function
was based on the discussion at
- FURTHER UPDATE: Having changed service provider I can no longer host an Access database and therefore I have updated the software to use a MySQL database.
- The initial configuration for GHowSA is read from an initialisation file GHowSA.ini and thereafter the configuration for individual
devices is read from the database. The device initialisation data includes the transfer function coefficients, sampling frequency, and device
description for each channel of the device.
- The initiation file also controls the error logging function allowing debugging information and or any programme run-time errors to be
logged to a debugging log and an error log respectively.
- The application limits the amount of detail data stored in the database based on the Days_to_keep_detail_data parameter in the ini file and
transfers summary data to the summary table at midnight of each day.
- A generic device class has been added that addresses all the available channels of all the available devices. eg The Battery monitor device
family "2F" has seven channels ("T";"Vad";"Vdd";"Vsens";"ICA";"CCA";"DCA") that can be accessed and logged to the database.
- The network search algorithm has been modified to ensure that network branches attached via a network hub are found.
- A window interface has been added to show the application in operation. This window can be collapsed to a system tray
icon in the notification taskbar
- For remote monitoring purposes a web server is included allowing the device data to be viewed remotely via a web-page
- A significant amount of error trapping has been retained within the application slowing the scanning of devices nontheless the application
in its current version scans at 200 milliseconds per channel allowing for 300 channels to be sampled per minute. However, simulation reveal
a practical limit of 150 channels per minute. The number of channels to be scanned can be increased if the scan interval is increased or
the frequency of scanning for channels recording slow changing data such as temperature is reduced. This is done in the device table in
the database by setting the CH_Freq to an integer greater than one. For example with an application scan frequncy of once per minute setting
the CH_Freq to 5 will result in all the channels of that device begin scanned once every five minute.
- A classes have been added to calculate solar positions, solar times and solar irradiation based on the Bird model.
- The SQLite class has been retained allowing for reversion of the database type back to SQLite.
For those with any interest in this application the Netbeans Project source data can be downloaded below.
Please note that this application is my very first application using Java and Netbeans IDE and was produced for personal use only and
as a means of becommng familiar with Java and one-wire programming, so do not expect commercial level software, or well structured and documented code.
The objective was to get something up and running for my own personal use but if anyone has any use for the code I am only too willing to share it.
Obviously if you download the source code and have any difficulties with it please be aware that as an absolute beginner myself in this area I
am unlikely to be able to provide any practical assistance.