SpacePowerMeter
Since we use quite a bit of power in the space, and this costs a boatload of moneys... it would be handy to have some insight into the powerusage.
In the beginning of july, we received a new power meter in the space, which is of the more modern 'blinky' kind, as opposed to the spinning wheel. By measuring the amount of blinks from the led, we can electronically read-out the amount of power used.
A ATtiny85 is connected to the ttyUSB0 of gateway, and measures the led-blinks coming from the DRM370A 3-phase power meter using a LDR. The ATtiny will send 'PULSE' over a 9600 baud serial connection every time the led on the powermeter flashes.
The powermeter flashes it's led 400 times per kWh, so with this information we can calculate our power usage. (We need to figure out X here, one specsheet says 160, the other 400, the other 800, it should be on the meter itself, google-screenshot says 400)
On gateway, a perl-script monitors the serial port, and logs the amount of received pulses in a logfile... later this will also go to rrdtool or something
Some Observations
*PPM* | *Watts* | *Situation* |
3-4 | 600 | Space closed (so only servers, emergency light, cooling, other permanent infra |
8 | 1200 | Background usage, space open, lights on in handwerklokaal |
16 | 2400 | Space open, lights on in lounge, hallway and handwerklokaal |
Code for the attiny85
The code for the attiny85 was written using arduino-tiny (arduino addon for attiny family).
/* Analog input, serial output Reads an analog input pin, prints the results to the serial monitor. */ #define SAMPLECOUNT 40 #define DEBOUNCE 40 #define SAMPLEDELAY 20 void setup() { Serial.begin(9600); } void loop() { unsigned int c = 0; // Sample counter int value; // Last value read int high = 980; int low = 850; int last; int ignore = 0; while( 1 == 1) { c++; // read the analog input into a variable: value = analogRead(A2); // print the result: if ( value > high ) { last = 1; ignore = c; // Serial.print( "Debug high: " ); // Serial.println(value); } else if( value < low ) { // if ( last == 1 ) // { // Serial.println( "High to low transition..." ); // } // Serial.print( "Debug LOW: " ); // Serial.println(value); if ( c > ignore ) { Serial.println( "PULSE" ); ignore = c + DEBOUNCE; } // else // { // Serial.println( "Still in debounce..." ); // } last = 0; } // else // { // Serial.print( "DEBUG... MIDDLE VALUE ?!?!?!?!"); // Serial.println( value ); // } // wait X milliseconds for the analog-to-digital converter // to settle after the last reading: delay(SAMPLEDELAY); if ( c > 65500 ) { c = 0; } } }