The CurrentCost is a device to
monitor electricity usage, with the particularly interesting aspect being
that it has a serial port to connect it to a PC to log/analyze the data.
I bought a USB cable from CurrentCost's ebay store
which arrived quickly and works well with FreeBSD - I assume it would work with Linux too, it didn't when
I quickly tried it but I think I didn't have the right kernel module loaded. On FreeBSD you need the ucom and uplcom
modules, and the cable works on my old FreeBSD 5.5 machine. I think the pl2303 module is needed on Linux but I didn't get
as far as trying it.
Update: Since writing this I have moved my currentcost monitoring to a Linux
box and it does indeed work correctly with the pl2303 module loaded.
Then comes the interesting bits, how to read the data, and what to do with it.
Firstly I started submitting the data to an existing system
for tracking household spending/utility usage etc, The Tracker.
I created an SQLite database to store the data:
#!/bin/sh
# Create the SQLite DB
if [ -f sqlite.db ]; then
echo "Error: sqlite.db already exists"
exit 1
fi
sqlite3 sqlite.db <<EOF
CREATE TABLE readings (
id INTEGER PRIMARY KEY AUTOINCREMENT,
ts datetime,
device_time time,
watts int(11),
temp double,
device_offset int(11),
ts_delta double(8,2),
joules int(11)
);
create index ts_index on readings(ts);
EOF
Initially I used MySQL but since my MySQL server is a separate machine from the one with the CurrentCost connected,
I figured it made more sense to keep it all on one machine, and SQLite saves the overhead of running MySQL.
Additionally, to create pretty graphs, I store the data into an RRD file as described
at http://www.jibble.org/currentcost/.
Then I run a perl script
to read the data from the serial port and update both databases. The code is based
on the perl code at http://www.jibble.org/currentcost/
too.
To make sense of the data, I use a simple PHP page, deliberately keeping the output
very simple so it works on my pocket PC.
For the curious, here's a preview of the web output.
The database looks something like this:
+-----+---------------------+-------------+-------+------+---------------+----------+--------+
| id | ts | device_time | watts | temp | device_offset | ts_delta | joules |
+-----+---------------------+-------------+-------+------+---------------+----------+--------+
| 391 | 2008-10-14 19:49:41 | 19:42:41 | 2288 | 15 | -420 | 6.05 | 13833 |
| 390 | 2008-10-14 19:49:35 | 19:42:35 | 2290 | 15 | -420 | 5.98 | 13701 |
| 389 | 2008-10-14 19:49:29 | 19:42:29 | 2359 | 15 | -420 | 5.95 | 14031 |
| 388 | 2008-10-14 19:49:23 | 19:42:23 | 2218 | 15 | -420 | 6.01 | 13339 |
| 387 | 2008-10-14 19:49:17 | 19:42:17 | 2280 | 15 | -420 | 25.03 | 57062 |
| 386 | 2008-10-14 19:48:52 | 19:41:53 | 2228 | 15 | -419 | 4.95 | 11024 |
| 385 | 2008-10-14 19:48:47 | 19:41:47 | 2193 | 15 | -420 | 11.96 | 26228 |
| 384 | 2008-10-14 19:48:35 | 19:41:35 | 2209 | 15 | -420 | 23.93 | 52868 |
| 383 | 2008-10-14 19:48:11 | 19:41:11 | 2288 | 15 | -420 | 18.98 | 43422 |
| 382 | 2008-10-14 19:47:52 | 19:40:53 | 2216 | 15 | -419 | 10.93 | 24227 |
| 381 | 2008-10-14 19:47:41 | 19:40:41 | 2340 | 15 | -420 | 5.77 | 13507 |
| 380 | 2008-10-14 19:47:35 | 19:40:36 | 2303 | 15 | -419 | 30.85 | 71048 |
| 379 | 2008-10-14 19:47:05 | 19:40:06 | 835 | 15 | -419 | 16.87 | 14083 |
| 378 | 2008-10-14 19:46:48 | 19:39:48 | 833 | 15 | -420 | 6.04 | 5031 |
| 377 | 2008-10-14 19:46:42 | 19:39:42 | 832 | 15 | -420 | 11.92 | 9920 |
| 376 | 2008-10-14 19:46:30 | 19:39:30 | 849 | 15 | -420 | 18.09 | 15357 |
| 375 | 2008-10-14 19:46:12 | 19:39:12 | 833 | 15 | -420 | 18.97 | 15800 |
| 374 | 2008-10-14 19:45:53 | 19:38:54 | 849 | 15 | -419 | 17.08 | 14505 |
| 373 | 2008-10-14 19:45:36 | 19:38:36 | 834 | 15 | -420 | 5.98 | 4984 |
| 372 | 2008-10-14 19:45:30 | 19:38:30 | 831 | 15 | -420 | 5.95 | 4941 |
| 371 | 2008-10-14 19:45:24 | 19:38:24 | 825 | 15 | -420 | 5.95 | 4907 |
| 370 | 2008-10-14 19:45:18 | 19:38:18 | 836 | 15 | -420 | 6.01 | 5024 |
| 369 | 2008-10-14 19:45:12 | 19:38:12 | 828 | 15 | -420 | 7.07 | 5856 |
| 368 | 2008-10-14 19:45:05 | 19:38:06 | 823 | 15 | -419 | 28.92 | 23798 |
| 367 | 2008-10-14 19:44:36 | 19:37:36 | 822 | 15 | -420 | 17.90 | 14714 |
| 366 | 2008-10-14 19:44:18 | 19:37:18 | 826 | 15 | -420 | 5.98 | 4938 |
| 365 | 2008-10-14 19:44:12 | 19:37:12 | 826 | 14.9 | -420 | 12.92 | 10671 |
| 364 | 2008-10-14 19:43:59 | 19:37:00 | 817 | 15 | -419 | 10.95 | 8949 |
| 363 | 2008-10-14 19:43:48 | 19:36:48 | 828 | 15 | -420 | 24.08 | 19937 |
| 362 | 2008-10-14 19:43:24 | 19:36:24 | 2359 | 14.9 | -420 | 6.01 | 14185 |
+-----+---------------------+-------------+-------+------+---------------+----------+--------+
This data highlights the only minor problem with the device - it quite
often doesn't receive the broadcasts from the meter unit, which should be
every 6 seconds, however I think the data should be accurate enough. Also the clock on my device is 7 minutes slow, but that is
not a major concern.
Links
| Comments |
|---|
No comments have been posted yet.
|
|