Current Cost Power-o-meterThis is a featured page

This is the idea as shown in this flickr video:
http://www.flickr.com/photos/barnybug/2604903353/

The Arduino is connected to the CurrentCost data on pin 2.
It uses the led on pin 13 (by default the built-in led on the board) to indicated receiving data and then externally connected coloured leds on pins 9-12 for the actual meter.

This is the sketch for the Arduino. You can adjust the watt levels that trigger the leds or add or reduce the number of leds used easily.
It could be easily adapter to output the watt values on the USB serial out, for example.
Have fun!
/*
* CurrentCost serial reader
*
* BG / 23rd June 2008
*/

#include <SoftwareSerial.h>

#define rxPin 2
#define ledPin 13

SoftwareSerial mySerial = SoftwareSerial(rxPin, 3);
byte pinState = 0;
char startPattern[] = "<ch1><watts>";
char endPattern[] = "<";
int state = 0;
int pos = 0;
int power = 0;
int wattLevels[] = { 0, 200, 400, 800, 2000, 99999999 };
int wattPins[] = { 12, 11, 10, 9, 8 };

void setup()
{
Serial.begin(9600);

pinMode(rxPin, INPUT);
pinMode(ledPin, OUTPUT);

for (int i = 0; i < 5; ++i)
pinMode(wattPins[i], OUTPUT);

mySerial.begin(2400);
}

byte readByte = 0xFF;

void loop()
{
readByte = mySerial.read();
if (readByte == 0xFF) {
digitalWrite(ledPin, LOW);

}
else {
Serial.print(readByte, BYTE);
gotByte();
digitalWrite(ledPin, HIGH);
}
}

void gotByte() {
if (state == 0) {
if (readByte == startPattern[pos]) {
++pos;
if (startPattern[pos] == 0) {
// finished matching start pattern
++state;
power = 0;
}
}
else {
pos = 0;
}
}
else if (state == 1) {
if (readByte == endPattern[0]) {

// finished reading power
// light up lights
int i = 0;
while (wattLevels[i] < power) {
digitalWrite(wattPins[i], HIGH);
++i;
}

// and clear remaining
while (i < 5) {
digitalWrite(wattPins[i], LOW);
++i;
}

state = 0;
}
else {
// read another digit
power = power * 10 + readByte - '0';
}
}


}




Posted Anonymously Latest page update: made by Anonymous , Sep 9 2008, 8:49 AM EDT (about this update About This Update Posted Anonymously Edited anonymously

20 words added
1 word deleted

view changes

- complete history)
More Info: links to this page
Started By Thread Subject Replies Last Post
Anonymous cc128 3 Sep 6 2009, 6:18 AM EDT by Anonymous
 
Thread started: Feb 13 2009, 1:55 PM EST  Watch
i would like to know where to buy cc128 meter i coudnt find it anywhere.thank you
1  out of 6 found this valuable. Do you?    
Keyword tags: None (edit keyword tags)
Show Last Reply

Anonymous  (Get credit for your thread)


Showing 1 of 1 threads for this page