jackkelly / snd_card_power_meter Goto Github PK
View Code? Open in Web Editor NEWAn electricity meter using a sound card to digitise signals from current transformer probes and AC-AC adapters.
An electricity meter using a sound card to digitise signals from current transformer probes and AC-AC adapters.
modify watsup._parse_wu_line()
and scpm.calibrate()
e.g. mains_2013-03-12_14.dat
Put watts up and calculated power over each other
After closing the wav file, of course!
I think the easiest way to do this might be something like this:
There are Python audio libraries e.g.:
But I don't want to have to load the entire previous file into memory in Python. Instead I want to just fire off an ffmpeg instance to compress the file.
Check audioop source code to make sure it down samples
replace most of the print()
statements with log
statements
e.g.
wattsup: [error] Blech. Giving up on read: Bad address
wattsup: [error] Reading final time stamp: Bad address
"volts" -> "voltage" if it isn't in units of volts
"amps" -> "current" if it isn't in units of amps!
If sox
isn't installed then we just get this error:
13-03-16 09:00:01 WARNING start WARNING: Previous conversion FAILED: sox --no-dither vi\
-1363417200.348878.wav --bits 24 --compression 8 vi-1363417200.348878.flac rate -v -L 1\
6000 && rm vi-1363417200.348878.wav
13-03-16 09:00:01 INFO start Running: sox --no-dither vi-1363420800.549942.wav --bits 2\
4 --compression 8 vi-1363420800.549942.flac rate -v -L 16000 && rm vi-1363420800.549942\
.wav
Why don't we get the full error message?
and update name of exceptions
-rw-r--r-- 1 root root 187M Mar 30 17:05 vi-2013_03_30_16_00_00_636767.flac
-rw-r--r-- 1 root root 189M Mar 30 18:05 vi-2013_03_30_17_00_00_450238.flac
-rw-r--r-- 1 root root 190M Mar 30 19:05 vi-2013_03_30_18_00_00_669354.flac
-rw-r--r-- 1 root root 193M Mar 30 20:05 vi-2013_03_30_19_00_00_889285.flac
-rw-r--r-- 1 root root 194M Mar 30 21:05 vi-2013_03_30_20_00_00_64461.flac
-rw-r--r-- 1 root root 189M Mar 30 22:05 vi-2013_03_30_21_00_00_817415.flac
-rw-r--r-- 1 root root 187M Mar 30 23:05 vi-2013_03_30_22_00_00_759095.flac
-rw-r--r-- 1 root root 187M Mar 31 00:05 vi-2013_03_30_23_00_00_999147.flac
-rw-r--r-- 1 root root 2.1G Mar 31 02:33 vi-2013_03_31_00_00_00_962376.wav
jack@jack-logger:/usr/local/logger/snd_card_power_meter$ tail *.log
13-03-31 05:27:27 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-31 05:27:27 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-31 05:27:41 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-31 05:27:41 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-31 05:28:01 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-31 05:28:01 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-31 05:28:02 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-31 05:29:15 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-31 05:29:20 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-31 05:29:28 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
probably a BST problem
But mixer settings must be loaded before calibration.
Run both V and i together
The current (I) data is just too nuts to try to calculate a phase difference using zero crossings or peaks.
One possible solution:
For 1 second of data, try to fit the voltage waveform to the current waveform using audioop.findfit()
.
BEFORE PUTTING ANY EFFORT INTO THIS: see if SMETS 2 specifies four quadrant recording or not
more portable
Texas Instruments have a 7-page PDF on "current-transformer phase-shift compensation and calibration" using a digital finite impulse response (FIR) filter: http://www.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sl...
jack@dave-logger:/usr/local/logger/snd_card_power_meter/scripts$ sudo ./plot.py
13-04-09 19:29:48 INFO Starting up...
13-04-09 19:29:48 INFO Opening Sampler...
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
13-04-09 19:29:48 INFO Successfully opened Sampler.
13-04-09 19:29:48 INFO Running sampler...
13-04-09 19:29:48 INFO Opening calibration file...
13-04-09 19:29:48 WARNING Error loading option from config file: No section: 'Calibration'
13-04-09 19:29:49 INFO Terminating Sampler
Traceback (most recent call last):
File "./plot.py", line 38, in <module>
main()
File "./plot.py", line 29, in main
adc_rms, calibration)
File "/usr/local/logger/snd_card_power_meter/snd_card_power_meter/scpm.py", line 152, in calculate_calibrated_power
data.real_power = inst_power.mean() * calibration.watts_per_adc_step
AttributeError: 'NoneType' object has no attribute 'watts_per_adc_step'
13-03-16 09:01:53 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-16 09:14:29 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-16 09:17:17 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-16 09:19:36 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-16 09:21:35 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-16 09:22:13 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-16 09:25:06 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-16 09:26:18 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-16 09:26:37 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-16 09:37:56 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
13-03-16 09:47:06 WARNING get_adc_data ERROR: [Errno Input overflowed] -9981
Both internally and for output
Makes it less ambiguous that this is UTC. And easier to handle programmatically.
Just need to modify config.py
?
Manually move it on my Atom PC.
Also move it on Dave's PC (if it's still there in college!)
WAV files cannot be larger than 4GB: http://en.wikipedia.org/wiki/WAV#Limitations
e.g. vi_2013-03-12_14-15-23.178384.flac
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.