Saturday, December 23, 2017

Reading power meters with RTL-AMR

Today I got the RTL-AMR tool working and monitored some power meters. To install it, you'll need to install 2 programs: Git and Go. This program needs to be compiled by Go and that can't happen without Git.

The install instructions are mostly copied from RTL-AMR's official GitHub page.

Download Go from here. Once you've installed it, download Git from here and install it. Lastly, you'll need to make sure your RTL-SDR drivers are installed and then download and extract this ZIP file.

Go to the extracted files, open the "rtl-sdr-release" folder, choose your architecture (x32 is fine by default) and run "rtl_tcp.exe". This will produce a Command Prompt window. Leave it running.

Open another Command Prompt and enter (or Copy-Paste) go get github.com/bemasher/rtlamr.


This will produce a file called "rtlamr.exe". It should be in your "C:\Users\[username]\go\bin" folder. Drag it onto a command prompt window, press Space, and add (without brackets) [> "C:\pop.csv"]. Press Enter to run this command.

This is what it should look like when you press Enter:



That command with the right caret and "C:\pop.csv" means we want to pipe the output into a file.

Now, as long as an antenna is hooked up, it will collect power usage stats from the nearest power meters and save them into the *.CSV file.

Here's what that file should look like in Notepad++:


The Type field in the middle tells us what kind of meter we're reading. Type 7 means electric. Reddit user dongledorr says that gas meters are type 12, but I'm not picking up any of those.

I've written some programs in Liberty BASIC to process these files.

To make it easy to keep this process running, I left RTL-AMR running and just did copy-paste on C:\pop.csv. In Windows 7, this produced "C:\pop - Copy.csv". You'll need to open this copy in Notepad++ and convert the line endings to Windows-style using Edit->EOL Conversion->Windows (CR LF), or the following code won't read it.

Here's the first program to process it into an actual CSV file:


This produces C:\pop2.csv, which may be opened in Excel. You'll want to sort the data. Excel can sort by more than one column, so you'll want to specify that there's a header column, then sort primarily by ID's and secondarily by time. Then save your Excel sheet. I saved mine as C:\pop2sorted.csv.

Now you can process it into a power graph with the following program. It takes the power consumed between intervals and converts it to an average at the end of the interval.



This program doesn't produce a proper CSV file. The values are actually tab-delimited so you can easily copy-paste into Excel.

Here's what the output should look like in Notepad++:


You can copy-paste it into Excel and select a group of lines having the same ID, but only select the last 2 columns. Then insert a data graph and you should get this:


Now you have a graph showing wattage at various times. This is just the simplest way to do it. Other people have much more elaborate ways of collecting and showing the data.

8 comments:

  1. I did all of the installations but am getting and error of tcp.
    What type of Realtek DVB-T based SDR dongle are you using, USB? Or some other interface
    What OS are you using

    ReplyDelete
    Replies
    1. I had problems on Win10. See https://www.rtl-sdr.com/getting-the-rtl-sdr-to-work-on-windows-10/

      Delete
  2. I used:
    RTL-SDR Blog dongle, v2
    Windows 7 x64

    If RTL-TCP doesn't work, then maybe your dongle drivers aren't installed.

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Thanks for the write up - it was super helpful. Type 12 is indeed a gas meter, at least in my area. I've also found type 1, 5, and 13's but haven't been able to correlate them to a utility yet.

    ReplyDelete
  5. Best write up out there... What antenna are you using? And how do I set the gain? I'm not receiving much.

    ReplyDelete
    Replies
    1. I used a GE passive HDTV antenna from Target. I don't know if they make it anymore but here is an Amazon link. The product images show the version I have but one of the reviews shows a different one.

      https://www.amazon.com/GE-24804-Indoor-Antenna-HDTV/dp/B00EH2C3W0

      I don't know about setting the gain. I didn't have to so it might not be necessary with a good antenna.

      Delete