Today, we are pleased to announce that help has arrived for commercial sub-metering clients with the release of our Free, Open-Source AMR software! Downloadable under the non-restrictive BSD license — users may freely download, install, and tailor the C++ source code for their own proprietary purposes.
This software uses the non-proprietary Modbus protocol to communicate to a group of EtherMeters across an Intranet or across the Internet. Collected meter readings are time-stamped and stored into an ASCII .CSV File (Comma-Separated Text File), which can be opened and manipulated using spreadsheet software, such as Microsoft Excel.
Today’s article will help you to build an AMR system using this new free software package. This non-proprietary program was designed to poll a network of EtherMeters using the standard Modbus/TCP or Modbus/UDP protocol from a Windows-based PC. The EtherMeters could be coexistent on a LAN, or they could be scattered across various Internet IP addresses.
Step 1. Store the executable file (amr.exe) to an empty directory.
Step 2. Within that directory, create a file called ‘sites.txt’ that defines the network addresses of the flow meters on the network:
Sample ‘SITES.TXT’ File (Meter Definitions File):
600 # SAMPLE_PERIOD_SECS 1 2 192.168.1.114 502 U # METER_ID_1 , METER_ID_2 , HOSTNAME(OR_IP_ADDRESS) , VIRTUAL_PORT , TCP_OR_UDP 3 4 192.168.1.115 502 U # METER_ID_1 , METER_ID_2 , HOSTNAME(OR_IP_ADDRESS) , VIRTUAL_PORT , TCP_OR_UDP 5 6 192.168.1.116 502 U # METER_ID_1 , METER_ID_2 , HOSTNAME(OR_IP_ADDRESS) , VIRTUAL_PORT , TCP_OR_UDP
Step 3. Open a Windows Command Prompt Window, and change directory to the directory containing amr64.exe or amr32.exe.
Step 4. Execute the program (amr64.exe or amr32.exe) from the command line, as follows:
amr64.exe <enter>
The program then polls each networked meter every 600 seconds and stores the data to a .CSV file. Here is an example of the file:
Sample ‘METER.CSV’ File (Historical Database File):
(Note that each EtherMeter is capable of reading ONE or TWO meters. If one of the two meter input channels is inactive, then the METER_ID should be set to ZERO.)
Date , Time , Meter_ID , Network_Fault , Meter_Fault , Meter_Reading , Units , Rate_of_Flow 2017/08/27 , 11:30 , 0001 , 0 , 0 , 169.000 , GAL , 0.000 2017/08/27 , 11:30 , 0002 , 0 , 0 , 99999986.000 , GAL , 0.000 2017/08/27 , 11:30 , 0003 , 0 , 0 , 520.000 , GAL , 0.000 2017/08/27 , 11:30 , 0004 , 0 , 0 , 258923.000 , GAL , 0.000 2017/08/27 , 11:30 , 0005 , 0 , 0 , 35011.000 , GAL , 0.000 2017/08/27 , 11:30 , 0006 , 0 , 0 , 12982175.000 , GAL , 0.000 2017/08/27 , 11:40 , 0001 , 0 , 0 , 169.000 , GAL , 0.000 2017/08/27 , 11:40 , 0002 , 0 , 0 , 99999986.000 , GAL , 0.000 2017/08/27 , 11:40 , 0003 , 0 , 0 , 520.000 , GAL , 0.000 2017/08/27 , 11:40 , 0004 , 0 , 0 , 258923.000 , GAL , 0.000 2017/08/27 , 11:40 , 0005 , 0 , 0 , 35011.000 , GAL , 0.000 2017/08/27 , 11:40 , 0006 , 0 , 0 , 12982175.000 , GAL , 0.000 2017/08/27 , 11:50 , 0001 , 0 , 0 , 169.000 , GAL , 0.000 2017/08/27 , 11:50 , 0002 , 0 , 0 , 99999986.000 , GAL , 0.000 2017/08/27 , 11:50 , 0003 , 0 , 0 , 520.000 , GAL , 0.000 2017/08/27 , 11:50 , 0004 , 0 , 0 , 258923.000 , GAL , 0.000 2017/08/27 , 11:50 , 0005 , 0 , 0 , 35011.000 , GAL , 0.000 2017/08/27 , 11:50 , 0006 , 0 , 0 , 12982175.000 , GAL , 0.000 2017/08/27 , 12:00 , 0001 , 0 , 0 , 169.000 , GAL , 0.000 2017/08/27 , 12:00 , 0002 , 0 , 0 , 99999986.000 , GAL , 0.000 2017/08/27 , 12:00 , 0003 , 0 , 0 , 520.000 , GAL , 0.000 2017/08/27 , 12:00 , 0004 , 0 , 0 , 258923.000 , GAL , 0.000 2017/08/27 , 12:00 , 0005 , 0 , 0 , 35011.000 , GAL , 0.000 2017/08/27 , 12:00 , 0006 , 0 , 0 , 12982175.000 , GAL , 0.000 2017/08/27 , 12:10 , 0001 , 0 , 0 , 169.000 , GAL , 0.000 2017/08/27 , 12:10 , 0002 , 0 , 0 , 99999986.000 , GAL , 0.000 2017/08/27 , 12:10 , 0003 , 0 , 0 , 520.000 , GAL , 0.000 2017/08/27 , 12:10 , 0004 , 0 , 0 , 258923.000 , GAL , 0.000 2017/08/27 , 12:10 , 0005 , 0 , 0 , 35011.000 , GAL , 0.000 2017/08/27 , 12:10 , 0006 , 0 , 0 , 12982175.000 , GAL , 0.000
Downloads:
We will occasionally post modifications and updates here — so if you are interested in using this free software as part of your flow meter monitoring solution, please refer back to this blog article occasionally.
Notes/Updates:
19 Dec 2015 – Added DNS Name Resolution Lookup to Program. Allows for Hostnames and/or IP Addresses, which serves situations where the meter does not have a static IP address, and the internet location is handled via dynamic DNS.
19 Mar 2016 – Updated .EXE files with embedded C++ runtime libraries.
12 April 2016 – Updated source and executables to provide both Modbus/TCP and Modbus/UDP socket options. Previous version only provided Modbus/UDP.
27 Aug 2017 – Updated source and executables that allows for specifying TCP or UDP socket types on a per-EtherMeter basis. Also, moved the polling sample period specifier from the command line to the input file (sites.txt). The code was re-organized for more efficient meter reads: Previously, if an EtherMeter had two connected meters, then two network polling requests were performed to collect the two readings. In the new code, only one network poll request is performed. Also meter registration units are now queried from the EtherMeters (e.g. Gallons, Liters, Cubic Feet, Acre Feet, etc…). Meter Fault (e.g. Cut Meter Signal Cable) is also now queried from the EtherMeters.
17 Sep 2018 – Updated source and executables that fix errors in performing the proper meter total scalings (x10, x100, etc…) and in displaying the meter registration units.
01 Nov 2018 – Updated source and executables to patch a resource leak. There was an fopen() call, without a corresponding fclose() call.
Thanks Jim,
Just had a thought. There is a device out there called a Netduino – similar to an Arduino. It is super small and inexpensive – about $50. It is programmed in C# by using Visual Studio. Might be a good way to store data.
Regards,
Greg
Hi Greg, Thanks for your comment. Are you are suggesting that using a small single-board computer — combined with this article’s open-source polling software — would make for an inexpensive datalogger for a network of EtherMeters? If so, then I agree wholeheartedly.
Another alternative is to use a Raspberry PI which supports development in C++. The PI comes with a Ethernet socket and multiple USB ports. You would connect it via the Ethernet connection and use a USB stick to hold the CSV file. I have also been able to configure the PI with a WIFI adapter in one of the other USB ports and had it setup as a web server.
Hi Pete, Raspberry PI is a great idea for a Modbus data collector/logger!
19 Dec 2015 Update: Added DNS Name Resolution Lookup to Program. Allows for Hostnames and/or IP Addresses, which serves situations where the meter does not have a static IP address, and the internet location is handled via dynamic DNS.
19 Mar 2016 Update: Recompiled and uploaded new .EXE files with embedded C++ runtime libraries. Alleviates “failed to start, side-by-side” execution errors.
12 April 2016 Update: Updated source and executables to provide both Modbus/TCP and Modbus/UDP socket options. Previous version only provided Modbus/UDP.
27 Aug 2017 Update: Major Update to source and executable files. Allows for specifying TCP or UDP socket types on a per-EtherMeter basis. Also, moved the polling sample period specifier to the input file (sites.txt). The code was re-organized for more efficient meter reads. Previously, if an EtherMeter had two connected meters, then two network requests were performed to collect the readings. In the new code, only one network read is required. Also added meter registration units to the code (e.g. Gallons, Liters, Cubic Feet, Acre Feet, etc…). Meter Fault (e.g. Cut Meter Signal Cable) was added to the code.