Electronics project notes/DIY home resource metering

From Helpful
Jump to: navigation, search
This is for beginners and very much by a beginner. It's meant to try to cover hobbyist needs, and as a starting point to find out which may be the relevant details for you, not for definitive information.

Some basics and reference: Volts, amps, energy, power · Ground · batteries · resistors · changing voltage · transistors · fuses · diodes · capacitors · inductors · transformers · baluns · amplifier notes · frequency generation · skin effect


And some more applied stuff:

IO: IO and wired communication · localish communication · wireless (ISM RF, GSM, RFID, more) · 802.11 (WiFi) · 802.15 (including zigbee)


Sensors: General sensor notes, voltage and current sensing · Knobs and dials · Pressure sensing · Temperature sensing · humidity sensing · Light sensing · Movement sensing · Capacitive sensing · Touch screen notes

Actuators: General actuator notes, circuit protection · Motors and servos · Solenoids

Some stuff I've messed with: Avrusb500v2 · GPS · Hilo GPRS · Bluetooth serial · JY-MCU · DMX · ESC/POS notes

Audio notes: basic audio hacks · microphones · amps and speakers · device voltage and impedance, audio and otherwise ·

Less sorted: Common terms, useful basics, soldering · Microcontroller and computer platforms · Arduino and AVR notes · ESP series notes · Electronics notes/Phase Locked Loop notes · mounts, chip carriers, packages, connectors · signal reflection · pulse modulation · Unsorted stuff


See also Category:Electronics.

Electricity

Piggybacking on a digital meter

If you have a digital meter (depends on where you live, and whether you've been upgraded to one yet), that meter can potentiallydo a lot of work for you (and be more accurate than current clamps), if it has either:

  • a LED (visible or IR) that pulses for every so-many kW-hours (or VARh, Volt-Amperes Reactive hour).

and/or

  • an a optical serial port (IEC61107/DIN 66258, IEC 62056-21; see also below), which may potentially be more interesting, but also more work. (see #Notes on IEC 62056-21 for details)



If you have the impulse LED, you'll need to not miss pulses. Probably some simple dedicated hardware (hint: something like an ATTiny is a buck or two).

Our previous meter emitted 10000 pulses per kWh (one pulse = 0.1 Wh, and a 1kW load makes for about ~2.8 flashes per second, a 200Wh load for a flash every ~2.1 sec), each pulse being ~2ms long. Both of those are pretty practical orders of magnitude to listen to and record, and not very hard to do with an Arduino/AVR.

It got replaced by a meter that does 500 imp/kWh (Pulse = 2Wh, a 1kW load means 30 pulses/minute, so 1/sec is an averge of 2kW, one every 10 sec is 200W), each pulse being 40ms long. This means less accuracy in time, which makes near-real-time graph generation a little less exciting, but also means it's harder to miss a pulse (in a microcontroller that isn't completely dedicated).

Current clamp

You can also use a current jaw/clamp.

These refer to any design of current transformers, which are mostly just simple coils that give you a small current proportional to the current on the wire you're snooping on.


However, clamping all directions in a wire will give you a zero reading, so this is only possible if the individual wires are visible at some point, such as one phase of your house, without others or the return cable, or a single wire from an extension cord to measure a single devices or a handful of them.


You're probably using an ADC, so want to see a voltage level proportional to the current from the clamp, so you'll need a simple opamp circuit, such as [1].

Also, being a simple transformer, its output will be AC if its input is AC, which means you either want to sample fast enough to be able to get an RMS, or condition the signal before sampling.

You do have to make more situation-based assumptions, about transformer accuracy and power factor, but though a little calibration goes a long way.


Clamps are regularly seen as part of a multimeter, but if you want to log values (and the multimeter doesn't have data output), you may want to buy a separate clamp and interface it with something.

You can expect to spend EUR 20 on a basic clamp, and a bunch more for the rest of the electronics (op amp, microcontroller dedicated to watching and counting, communication to something. There are other options.)

See projects like:


If you want something shiny and convenient, there are ready-made products, for on the order of 250 EUR (probably less now), which add convenient readout displays, wireless stuff, and such.

A few of these:

You may be able to leech values from some of these for your own graphs (e.g. simple enough in the case of Current Cost).


Pluggable

This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)

For more localized power measurement you can use wall-plug power meters, which are now fairly cheap devices.

A number of these are hackable at some level or other, meaning you can automate data collection. For example, see this Kill-a-watt XBee hack (piggybacks on low-voltage part of the device after sampling; needs soldering), though there are simpler, cheaper, wired alternatives to using XBee.

Gas

Water

Semi-sorted notes

http://www.bwired.nl/


You may like interfacing with phototransistors on an Arduino or so.

Many projects you'll find transmit the data via an XBee, some via ethernet interface. If you like hacking access points, you could perhaps abuse its serial interface.


Metering bus protocol notes

This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)


Between various types of meter reading and other SCADA and telemetry, the protocols that may be involved (the lower half of this list is mostly stuff I came across while searching): (verify)

  • IEC 61107 (which was IEC 1107 before a renumbering)
    • Absorbed into IEC 62056 (its 62056-21 subpart seems mostly equivalent to IEC 61107(verify)), and the IEC considers 61107 to be superseded by 62056(-21). See also below.
    • but still common sort of as just this part, because it's simple(r)
  • IEC 62056 series of standards
    • absorbed DLMS and IEC 61107 (verify)
    • consists of a bunch of parts, more details below
  • ANSI C12.18
  • Power Line Carrier (PLC)
    • Shared local medium, collected by a local data concentrator and sent on to grid operators in whatever way it chooses to(verify)
    • modulation on a frequency in 3kHz..148.5kHz range (see EN 50065-1)
    • range is a few hundred meters, with option to use (meters as?) repeaters as controlled by the concentrator?(verify)
    • Physical layer details: See IEC 61334-5-1, http://en.wikipedia.org/wiki/IEC_61334
  • ZigBee Smart Energy (mostly an interconnection?)



DLMS (Device Language Message Specification), an application layer protocol mostly about communicating object entities, fairly generic. Merged into IEC 65056(verify)

xDLMS - extended form that knows about COSEM?(verify)

There is software that accesses via DLMS/COSEM, though may be somewhat specific to a meter.


Unsorted


See also:

There is various software that can read out DLMS, IEC 62056-21, including

  • MAP110, MAP120 software (from Landis+Gyr)




IEC 62056
This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)

Consists of various parts. Some of the more relevant:

Lower-level parts:

  • IEC 62056-21: local data exchange (is the 3d edition of IEC 61107): COSEM over a optical port or current loop.
    • Has a few different modes that meters can choose to use/implement, see below
  • IEC 62056-46: Data link layer using HDLC protocol (See also [2]) - alternative to more ASCII-over-classical-serial exchange. (Used in 62056-21 mode E?)
  • IEC 62056-42: Physical layer services and procedures for connection-oriented asynchronous data exchange

Abstractions:

  • IEC 62056-62: Interface classes. A model specific for metering that defines named classes, some inheritance, and queryable attributes. The COSEM model's objects are instantiations of these classes(verify). (Seems to mostly be background information that programmers might want to know)
  • IEC 62056-53: COSEM Application layer (where COSEM is the COmpanion Specification for Energy Metering, a application later protocol specific data model for energy metering)
  • IEC 62056-61: Object identification system (OBIS), for domain-specific enumation of things you commonly want to ask for (things in IEC 62056-62 and a few more(verify))

Also related:

  • IEC 62056-47: COSEM transport layers for IPv4 networks (not very common?(verify))
  • IEC 62051:1999, Electricity metering – Glossary of terms


Notes on IEC 62056-21

Physical media for local access is usually a half-duplex serial port affair, often either an optical port (infrared LED + infrared photodiode), or wired (often RS-485?).


There are fancy conformant reader heads but they're damn expensive for what they are. A few components and some creativity you can build your own much cheaper.

If you do: It looks like the IR LEDs are on a 38kHz carrier. The simplest way to send and receive this is probably to buy components that already use that -- and note that TV remote LEDs and their receivers are a good place to start (these seem to usually be 36kHz or 38kHz(verify)).

See also:


Meters often choose to default to a particular mode, and may implement only one. When they do, mode C seems a favourite(verify). They may also prefer a specific speed. This is typically mentioned in the meters's documentation.


The modes:

  • A (initial mode, until otherwise negotiated)
    • ASCII based protocol
    • all parts at 300 baud, 7N1(verify)
    • readout, programming
  • B
    • ASCII based protocol
    • starts at 300 baud, has baud switching
    • readout, programming
  • C
    • ASCII based protocol
    • starts at 300 baud, has baud switching
    • readout, programming
    • adds optional security, manufacturer-specific functionality
    • allows partial block communication (...which is?)
  • D
    • ASCII based protocol
    • fixed at 2400 baud throughout
    • readout only (the only mode that isn't bidirectional, initiated by a button or such)
  • E


A baud switch, requested or not, will only happen when acknowledged/dictated by the meter. In mode B it seems to be a command, in mode C the readout hardware can ask for another rate(verify).

Standard baud rates are 300, 600, 1200, 2400, 4800, 9600, and 19200. (Further rates can be defined by specific meters, but will have to be mentioned by their documentation, and implemented by readout hardware)

All modes except D (possibly E depending on implementation?) allow you to switch to programming (after readout?). Programming mode is due to one of various security levels and their conditions - basic alterations may require a password, some things may require the meter being opened at the time (which is considered tampering, and registered as such in the meter). Don't do that. ...but you generally need not worry about changing something without meaning to, because even the meters without particularly good security aren't that bad...


Optical interface

The optical interface has an IR transmitter (LED) and receiver (photodiode) side by side (with some standard-specced distances, isolation from environment light, separation between LED and photodiode, etc.)

The commercial things that fit onto many meters many have a magnet for convenient temporary attachment. There seems to be no physical means (e.g. notches) of aligning the led/photodiode. The heads presumably mark how they should be positioned (typically wire down?)


  • half duplex communication
  • led off is SPACE, transmitting a 38kHz pulse sequence is MARK(verify)


Protocol

Modes A, B, C, and D resemble each other, but vary in details like baud switching, exact commands, and sequence.


An ASCII line-base protocol, using CRLF line termination, largely readable characters, and using some control codes for specific functions, including:

  • 0x06 is ACK, acknowledge
  • 0x02 is STX, frame start
  • 0x03 is ETX, end of block
  • 0x01 is SOH, start of heading


References to BCC are a Block Check Character, a single character that acts as a checksum of the data block just sent. This seems to be ISO/IEC 1155:1978, also known as LRC (longitudinal redundancy check)(verify). This checksums bytes starting at the first STX or SOH (excluding it), up to the ETX character (including it). Calculation is apparently(verify):

  • value=0
  • for each byte in buffer:
    • value = value XOR byte (which is equivalent to adding and and-masking with 0xff)
  • value = ((value XOR 0xff) + 1) AND 0xff (...apparently.)


Mode C

Request for setup (at 300 baud) to a specific device ID, usually 1(verify)

  • /?1!

Returns device identification, which consists of

  • 3 characters: manufacturer string
  • 1 character: baud rate
  • rest of line: device ID?


Mode switch request (still at 300 baud)

  • ACK (that is, 0x06)
  • 0 (character, i.e. 0x30)
  • character indicating baud rate we wish for (choices listed somewhere below)
  • mode to enter - 0 for readout, 1 for programming mode, 2 for manufacturer specific mode

e.g.

  • ACK 050 for readout at 9600 baud
  • ACK 000 for readout at 300 baud.


The meter pauses (how long?) to allow the baud rate switch.


In the case of data readout, meter sends data readout, structured like:

0x02 data ! 0x03 BCC

Data readout is a sequence of lines, mentioning OBIS (62056-61) identifiers. Meters choose which of the possible identifiers they use, and may (and often do) add some of their own.



Reducing power/utility usage

This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)