digital-car.co.uk    

Go Back   digital-car.co.uk > General > Off Topic

Reply
 
Thread Tools Display Modes
Old 10-03-2010, 12:39 PM   #1
Gepard
Advanced Member
 
Join Date: Dec 2006
Posts: 5,162

Gepard will become famous soon enoughGepard will become famous soon enough
Current Cost Envi

I'll put all the dev work I do with mine in this thread but others feel free to add with your own meters.

My one is the Current Cost Envi: http://www.currentcost.com/products.html Installation takes less than 5minutes and it updates ~4-6 seconds. It shows a bar graph for the usage divided into night day and evening. Total cost, total consumption, temperature of the room, time, energy now and cost per day based on current usage levels. It can also read individual appliance sensors which I think are on there way....

The device has a transmitter that wrapps around a single core power cable that goes into your meter. And the receiver/display has an AC cord attached. Can't say anything about range...I'm in a fairly new house.

I'm currently working on a computer interface to get, read, retieve and monitor usage. The device connects through a special USB cable. It plugs into the back via a RJ45 jack and has a USB connector the other end. The USB connector is mounted to a circuit board that contains Prolific USB->Serial adapter suggesting the device outputs serial data as standard. Haven't worked out whether it's true RS232, 5V TTL or 3.3V levels.

This contains info on the pinout: http://www.techtoniq.com/forum/viewtopic.php?f=5&t=385

The device comes up in device manager as a virtual COM port and as standard the protocol settings are 57600,8,N,1. These seemed to be fixed and older version run at 9600.

The device outputs a string every 6 seconds:
Code:
<msg><src>CC128-v0.11</src><dsb>00027</dsb><time>19:55:10</time><tmpr>21.3</tmpr><sensor>0</sensor><id>04064</id><type>1</type><ch1><watts>00326</watts></ch1></msg>
<msg><src>CC128-v0.11</src><dsb>00027</dsb><time>19:55:16</time><tmpr>21.3</tmpr><sensor>0</sensor><id>04064</id><type>1</type><ch1><watts>00325</watts></ch1></msg>
<msg><src>CC128-v0.11</src><dsb>00027</dsb><time>19:55:27</time><tmpr>21.2</tmpr><sensor>0</sensor><id>04064</id><type>1</type><ch1><watts>00324</watts></ch1></msg>
<msg><src>CC128-v0.11</src><dsb>00027</dsb><time>19:55:33</time><tmpr>21.3</tmpr><sensor>0</sensor><id>04064</id><type>1</type><ch1><watts>00324</watts></ch1></msg>
<msg><src>CC128-v0.11</src><dsb>00027</dsb><time>19:55:39</time><tmpr>21.3</tmpr><sensor>0</sensor><id>04064</id><type>1</type><ch1><watts>00323</watts></ch1></msg>
<msg><src>CC128-v0.11</src><dsb>00027</dsb><time>19:55:45</time><tmpr>21.3</tmpr><sensor>0</sensor><id>04064</id><type>1</type><ch1><watts>00324</watts></ch1></msg>
<msg><src>CC128-v0.11</src><dsb>00027</dsb><time>19:55:51</time><tmpr>21.3</tmpr><sensor>0</sensor><id>04064</id><type>1</type><ch1><watts>00323</watts></ch1></msg>
<msg><src>CC128-v0.11</src><dsb>00027</dsb><time>19:55:57</time><tmpr>21.3</tmpr><sensor>0</sensor><id>04064</id><type>1</type><ch1><watts>00323</watts></ch1></msg>
<msg><src>CC128-v0.11</src><dsb>00027</dsb><time>19:56:03</time><tmpr>21.3</tmpr><sensor>0</sensor><id>04064</id><type>1</type><ch1><watts>00326</watts></ch1></msg>
Which breaks down to:


//start of message
<msg>
//device ID
<src>CC128-v0.11</src>
//unknown
<dsb>00027</dsb>
//time on device
<time>19:55:10</time>
//room temperature in C
<tmpr>21.3</tmpr>
//sensor number (3 phase has multiple sensors on each phase)
<sensor>0</sensor>
//sensor ID
<id>04064</id>
//phase number
<type>1</type>
//current power consumption
<ch1><watts>00326</watts></ch1>
//end of message
</msg>

The device also has a history function that supports the download of the past few days of data stored in the device. So you can leave it running, then connect up your computer and get all the data. Instead of having 6 second accuracy though it drops down to bi-hourly.



I'm currently experimenting with my own software. Although you can buy/download software from the Current Cost website:

http://www.currentcost.com/software-downloads.html

VB6's MSCOMM control can't read from the port without crashing the program however .net doesn't seem to have this problem.

I'm currently using Tera Term's log function which takes all data from the serial port and saves it to a text file. I then use the following Excel Code to read the text file line by line.

Code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ImportTextFile
' This imports a text file into Excel.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Sub ImportTextFile(FName As String, Sep As String)

Dim RowNdx As Long
Dim ColNdx As Integer
Dim TempVal As Variant
Dim WholeLine As String
Dim Pos As Integer
Dim NextPos As Integer
Dim SaveColNdx As Integer

Application.ScreenUpdating = False
'On Error GoTo EndMacro:
'MsgBox ActiveCell.Row
'MsgBox ActiveCell.Column


SaveColNdx = 4 'ActiveCell.Column
RowNdx = 3 'ActiveCell.Row

Open FName For Input Access Read As #1

While Not EOF(1)
    Line Input #1, WholeLine
    If Right(WholeLine, 1) <> Sep Then
        WholeLine = WholeLine & Sep
    End If
    If InStr(1, WholeLine, "hist") <> 0 Then GoTo end2
    ColNdx = SaveColNdx
    Pos = 1
    NextPos = InStr(Pos, WholeLine, Sep)
    While NextPos >= 1
        TempVal = Mid(WholeLine, Pos, NextPos - Pos)
        Cells(RowNdx, ColNdx).Value = TempVal
        Pos = NextPos + 1
        ColNdx = ColNdx + 1
        NextPos = InStr(Pos, WholeLine, Sep)
    Wend
    RowNdx = RowNdx + 1
end2:
Wend

EndMacro:
On Error GoTo 0
Application.ScreenUpdating = True
Close #1
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' END ImportTextFile
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End Sub
'Since ImportTextFile takes input parameters, it should be called from other VBA code:

Sub DoTheImport()
ImportTextFile FName:="C:\Users\Gepard\Desktop\teraterm.log", Sep:="|"
End Sub
Once in the worksheet you have the whole string which needs the relevent data extracted. You can do this with the MID function:

Power: =MID(<<string>>,141,4)
Time: =MID(D3056,50,5)
Temperature: =MID(D3056,71,4)

The text value that that gives needs to be converted to a numerical value for plotting using this nested functions:

=VALUE(TRIM(CLEAN(<<cell>>)))

This can then be used to give you a graph:



The whole process is done using a timer function:

Code:
' *********************************************************************
' Excel VBA Timer Example v1.00
' Copyright ©2002 by Sebastian Thomschke, All Rights Reserved.
' http://www.sebthom.de
'*********************************************************************
' If you like this code, please vote for it at Planet-Source-Code.com:
' http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=34409&lngWId=1
' Thank you
'*********************************************************************
' WARNING: ANY USE BY YOU IS AT YOUR OWN RISK. I provide this code
' "as is" without warranty of any kind, either express or implied,
' including but not limited to the implied warranties of
' merchantability and/or fitness for a particular purpose.
'*********************************************************************
' You are free to use this code within your own applications, but you
' are expressly forbidden from selling or otherwise distributing this
' source code without prior written consent.
' *********************************************************************
Option Explicit

Dim timer_enabled As Boolean
Dim timer_interval As Double


' *********************************************************************
'  your code goes into this Makro
' *********************************************************************
Sub Timer()
    ' output the current time to cell D13
    'Range("K11").Value = CStr(Time)
    Tabelle1.DoTheImport
End Sub


' *********************************************************************
'  internal timer methods
' *********************************************************************
Sub timer_OnTimer()
    Call Timer
    If timer_enabled Then Call timer_Start
End Sub

Sub timer_Start(Optional ByVal interval As Double)
    If interval > 0 Then timer_interval = interval
    timer_enabled = True
    If timer_interval > 0 Then Application.OnTime (Now + timer_interval), "Timer_OnTimer"
End Sub

Sub timer_Stop()
    timer_enabled = False
End Sub

Code:
' *********************************************************************
'  internal timer methods
' *********************************************************************
Sub timer_OnTimer()
    Call Timer
    If timer_enabled Then Call timer_Start
End Sub

Sub timer_Start(Optional ByVal interval As Double)
    If interval > 0 Then timer_interval = interval
    timer_enabled = True
    If timer_interval > 0 Then Application.OnTime (Now + timer_interval), "Timer_OnTimer"
End Sub

Sub timer_Stop()
    timer_enabled = False
End Sub

The interval is set to 5 seconds. So the data/graph is near enough live.

Last edited by Gepard; 10-03-2010 at 12:44 PM.
Gepard is offline   Reply With Quote
Old 10-03-2010, 12:55 PM   #2
ccsnet
DC Organiser
 
ccsnet's Avatar
 
Join Date: Feb 2004
Location: Morecambe, Lancs, UK ( Just For The Moment )
Posts: 16,590

ccsnet will become famous soon enough
Subbed.... still waiting on the gas sensor info.

One point to make remember the goal is to the info but not go mad on the power or cost getting there or whats the point as your no better off ?

Terran
__________________

ccsnet is offline   Reply With Quote
Old 10-03-2010, 01:03 PM   #3
Gepard
Advanced Member
 
Join Date: Dec 2006
Posts: 5,162

Gepard will become famous soon enoughGepard will become famous soon enough
Tbh not sure I have a goal atm.....I find it quite interesting to see how it goes up and down with applicances/people etc.
Gepard is offline   Reply With Quote
Old 10-03-2010, 04:20 PM   #4
teamCBA
Advanced Member
 
teamCBA's Avatar
 
Join Date: Oct 2006
Location: Midlands
Posts: 5,746
teamCBA will become famous soon enough
Subbed too, nice idea, although the irony of having to have computer running to see how you can save money is not lost on me
__________________
teamCBA is offline   Reply With Quote
Old 10-03-2010, 04:35 PM   #5
Gepard
Advanced Member
 
Join Date: Dec 2006
Posts: 5,162

Gepard will become famous soon enoughGepard will become famous soon enough
You can use the history function though so you don't need it on 24/7 ;)
Gepard is offline   Reply With Quote
Old 10-03-2010, 04:35 PM   #6
teamCBA
Advanced Member
 
teamCBA's Avatar
 
Join Date: Oct 2006
Location: Midlands
Posts: 5,746
teamCBA will become famous soon enough
30 quid for the unit so far, know of any lower ?
__________________
teamCBA is offline   Reply With Quote
Old 10-03-2010, 04:39 PM   #7
Gepard
Advanced Member
 
Join Date: Dec 2006
Posts: 5,162

Gepard will become famous soon enoughGepard will become famous soon enough
Nope

Remember as well you need the cable....unless you want to have a go at rolling your own?
Gepard is offline   Reply With Quote
Old 11-03-2010, 12:28 PM   #8
Scouse Monkey
Advanced Member
 
Scouse Monkey's Avatar
 
Join Date: Sep 2004
Location: Bristol
Posts: 26,822

Scouse Monkey will become famous soon enough
is it not just a £7 cat 5 cable? :o
Scouse Monkey is offline   Reply With Quote
Old 11-03-2010, 12:33 PM   #9
Gepard
Advanced Member
 
Join Date: Dec 2006
Posts: 5,162

Gepard will become famous soon enoughGepard will become famous soon enough
Nope - unfortunately!

Quote:
Originally Posted by Gepard View Post
I'm currently working on a computer interface to get, read, retieve and monitor usage. The device connects through a special USB cable. It plugs into the back via a RJ45 jack and has a USB connector the other end. The USB connector is mounted to a circuit board that contains Prolific USB->Serial adapter suggesting the device outputs serial data as standard. Haven't worked out whether it's true RS232, 5V TTL or 3.3V levels.
Gepard is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Forum Jump
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT +1. The time now is 12:58 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Website Hosted by
www.wicked-websites.co.uk