Energiemeter

From VoidWarranties - Hackerspace Antwerp, Belgium
Revision as of 10:21, 1 October 2014 by Warddr (Talk | contribs)
Jump to: navigation, search


Energiemeter
What:
We zijn bezig met het uitzoeken van de werking van AC current clamps, en hoe we ze kunnen gebruiken om het stroomverbruik van de space in kaart te bregen. Hier is de progress.
Event.png
Participants:
warddr, Berz
Category:
Electronics
Locations:
Den Bunker

Contents

10 maart

5V ----- 330kR ------ 330kR ----- GND -----
                 |                 |      |
                 |                 |      |
                 |                 |      |
             SPOEL p1 --------- 100nF -- 10µF
                 |
                 |
                 |
                68R
                 |
                 |
                 |
A1 --------- SPOEL p2


code

arduino

void setup() {
  Serial.begin(115200);
}
void loop() {
  Serial.println(analogRead(A0));
}

python

from serial import Serial
from matplotlib import pyplot
import time

def millis(): #give current time in miliseconds
    return int(round(time.time()*1000))

ser = Serial('/dev/ttyACM0',115200,timeout=2)
ser.open()
start = millis()               
x=[]
y=[]
while True:
            mytime = millis()-start
            reading = ser.readline()

            if ((mytime > 3250) and (mytime < 3500)):
                x.append(mytime)
                y.append(reading)
            if (mytime>3500):
                break
ser.close()

pyplot.plot(x, y, '-' )
pyplot.show()

for idx,item in enumerate(x):
        print (str(x[idx]) + ";" + str(y[idx]))

resultaten

onbelast

Noload.png RAW: File:Noload.txt

160mA

160mA.png RAW: File:160mA.txt

4,22A

4A22.png RAW: File:4A22.txt

7,78A

7A78.png RAW: File:7A78.txt


10 maart

void printDouble( double val, unsigned int precision){
   Serial.print (int(val));  //prints the int part
   Serial.print("."); // print the decimal point
   unsigned int frac;
   if(val >= 0)
       frac = (val - int(val)) * precision;
   else
       frac = (int(val)- val ) * precision;
   Serial.println(frac,DEC) ;
} 

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

void loop() {
 const double samples=2500;
 const int vermenigvuldigmet = 155;
 double averageABS = 0;
 for(int I=0; I<samples; I++){
   averageABS += (double(abs(analogRead(A0)-512)))/samples;
 }
 printDouble(averageABS,100); //gemiddelde lezing
 printDouble(averageABS*vermenigvuldigmet,1000); //gemiddelde stroom
 printDouble(225*((averageABS*vermenigvuldigmet)/1000),1000); //gemiddelde VA
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox
Content Creation
Belgian Spaces