Projects/Power Meter: Difference between revisions
< Projects
mNo edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Project | {{Project | ||
|name=Power Meter | |name=Power Meter | ||
|start=2012-07-07 | |||
|end=2012-07-15 | |||
|contact=Gebruiker:Zarya | |contact=Gebruiker:Zarya | ||
|info=Bitlair Power meter | |info=Bitlair Power meter |
Revision as of 12:15, 24 July 2012
Project Power Meter | |
---|---|
Name | Power Meter |
Start | 2012-07-07 |
End | 2012-07-15 |
Contact | Gebruiker:Zarya |
Website | |
Information | Bitlair Power meter |
Status | Productie"Productie" is not in the list (Alpha, Beta, Production, Finished, Abandoned) of allowed values for the "Project status" property. |
- Meter url https://stats.bitlair.nl/
Code
#include <WProgram.h>
#include <inttypes.h>
#define MS_PER_HOUR 3.6e6
int cycles_per_kwh = 100;
int max_watt = 6000;
unsigned long previous = 0;
unsigned long cycle = 0;
boolean last = LOW;
void kwhChange() {
unsigned long now = millis();
unsigned long time = now - previous;
if (cycle == 0) {
cycle++;
return;
}
// digitalWrite(13,last);
previous = now;
double W = 1000 * ((double) MS_PER_HOUR / time) / cycles_per_kwh;
Serial.print("Cycle ");
Serial.print(cycle, DEC);
Serial.print(": ");
Serial.print(time, DEC);
Serial.print(" ms, ");
Serial.print(W, 2);
Serial.println(" W");
cycle++;
if (last) last = LOW;
else last = HIGH;
}
void setup () {
Serial.begin(57600);
pinMode(13, OUTPUT);
attachInterrupt(0, kwhChange, FALLING);
}
void loop () {
digitalWrite(13,digitalRead(2));
}
Pictures
-
Meter
-
Electronic