Arduino EmonLib Project - Please help me avoid doing stupid things

I’m pretty deep in Arduino, and was excited to see EmonLib. I’ve been reading through this site the past few days, and I’m starting to get a feeling that using many sensors can be pretty complex. So, I wanted to tell you about my planned setup to get your thoughts.

Objective: Monitor approximately 25 circuits to:

  • Identify where we’re spending our money
  • Charge the basement tenants based on their usage (roughly at least). It doesn’t have to be super accurate, but we want to get away from the flat-rate rental fee (and especially the “free electricity” mindset.)

My current test setup

  • emonLib
  • Arduino Mega 2560 r3
  • ESP8266 receives serial data from Mega and publishes online
  • One SCT-013-000, 33 ohm burden resistor

The values I’m getting for a 120VAC circuit are good enough. I can tweak it a little, but this setup seems to be working for one sensor at least.

My plan
This is where I may be getting over-ambitious. I plan on hooking up at least 15 sensors, maybe all 25 if a multiplexer works. If I am limited to 15, then I’ll duplicate the setup.

Questions

  1. Do I need to account for additional sensors for US 240VAC, or can I wrap the SCT around both “hot” wires?
  2. Limits to the number of sensors: I was reading an article here about emonTx where somebody wanted a bunch of sensors. It seems like in the end, since all he cared about was apparent power, it was OK to use a bunch on one Arduino. (now that I’m trying to find the link, I can’t find it, so take that sentence with a grain of salt. I may have misread something)

I think that’s all for now. I will have questions as I go along, but wanted to make sure I’m headed in some sort of right direction.

  1. Have you read the page in Resources > Building Blocks about using the emonTx in N.America? You’re not using an emonTx of course (except an emonTx is more-or-less an Arduino with one voltage and 4 current inputs all on one pcb) but most if not all of that page will apply to you.

  2. How and to what accuracy do you want to measure? EmonLib as it stands samples the voltage & current for a short period (nominally 200 ms, you can have what you like, but ideally it must be an exact number of mains cycles) every so often. In your case, “every so often” probably means 25 × 200 ms plus a bit for overheads like switching the multiplexer and sending the data. (That’s actually still faster than the emonTx on battery power or sending to emoncms.org, which reads every 10 s.) What that means in practice is the consumption of each circuit is only known at discrete moments, which is OK if the load is more or less constant, but a problem if you have something that switches rapidly, like an induction hob.

I think if you accept the limitations, and with care, it’s feasible.

Note, EmonLib drives the multiplexer in the ATMega 328P via “analogRead( )”. If you’re having an external multiplexer (as well?), you’ll need to customise your copy of emonLib.

Good call about the 200x25 and understanding the limitations. Also, good point about EmonLib handling the AnalogRead()s. I’ll check out that code and maybe settle with doing 2 Arduino setups.

After reading more late last night, I’m going to try a local emonCMS on a Pi connected via ethernet. That looks like it will save a lot of work!

Also, after reading more, I am under the impression that it’s reasonable to measure only 1 leg of the 240v circuits and multiply by 2. However, this would be an inappropriate method for measuring the mains since those legs would vary wildly, so I’ll only use this method for the individual circuits.

Buuuuut, this does bring up a new thought. Two of the 240v breakers are feeders for subpanels. I’d like to measure the current at the this (feeder) level rather than the subpanels. So, it seems that for those, I ought to measure each leg.

Are you talking about the voltage balance, or the current balance, between the two legs? As I’m in the UK and we use a straightforward single phase system in domestic properties, I’ve no experience of this.

USians have reported that the voltage balance is good, hence measuring one leg and doubling where appropriate would make things a lot easier (and from what you first wrote, you’re not too bothered about an error of a couple of percent). But it’s your decision, you need to base it on what you see in your installation.

But if you’re talking current, then that’s a dangerous assumption, and would depend on how well whoever did the installation and assigned the various circuits, anticipated how and where the users would use their electricity! You can really only measure one leg of a 240 V circuit if you know that the neutral current is negligible or zero.

Here’s the topic I was reading that’s relevant: monitoring AC voltage in the US | Archived Forum

As for balance, the 240v circuits I’d only measure one leg on, are ones that are single-appliance. Like, air conditioner, hot water heater, bandsaw, table saw, jointer, dust collector, oven, dryer etc.

The 240v circuits where I’d measure both legs would be the ones where current consumption may vary based on leg: Feeder circuit for basement subpanel, feeder for garage subpanel, etc.

I ought to research the power usage characteristics of the 240v appliances that have 4 wires: In somewhat recent years, the wiring for ranges/ovens/dryers has changed from 3 wire (hot, hot, ground) to 4 wire (hot, hot, neutral, ground). I have a hunch that parts of newer appliances might operate on 120v (therefore only use one of the hot conductors). But, if so, it’s likely the control panel. Surely, the heating elements still use 240v. I’ll research before relying on this assumption.

I think that’s a pretty safe bet - the only point where it might go badly wrong is if they use multiple heating elements and switch between 240 & 120 V to the same element (to get ¼ power), and I can’t see that as being likely. But it’s possible. We tend to achieve the same thing in a slightly different way - 1 element or 2 elements in series or 2 in parallel, giving ½, ¼ or full power.

If I were designing a control panel that might be used in 120 V and 240 V appliances, it’s a no-brainer: run the controls off 120 V; it saves having two sets of parts, 2 assembly operations, 2 sets of stock in the stores, and the possibility of shipping the wrong one.

Hi Keith,

(I’m in the US as well, so thought I’d offer some input)

Quite correct. Take a clothes dryer for example. The heater does indeed use 240V, the timer, display etc. (if so equipped) operate from 120V.

Same for a stove or oven, or any other 240V appliance that has a dispay, clock, timer, etc.

Thanks for the verification.

Here’s a new question that might need to be factored into this. I’m aware that some motors (especially compressors) have an initial very high current draw. Breakers are designed to be able to handle this (a 20A breaker will not trip by an air compressor drawing 50A for a split second before running at 15A).

My question is: What’s the duration of this spike typically? Like, if my air compressor spikes at 50A then runs for 3 minutes drawing 15A, I imagine the spike may be missed by the analogRead(). Does the spike make a huge difference for a 3 minute runtime? If the spike matters much, I’d be interested in planning ways to account for that. Even if it’s a separate Arduino to poll more frequently. If it will only throw off the calculations 20% or less, I’m not worried about it.

Again, things don’t have to be completely accurate, just relational. In fact, I might as well be measuring in units of unicorns. As long as I can see that I’d save 2 unicorns per hour if I remember to turn off the bandsaw brake, or 4 unicorns per hour if I track down the air compressor hose leak, or 7 per hour if I am unnecessarily using a dehumidifier in the basement, then I’m in good shape. If we miscount unicorns by 20% it’s not a big deal.

That’s almost like “How long is my piece of string?” - it depends totally on the motor, the load and what proportion above normal running current you define as a spike. I think you’d be hard done by if it makes an appreciable difference over 3 minutes, but given your initial assumptions, if its duration is less than 10 s and it happens just after a sample, you’ll miss it. If it happens just before, you’ll assume (emoncms will assume) that it’s 50 A falling linearly to 15 A over 10 s.

But having written that, I came across a centrifuge with a star-delta starter that required 30 mins on star before switching to delta, even though the current had apparently stabilised after less than 10 mins.

If I find one of your unicorns browsing on my front lawn, I’ll let you know. :sunglasses:

You might find EmonESP useful: GitHub - openenergymonitor/EmonESP: ESP8266 WIFI serial to emoncms link

I think the dryer drum motor is typically 120V too, and unlike the electronics, it’s a significant enough load that a 2x or 0x error might start to add up.

Yep. Forgot about the motor. It’s definitely a 120V device too.

2x error, I’ve got a handle on.

0x?

As Ricky Ricardo so often said, “'splain me Lucy!” (from the I Love Lucy TV show)

If you put a CT around one leg and double it, then if you pick the leg that has the drum motor connected you’ll accidentally double its power consumption (2x), but if you pick the other leg you’ll never see that consumption (which I shortened to a 0x, i.e. times 0 error)

And there’s no way out of that, short of threading the second leg through the original CT or using a second CT, but that still leaves any error resulting from voltage imbalance.

D’oh! (as hand smacks forehead)

Thanks dB!

Ok, so 2 sensors for the voltage-imbalanced 240v circuits it is. Thanks for the advice.

I’m much further along in my project now. This whole Emon system is great. I have a question about timings.

Above, we discussed sample timings. Here’s a note from you in post number 2.

This appears to be quite accurate.

In my Arduino loop, I currently have the [pseudo] code:

loop {
  read sensor;
  display on OLED screeen;

  if (ten seconds has passed since last publish){
    publish via mqtt; (on local pi via ethernet)
  }
}

May I simplify by doing this?

loop {
  read sensor;
  display on OLED screeen;
  publish via mqtt; (on local pi via ethernet)
}

I realize that publishing once every 250ms would be absurd. But, when I have 15 sensors hooked up to 1 Arduino, each sensor’s value would get published once every 3-4 seconds.

If that’s ok, how does that affect the process engine in EmonCMS? PHPFINA vs PHPTIMESERIES? Currently I’m using PHPFINA @ 10 second intervals for no educated reason other than that looked right.