Projects/Power Meter: Difference between revisions
< Projects
mNo edit summary |
mNo edit summary Β |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Project | {{Project | ||
|name=Power Meter | |name=Power Meter | ||
|contact= | |start=2012/07/07 | ||
|contact=Zarya | |||
|info=Bitlair Power meter | |info=Bitlair Power meter | ||
|status= | |status=Production | ||
|Picture=Zarya_15155.jpg | |||
|end=2012-07-15 | |||
}} | }} | ||
* Meter url https://stats.bitlair.nl/ | |||
== Code == | == Code == | ||
Line 56: | Line 60: | ||
Image:Zarya_15157.jpg| Electronic | Image:Zarya_15157.jpg| Electronic | ||
</gallery> | </gallery> | ||
== Schema == | |||
[[Bestand:Pocircuit.png|200px]] |
Latest revision as of 19:15, 21 April 2013
Project Power Meter | |
---|---|
Name | Power Meter |
Start | 2012/07/07 |
End | 2012-07-15 |
Contact | Zarya |
Website | |
Information | Bitlair Power meter |
Status | Production |
- 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