Raspberry Pi and FTDI USB (or Serial)

For more advanced meter data users. Learn from others and ask questions about how to read meters, how to use the EKM Push Data, and how to display the meter data in useful ways.
flyrjh
Posts: 4
Joined: Wed Nov 19, 2014 8:58 pm

Raspberry Pi and FTDI USB (or Serial)

Post by flyrjh »

My goal: Read my OmniMeter v4 from a Raspberry Pi, either with the FTDI/USB adapter, or the serial converter. I have both, USB would be preferred but either is fine.

I have read for hours on this forum, and there's a lot of great information, but I'm not having much success yet.

Could anyone point me in a more productive direction? I'm about ready to buy an iSerial and just try that code, as I've seen several examples that look workable.

C, python, and shell are all very familiar, although maybe rusty at times. I have tried reading and writing in each with no luck; I understand 7-E-1 can be a problem but I've done my best to set these, seems really hard to debug when you're just getting nothing back.

If I could at least get some data from the device I could look into the algorithms scattered in the forum.

Thanks for any advice or pointers,

Joe
flyrjh
Posts: 4
Joined: Wed Nov 19, 2014 8:58 pm

Re: Raspberry Pi and FTDI USB (or Serial)

Post by flyrjh »

Well, after posting this I'm finally getting data in C. I think it was just missing O_RDWR. Hopefully over the next few weeks I can get it parsed and post some sample code, curious how many people might be interested. Looking forward to rrdtools next! And maybe posting to a google spreadsheeet, we'll see. -Joe
Jameson
Posts: 860
Joined: Fri Nov 04, 2011 7:42 pm
Location: Santa Cruz, CA
Contact:

Re: Raspberry Pi and FTDI USB (or Serial)

Post by Jameson »

Hello Joe, Welcome to the forum!!

Very cool to hear about your raspberry pi project. That would be great if you wanted to post your code here for others to take a look at and/or contribute to.

Here is a discussion on the forum that somewhat relates to the raspi: http://forum.ekmmetering.com/viewtopic. ... erry#p3429

My recollection is that he had quite a cool setup. We are interested in a standalone, low power, data logging solution (to an SD card or dropbox folder) that the raspberry pi could potentially provide.

I am curious to follow your progress :D
Jameson
EKM METERING
http://www.ekmmetering.com
831.425.7371
flyrjh
Posts: 4
Joined: Wed Nov 19, 2014 8:58 pm

Re: Raspberry Pi and FTDI USB (or Serial)

Post by flyrjh »

Jameson, thanks! I've been looking forward to this step for many months, and reading many of your very kind replies.

What I've done is to write a little C program that reads USB/RS-485 data, and prints the parts I wanted. Then, I have a shell script that calls it every minute, parses the output, and calls the wattvision API to let them handle graphing. Google docs would be easy enough; or dropbox, but for mine I'm writing to a local SAN, just an old hard drive, to avoid wearing out the SD card over the next few years.

I found a RasPi site that gave me a good start at reading RS-485, which turns out to be fairly simple with your USB dongle. Then, I found some v3 struct code on the EKM forum here, and I updated that to the v4 specs. Finally I put the CRC bits in, un-swapped the endian bits from the other system's code, and it actually verifies.

So it's a fairly simple setup; no iSerial required, and it's been running all day now without any hiccups. It can query up to twice per second if you put it in a tight loop, far more than most people should need. (another post)

There's yet another post I ran across that's using rrdtools for graphing that I'd like to try next, since wattvision only does power and I want to add water and gas. Looks like he was using iSerial too.
http://forum.ekmmetering.com/viewtopic. ... =rrd#p5970

I'll try to clean the code up over the next few days and post more progress. Thanks for the encouragement, if I hadn't read your past interest I might not have been so persistent last night!

Joe
Jameson
Posts: 860
Joined: Fri Nov 04, 2011 7:42 pm
Location: Santa Cruz, CA
Contact:

Re: Raspberry Pi and FTDI USB (or Serial)

Post by Jameson »

Hi Joe,

Yes we are super encouraging of this kind of project. Our philosophy is: the more ways our users can access their meter data the better.

Yeah teaming up with what he has here: http://forum.ekmmetering.com/viewtopic. ... erry#p3429 could be a match made in heaven. :mrgreen:

I would love to see how your water meter and gas meter graphs turn out!

Thanks again,
Jameson
EKM METERING
http://www.ekmmetering.com
831.425.7371
advansis
Posts: 2
Joined: Fri Feb 06, 2015 2:51 pm

Re: Raspberry Pi and FTDI USB (or Serial)

Post by advansis »

Hi Joe
How's progress? I'd love to hear more about your setup
vintozver
Posts: 6
Joined: Tue Oct 23, 2018 3:48 pm

Re: Raspberry Pi and FTDI USB (or Serial)

Post by vintozver »

I have a production setup. I used Andino Pi (Raspberry Pi 3 B+ inside, plus RTC, plus RS485 converter, plus Atmel chip).
Currently access the meter using RS485 but atmel chip is also capable of counting the impulses.

Andino Pi is powered by 12V 2A DC power source, everything is on DIN rail ...

I also created a small FCGI script and setup nginx so I'm able to access the meter data and access it using REST.

The setup works quite well and stable.
nielo
Posts: 10
Joined: Wed Aug 27, 2014 7:45 pm

Re: Raspberry Pi and FTDI USB (or Serial)

Post by nielo »

Dunno if anybody is interested but if they are I'm willing to share.
The screen shot is a chart generated on a system running on a Raspberry Pi 3B+ that is collecting data from two EKM Meters (a v3 and a v4). It shows generation from my solar panels, power in/out from the utility (HELCO - Hawaiian Electric Light Co) and usage.

The data is stored in a Maria database located on my Synology Server. Data is collected every 30 seconds and request/response takes about 450 ms for each meter via a 900 mhz radio link. Eventually I plan on collecting much more data, everything from the power used by my hot tub to the temperature of my pool. For devices that are not EKM meters (for instance pool pH, temperature, REDOX) I plan on using Arduinos outputting on a RS485 buss that is connected to a Digi ZigBee 900 mhz radio. Finally, the software was written in "Lazarus", a free version of Pascal similar to Delphi (I'm not a big fan of C or any of its derivatives.)
The attachment chart.png is no longer available
Attachments
chart.png
chart.png (154.46 KiB) Viewed 28445 times
Jameson
Posts: 860
Joined: Fri Nov 04, 2011 7:42 pm
Location: Santa Cruz, CA
Contact:

Re: Raspberry Pi and FTDI USB (or Serial)

Post by Jameson »

Damn! That is so cool! Great work. Are you pushing all of your data to a remote server with your Raspberry Pi, or is some of it stored locally? Feel free to post github links if you have them.

Anyway, very cool to see!
Jameson
EKM METERING
http://www.ekmmetering.com
831.425.7371
nielo
Posts: 10
Joined: Wed Aug 27, 2014 7:45 pm

Re: Raspberry Pi and FTDI USB (or Serial)

Post by nielo »

The data is stored on a local server. I haven't made the data available on the web because, at least so far, I haven't had the need to do that. I haden't though about putting anything on GitHub but maybe I will eventually... after I clean up the code a bit. ;)

I'm still having some minor issues with the radios (Digi Xbee 900 mHz) occasionally receiving an incomplete packet, and very occasionally getting a bad CRC. The v4 meter is located about 100 ft from the radio and the v2 meter is about 3 ft. Both are connected via cat 5e to a RS485 board supplied by EKM. I didn't use shielded wire and, for a couple reasons, I think the radio may be messing with the RS485 signal. I should hook up my O-Scope and look at the signal but so far I've been too lazy to do that.
Post Reply