Hacker News new | past | comments | ask | show | jobs | submit login

Funny you should mention this. I just set this up myself... I have a meter measurement about every 30 seconds, which it gets plotted into a cool web graph that shows usage as well as consumption spikes and I can set alerts and such. Pretty cool.

For anyone who's curious, here's the hardware:

1. A "smart meter" outside the house (set up by the power company) 2. A raspberry pi 3 (w/power cable/sdcard) 3. NooElec NESDR Mini 2+ software defined radio http://www.nooelec.com/store/sdr/sdr-receivers/nesdr-mini-2-... This comes with an antenna as well.

And here's the software:

* Ubuntu Mate on the rpi3 (you can also use raspbian or whatever) * rtlamr to take readings from the meter (https://github.com/bemasher/rtlamr -- this is awesome and worked on the first try after I installed golang and ran "go get github.com/bemasher/rtlamr") * rtl-tcp (a dependency of the above that is automatically installed if I remember correctly.) * openhab2 open source home automation sw (optional) * influxdb open source time series database * grafana graphing software

Once I plugged the USB NooElectric SDR, I was able to grab my meter's reading with a little python3 script. The test code I'm using looks something like:

    completed = subprocess.run(['/home/myaccount/go/bin/rtlamr', '-filterid=1234567', '-single=true', '-format=json'],
        stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
    data=json.loads(completed.stdout.decode("utf-8"))
    reading = data['Message']['Consumption']
This gives you the reading for your meter. Change the -filterid to use the number physically written on your meter outside.

I wanted to be able to visualize trends (like the rate of consumption when I turned on the heat) using a nifty chart, so I published from python (via the paho library-- https://pypi.python.org/pypi/paho-mqtt ) to a local mqtt server (mosquitto running on the pi) though I also tried sending to a mqtt feed at io.adafruit.com, which does a neat graph on its dashboard... until I overwhelmed its quota with too-frequent updates. I wanted something faster where I didn't have to worry about any throttling.

So I decided to do it all locally. First, I set up openhab2 (http://docs.openhab.org/) which has an add-on to to automatically read the mqtt feed, then inserted the measurements to a database on a local influxdb (https://en.wikipedia.org/wiki/InfluxDB) server also on the pi which keeps a real-time history (aka "persistence") of my electric usage over time. (I could have also just inserted to the influxdb directly from my python3 script, but I'm playing with openhab2 for other things so had it do it for me...)

Finally, I connected grafana (http://grafana.org/) to the influxdb database. Now I have gorgeous real-time graphs and an amazing interactive web-UI that lets me zoom in and set alerts and such.

It sounds like a lot of steps to get to the graph, and once you have the actual measurement, you have choices on how to visualize it-- you could have python send the readings to a Google Sheets spreadsheet and graph from there, for example. or do updates to adafruit less frequently to not blow through the quota. Or use openhab2's which includes its own charts.

But grafana's visualizations are just the coolest. See http://play.grafana.org for an idea of what you can do...

Anyway, long drawn out answer, but the point is-- assuming you have a smart electric meter that work with rtlamr, you can do this yourself :)




wow, this post inspired me to look at that SDR, and I had no idea SDR had gotten so cheap. Last time I looked was a couple years ago, and anything halfway decent was 100+. Suffice it to say, I just ordered one, and I'm going to look at building a similar setup, though as I'm rather familiar with Go, probably as a single binary that does recording and web display as a single thing.


Yeah you don't need all the levels that I used :) I've been playing around to figure the best way to do it and integrate it with everything else, so I figured I'd list everything I've tried in case someone wants to play with them.

Update: Just found this at the top of the discussion at http://bemasher.net/rtlamr/ -- which I actually should probably sit down and read at some point :)

https://gist.github.com/bemasher/7af275c3d2fd3f02933e7990e8e...


I just wrote up https://gist.github.com/andyleap/01601cc9cdf7d3708bb63d5867a... real quick, uses the rtlamr stuff directly and turns around and spits them into a local influxdb instance. It's been working out fairly well so far! I'd still like to make it more "all in one" down the road, but influxdb + grafana is a good start for the display side of things.


That's pretty cool!

Can rtlamr send text over TCP to a remote data collection server? I think they call it a 'receiver'.

Looks like different formats are supported, e.g. plain and csv, so it's a pretty open setup. With that in mind, what's the added value of mqtt in your reference configuration?


Well, when I was using adafruit's mqtt server it gave me quick real-time access to the data on the web with its dashboard graphing stuff. Ie, doing the hard work for me. It's not really necessary to do it this way, you could go straight to influxdb or whatever, but I'm using mqtt for other things w/openhab, so... you could easily skip using mqtt if you wanted to simplify things.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: