Serial Volt/Amp meter

Moderator: Mattk

Post Reply
pterodyne
Fresh Boarder
Fresh Boarder
Posts: 17
Joined: Tue May 01, 2012 7:46 pm

Serial Volt/Amp meter

Post by pterodyne »

Hello all. Loving this setup for weather. Ive also hacked my nlsu2 to have two more USB ports and added usb/serial adapters to read the output of my Solar/battery system (I use 2 wattsview serial power meters). Knowing nothing about perl programming Im at a bit of a loss on how to set these up. Currently this is what I have done:

seeing that

Code: Select all

cat /dev/ttyUSB0
(or ttyUSB1) will output:

Code: Select all

00016.3V-00013.4A 00218.2W 00557.5WH
I ipkged netcat and made some simple user scripts

Code: Select all

./scripts/charge
and

Code: Select all

./scripts/load
:

Code: Select all

while true; do nc -i 10 -l -p 8082 < /dev/ttyUSB0 ; done
Using two scripts I put them in one script to call both using

Code: Select all

./elec
. Im not a shell programmer either so Im not certain how to make both devices be read sequentially from one script. Frankly I'm amazed I've gotten this far!

Either way I'm at the point where I either need to get this done right as a "plugin" for meteohub or at the very least get the scripts cleaned up and auto starting at bootup. Graphing would be nice, but at this point I just need to check the status. I don't know how it would be accomplished but rewriting the ASCII output from the power meters to extract Volts and Amps would be nice and make graphing easier.

Just really an exploratory post at this point.

Anyone have any thoughts? Id put a small bounty out if someone wanted to write a script for me and help me get it working

Thanks for any comments!

Bryan
pterodyne
Fresh Boarder
Fresh Boarder
Posts: 17
Joined: Tue May 01, 2012 7:46 pm

Re: Serial Volt/Amp meter

Post by pterodyne »

Ok.. while looking through other threads I have made progress at least with my knowledge.. Here is what I am trying as a user plugin

Code: Select all

#! /bin/sh
#
while :
do
  # pull data from website and filter the needed string
  gawk 'BEGIN {FS=""} ; {print $5$6$7$8}' /dev/ttyUSB1
  # make sure output gets flushed
  sync
  # wait 30 seconds for next read
  sleep 30
done
Just trying to limit it to voltage part of the output. Because the entire output of cat /dev/ttyUSB1 looks like this:
00013.3V-00002.0A 00026.8W 00512.4WH


the gawk command above does limit it to 13.3 which is the voltage. Probably an easier way to write that than I did.

Nothing shows up on the sensors page though.

Using this:

Code: Select all

#! /bin/sh
#
while :
do
  # pull data from website and filter the needed string
  wget -O /dev/stdout "http://www.wetter.com/deutschland/sylt_ost/DE0010330.html" 2>/dev/null | grep "deg text_l temp_w" | gawk 'BEGIN {FS=">"} {print $3}' | gawk 'BEGIN {FS="&"} {printf "t9 %d\n", lround ($1 * 10.0)}'
  # make sure output gets flushed 
  sync
  # wait 30 seconds for next read
  sleep 30
done
From this page:
viewtopic.php?p=9951#p9951

I suspect the sensor is defined as t9 from this

Code: Select all

 {printf "t9 %d\n", lround ($1 * 10.0)}
Lost now.. brain hurts, although I have learned a ton today about awk

How do I get the sensor to show up on the sensors page? Remember my data types will be Voltage and Amperage. I could also do calculations to arrive at Watts or Watt Hours using awk (I think). If I can get this to work, I will just define 4 different plugins and have each one graph with a defined graph. This will work for me.
Post Reply