Power meter

Hi all,
I came across this nice little power meter today(however pricy …) :
It has TTL output, and should therefore be able to communicate with openhab true rules and the serial binding. Or does someone out there have better suggestion on how to cheaply integrate power measurment to openhab, with a minimum of soldering and new coding? It would be nice to log the power consumption on each of my circuit breaker(17 in total), Hence the version that you plug into your socket would not work, since several of appliances are connected directly to the circuit breaker(oven top, heating cables etc).

I am slowly working on something based on an ESP8266 and a Cirrus CS5490. (or its bigger brother to get more channels, haven’t decided yet). My idea with this is to easy be able to get the readings from the distributing panel, and into the network, by having the ESP8266 connect to WiFi.

The biggest problem is when it will actually be ready. Some other things has come up which needs more attention, and it will most likely be a lot more expensive than the one you linked to too. :wink:

This firmware for esp8266 already support powermeter.
U can get the readings from power monitor to mqtt or simple http-get.

Thanks, i think I will try to get a few of those modules, and test them out. Do you have some tutorial for esp8266 in english? Seems like they are easy to use and that I can get temperature nodes, gpio(3?) to work with them.

No tutorial :smile: . Here the demo.
Register, check options u need, press button ‘create firmware’, download it, flash the esp8266.
All setting is on esp web page.
To enter safe mode you must connect rx & tx or 3 times press reset button on esp.
When you enter safe mode, you can adjust network settings from web browser (192.168.4.1).
Connect sensors, and setup it web page.
Finally you get data from any sensors to mqtt topic or Reading GET request sensors at IP_ADRESS/sensors . Sensor readings are separated by a semicolon.

Here list of metrics translated to mqtt.

So i can buy this one and get it up running by attaching battery and a dht22 sensor to it? How did you bind it to openhab?

Thanks

Yes, but better use esp12 it has more memory. That firmware has a deep sleep mode for use with batteries.

If you are looking for accuracy, such a solution will not work and you would need an RMS capable energy meter. You can get these to go into the electrical panel and plug the load in inline (often up to 16A) without the need of current transformers. Afterward, to get the data from them, the cheapest option is by pulse counting the pulse outputs of the meters, otherwise you can do something like a multi-drop RS-485 Modbus RTU network to connect back to the serial port on your controller.

I ordered one of these to test as well, was thinking about making a shield that can read in 10 of them. Do you think that sensor has to low accuracy as well?

It really depends on what you are trying to accomplish, what your needs are, budget, time, etc. etc. etc.

Me personally, I wouldn’t spend the effort building what you are talking about. A friend of mine loves the idea however as it is a relatively cheap way of better understanding electrical power use. Let me expand SOME of the potential benefits and challenges.

The Pros to your approach

  • A lot of the benefits of energy management can be gained from the shape of the load curve (when, how long, what does the consumption profile look like). If you are metering many loads, its not really essential that you know exactly how many RMS Watt hours they have each consumed.

  • Should you be interested in having accurate consumption values; you can just create a multi-tiered metering setup where you have one or more accurate (revenue-grade?) energy meters which have low accuracy sub-meters installed below them. (I use the utility meter as my accurate meter)

The Cons to your approach

The biggest thing is that error will be accrued throughout the measurement chain; a bit here for this reason, a bit there for that reason, and could end up being quite significant with your final values. Here are some examples of where error will come from:

  • In order to have an accurate power or energy measurement you need to have RMS voltage and current measurements. They are by no means the same as just plucking an instantaneous value off of a current sensor every once in awhile and averaging them over time. Here are some links comparing average vs. RMS 1 2 3.

  • Aside from RMS sensors… keep in mind that without knowing the voltage, you can’t calculate power. And this changes over time so imaging that it is a constant like 115VAC or 230VAC is simply wrong. There is also sensor sensitivity and accuracy. CTs (current transformers) are meant to be sized accordingly for the circuits they measure in order to provide good accuracy. Putting a 100A CT on a 16A circuit which only really has 5A maximum going through it would provide very poor accuracy as it is in the bottom 5% range of the CT… looking at your CT, it says 3% accuracy between 10-120%. As the accuracy is non-linear, measuring below 10A (10%) could have anything like 10-30% error introduced. You need small CTs to measure small loads, bigger ones for bigger loads. My whole house never draws more than 40A!!

  • Next in the chain is the input of the analog signal. This split-core CT doesn’t say what its output range is, but that would need to either match the input range, or be smaller so that you can measure the range of the sensor. It probably uses millivolts, but using a more common industrial example, if you have a 4-20mA sensor (0-100% range) plugged into a 0-25mA input, you are losing precision due to unused 4mA upfront and 5mA afterward… meaning you never use 9mA of your 25mA input channel, or 36%! This compounds the fact you may only be using a tiny range of your current sensors range.

  • Once the analog signal is received, it needs to be converted to digital using an ADC. The precision of this input will determine how many possible digital values you will have in relation to your analog values. The larger the number of bits used, more digital values, meaning smaller increments can be measured and so you’ll have a greater precision of knowing when the analog signal changes slightly. An 8-bit analog input gives you 255 digital values, and 16-bit gives you 65535. So as your analog value changes linearly and gradually, you will see steps on the digital value. The number of steps determine the level of visibility you have on the analog value. So imagine measuring 0-10A on this CT with an imaginary 8-bit analog input (imagining the signal and input were perfectly matched) - 0A=0 0.5A=1 1A=2… I’m sort of guessing, but that gives you an idea. So, not possible to measure any changes below around half an amp. Obviously a different story if the input was 16-bit.

  • Then there is the software, and there are many parts of the measurement chain in the software as well, but the biggest one will be time and frequency. The current value will probably be bouncing all over the place, so an instantaneous reading will mostlikely be useless. You’ll need to do signal processing like a low-pass filter or running average on the incoming values which you read quickly. Then you’ll need to do any planned power and energy calculations that you have in mind… problem being that you can’t do much with only a current value.

This is why I am a believer in spending money on RMS energy meters (not just power); as pretty much all of these issues go away and then you just read the meter. :smiley:

I am also of the mindset of focusing the effort on what you do with the data, rather than spending all your effort on just getting it.

Take a look at the Cirrus Logic CS5490. It it purpose build for exactly this, and got I2C, so it can tell a micro what it figures out. :smiley:

1 Like

So, now I have managed to get an arduino code which reads out the power from my meter by reading out the blinking frequency of it.

My arduino code can be found here:

Has anyone of you integrated power measurement into OH? How does the items and sitemap look like? What should I send out on the serial port from the arduino so that OH can use it:
Currently I am sending this:

  Serial.print(power);
    Serial.print(' ');
    Serial.println(pulseCount * whPerPulse);  // watt hour elapsed

So now when I have the total power usage I thought about moving on to measure every single fuse I have.
So have these two pole fuses:

So I was thinking about measure the voltage as @geva suggested and the current( 16A max), what components should I pick for a cheap and easy setup ? Since I now have the total amount of power I can use that to calibrate the sensors right?

My idea is using this arduino:
http://www.arduino.org/products/boards/4-arduino-boards/arduino-due
since it has higher adc resolution than other arduino boards.

I would like to store power consumption of my appliances over a year span, then look at the data and see where I can save money. Should I buy new more energy efficient appliances or rather not… Dryer,Washing machine,hvac, oven top, oven, dishwasher, water heater, fridge and underfloor heating has their own fuse thats why I can Install it directly in the fusebox and measure it right there.

Here is the power / energy part of my items file:

Number                  Chart_Period                    "Chart Period"                          <clock>         (Charts)
Group                   Chart_Power                     "Power Draw"                            <energy>        (Charts)

/* ENERGY */

Number Energy_Apparent_Power                                    "Power TeleinHTTP [%d VA]"      <energy>        (Energy, Chart_Power)   { http="<[http://localhost:8353/PAPP:60000:REGEX((.*?))]" }
Number Energy_Active_Power_Inst                                 "Inst. Active Power [%d W]"     <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/ActivePowerInst:state:REGEX((.*?))]" }
Number Energy_Current                                           "Current [%d A]"                <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/Current:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/Current:state:*:REGEX((.*?))]" }

Number Energy_Apparent_Power_MQTT                               "Power [%d VA]"                 <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/ApparentPower:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/ApparentPower:state:*:REGEX((.*?))]" }
Number Energy_Apparent_Power_MQTT_Smoothed                      "Power Smoothed [%d VA]"        <energy>        (Energy, Chart_Power)   { mqtt="<[local-broker:/node-red/ENERGY-V1/ApparentPowerSmoothed:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/ApparentPowerSmoothed:state:*:REGEX((.*?))]" }
Number Energy_Active_Power                                      "Active Power 5min [%d W]"      <energy>        (Energy, Chart_Power)   { mqtt="<[local-broker:/node-red/ENERGY-V1/ActivePower:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/ActivePower:state:*:REGEX((.*?))]" }

Number Energy_Apparent_Power_MIN                                "Power MIN. [%d VA]"            <energy>        (Energy, Chart_Power)   { mqtt="<[local-broker:/node-red/ENERGY-V1/ApparentPowerMIN:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/ApparentPowerMIN:state:*:REGEX((.*?))]" }
Number Energy_Apparent_Power_MAX                                "Power MAX. [%d VA]"            <energy>        (Energy, Chart_Power)   { mqtt="<[local-broker:/node-red/ENERGY-V1/ApparentPowerMAX:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/ApparentPowerMAX:state:*:REGEX((.*?))]" }
Number Energy_Apparent_Power_AVG                                "Power AVG. [%d VA]"            <energy>        (Energy, Chart_Power)   { mqtt="<[local-broker:/node-red/ENERGY-V1/ApparentPowerAVG:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/ApparentPowerAVG:state:*:REGEX((.*?))]" }

Number Energy_Active_OffPeak                                    "Off-peak Energy [%d Wh]"       <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/RealEnergyOffPeak:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/RealEnergyOffPeak:state:*:REGEX((.*?))]" }
Number Energy_Active_OnPeak                                     "On-peak Energy [%d Wh]"        <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/RealEnergyOnPeak:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/RealEnergyOnPeak:state:*:REGEX((.*?))]" }
Number Energy_Active_Total                                      "Total Energy [%d Wh]"          <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/RealEnergyTotal:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/RealEnergyTotal:state:*:REGEX((.*?))]" }

Number Energy_Subscribed_Power                                  "Subscribed Power [%d kVA]"     <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/ElecSubscribedPower:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/SubscribedPower:state:*:REGEX((.*?))]" }
String Energy_Tarif_Period                                      "Tarif Period [%s]"             <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/ElecTarifPeriod:state:REGEX((.*))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/TarifPeriod:state:*:REGEX((.*))]" }
String Energy_Contract                                          "Energy Contract [%s]"          <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/ElecContract:state:REGEX((.*))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/EnergyContract:state:*:REGEX((.*))]" }
String Energy_Meter_ID                                          "Elec. Meter ID [%s]"           <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/ElecMeterID:state:REGEX((.*))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/MeterID:state:*:REGEX((.*))]" }

Number Energy_Daily_Cost_Total                                  "Daily Cost [%.1f E]"           <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/DailyTotalCost:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/DailyTotalCost:state:*:REGEX((.*?))]" }
Number Energy_Daily_Consumption_Total                           "Daily Consumption [%d Wh]"     <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/DailyTotalConsumption:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/DailyTotalConsumption:state:*:REGEX((.*?))]" }
Number Energy_Daily_Consumption_OnPeak                          "Daily OnPeak Consumption [%d Wh]"      <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/DailyTotalOnPeakConsumption:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/DailyTotalOnPeakConsumption:state:*:REGEX((.*?))]" }
Number Energy_Daily_Consumption_OffPeak                         "Daily OffPeak Consumption [%d Wh]"     <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/DailyTotalOffPeakConsumption:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/DailyTotalOffPeakConsumption:state:*:REGEX((.*?))]" }

Number Energy_Interval_Cost                                     "Interval Cost [%d Wh]"         <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/Cost:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/Cost:state:*:REGEX((.*?))]" }
Number Energy_Interval_Consumption_Total                        "Interval Consumption [%d Wh]"  <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/Consumption:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/Consumption:state:*:REGEX((.*?))]" }
Number Energy_Interval_Consumption_OnPeak                       "Interval OnPeak Consumption [%d Wh]"   <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/OnPeakConsumption:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/OnPeakConsumption:state:*:REGEX((.*?))]" }
Number Energy_Interval_Consumption_OffPeak                      "Interval OffPeak Consumption [%d Wh]"  <energy>        (Energy)                { mqtt="<[local-broker:/node-red/ENERGY-V1/OffPeakConsumption:state:REGEX((.*?))]", mqtt=">[local-broker:/BMS/OPENHAB-V1/Things/ElectricMeter/OffPeakConsumption:state:*:REGEX((.*?))]" }

And the sitemap:

                Text item=Energy_Active_Power_Inst label="Electric Demand [%d W]" {
                        Frame {
                                Text item=Energy_Active_Power_Inst
                                Text item=Energy_Active_Power
                                Text item=Energy_Apparent_Power
                                Text item=Energy_Apparent_Power_MQTT
                                Text item=Energy_Apparent_Power_MQTT_Smoothed
                                Text item=Energy_Daily_Cost_Total
                                Text item=Energy_Daily_Consumption_Total
                                Text item=Energy_Daily_Consumption_OnPeak
                                Text item=Energy_Daily_Consumption_OffPeak
                        }

                        Frame {
                                Selection item=Chart_Period label="Chart Period" mappings=[0="4 Hours",1="8 Hours",2="12 Hours",3="24 Hours",4="3 Days"]
                        }

                        Frame label="Energy Demand" {
                                Chart item=Chart_Power period=4h refresh=60000 visibility=[Chart_Period==0]
                                Chart item=Chart_Power period=8h refresh=300000 visibility=[Chart_Period==1]
                                Chart item=Chart_Power period=12h refresh=300000 visibility=[Chart_Period==2]
                                Chart item=Chart_Power period=D refresh=3600000 visibility=[Chart_Period==3]
                                Chart item=Chart_Power period=3D refresh=3600000 visibility=[Chart_Period==4]
                        }
                }

And the RRD persistence:

Strategies {
        // CronExpressions are "seconds, minutes, hours, day-of-month, month, day-of-week, year (optional)"
        // ranges like 30-45 or MON-FRI can be used, and wildcards like * mean every value for this field
        // 0/15 type increments can be used, 10,35,55 is a list, and ? means 'no specific value'

        everyMinute             : "0 * * * * ?"
        every5Minutes           : "0 0/5 * * * ?"
        every10Minutes          : "0 0/10 * * * ?"
        every15Minutes          : "0 0/15 * * * ?"
        every30Minutes          : "0 0/30 * * * ?"
        everyHour               : "0 0 * * * ?"
        every12Hours            : "0 0 0/12 * * ?"
        everyDay                : "0 0 0 * * ?"

//      default = everyMinute, everyChange
}

Items {
        // defining items can use item names, wildcards, as well as group names and wildcards!
        // environment interval data points to collect and graph
        Charts*, Temperature*, Humidity*, Energy*  : strategy = everyMinute
        //Temperature*,Humidity*,HVAC*,Chart_* : strategy = everyMinute, restoreOnStartup
//      HVAC_Setpoint_* : strategy = everyMinute, restoreOnStartup
        //Status : strategy = everyHour, restoreOnStartup
}

The only comment I would make Kim is that I am “used to” power measurement being for a particular time period for understanding and accuracy. Energy implies the power and time… but the way that you are calculating the power looks like you are using fixed time period (36000000) for the calculation, but you are firing the calculation on the pulses; not the passing of that fixed time. I could be mistaken as I didn’t look very deeply at it. This is also going to create A LOT of traffic on the serial line to OpenHAB, log files, etc if the pulse intervals are really 1 Wh. You may consider having a total count register which you increment, and then every defined period (1 min, 5 min, 10 min, etc.) you fire off the power calculation and print it out on the serial port for OpenHAB.

I am using 5 minutes for all of my calculations, so the average power over the interval is returned. This obviously doesn’t tell you what the max power was during that 5 minutes, but does allow you to take 12 records, add them up, and get the hourly energy consumption… or average them to get the average power over an hour.

Yes, its 1wh pulses. I can get get arduino to do average of 5minutes as
well as post new day max day min if that occurs on the serial port. Do you
have a code that does that?

Sorry… I am doing all of my calculations in Node-RED with JavaScript.

Can you give me complete code for monitoring electrical parameters such as Power factor,Active power , Reactive power,Apparent power,Current,voltage,consumption,tariff.And how to setup hardware for the following if there is any tutorial from your side it will be good. Thank you in advance.