Pull to refresh
0
BARY.io
Меня зовут BARY, я подружу все ваши IoT устройства

How to save energy with BARY: Smart Home

Reading time10 min
Views772
Original author: BARY


Well, every modern person has at least once wondered: for how much longer can you pay such huge utility bills?! I am no exception. Electricity, gas, heating, water, rent, elevator, removal of solid waste, etc. etc.

One of the reasons (far from the last) of creating the BARY application was the ability to collect statistics, analyze and reduce energy consumption. Europe has long passed into the regime of total economy; I think this fate will not bypass us. Therefore, to prepare for this in advance definitely will not be superfluous.

I now propose that we examine how we managed to optimize the cost of electricity along with BARY: Smart Home.

Getting started: air conditioning and under floor heating


The first optimization of energy costs was to restore order in the use of underfloor heating and air conditioning. Even without a detailed analysis, it was clear that they consume a lot.

Today, only the lazy did not write about the prevention of viral infections. But, nevertheless, practice makes perfect. The key to healthy antiviral weather in the apartment is a temperature of 18-24 C, humidity 40-60%, as well as regular ventilation.

I almost did not turn the air conditioning off during the summer. In winter, the same thing happened with warm floors. At the time when the owner was absent from the house, air conditioning turned off only occasionally (we did not want to return to the stuffy room) and the floor heating never went down. The bills for all this were quite cosmic, and the temperature was far from ideal parameters. It was somehow impossible to turn everything off manually before leaving: either we had no time, or it was simply forgotten.

Most household air conditioners do not have remote air temperature sensors (this is my case), i.e. they do not accurately provide the specified temperature regime. But they can be turned on by any external sensor when the upper temperature threshold is reached and turned off when it reaches the lowest. This was my first automation.

In fact, it goes like this: the lower threshold is set at 24.0 ° C and the upper — 24.5 ° C. As soon as the temperature in the apartment rises above 24.5 ° C, the air conditioner turns on and works until the temperature drops below 24.0 ° C. To prevent the conditioner from turning on and off every minute, a condition is set for the minimum time for work and rest. I have it for 10 minutes. The value was selected empirically. In practice, the temperature has always been in the indicated range.

In BARY, it looks like this:


Fig. The rule of turning on the air conditioner

I think it’s worthwhile to dwell in more detail on what the rule shown in the example does:

  • The condition of the air conditioner has not been changed over the past 10 minutes;
  • Armed mode is off;
  • Air conditioning off;
  • Sleep mode is off (in night mode another rule is used);
  • The temperature in the living room or in the kitchen exceeds the value set in these rooms (I have a studio apartment; therefore I use a sensor in each room. You can use either a numerical value or variables from the settings of zones and rooms as values);
  • A motion sensor in the kitchen does not detect movement (this sensor is used by the wife, because she does not like it when the air conditioning is blowing on her);
  • There is no energy consumption for the water heater (it is very voracious, and at the time of its operation it is better not to turn on anything ‘heavy’).

Since this moment, the consumption of electricity by the air conditioner decreased several times. In order for the air conditioner would not work idle when there are no hosts, a virtual button was made in BARY, the status of which was present in the automation of the air conditioner (“Security” from the example above). The same virtual button was for night mode (“Sleep” from the example above), which was also taken into account in a separate automation rule and turned on the air conditioner in the most silent mode. At first, these buttons had to be activated manually.

The automation solution was found in the form of Apple ecosystem. A bunch of my devices were implemented with Homekit, and also Apple TV was acquired. With it, you can implement the work of automation rules in Homekit (you can also use iPad, but I didn’t have it at that time). The rules are created in Homekit itself: the last person leaves home; the first person comes home. Virtual buttons were bound to these rules in BARY.


Fig. Rules for automatic security on / off

At first I even kept statistics, which displayed the number of minutes worked by the air conditioner per hour. Unfortunately, now the statistics have already been lost, but the air conditioner’s operating time has decreased by almost ⅔ from the original figure.

Identification of the main electricity consumers


Analysis methods for the major consumers


In order to start optimizing costs, you need to understand where the majority of the electricity goes.
Here, I think, there may be different approaches:

  • The usage of special modules — relays. In addition to their main on / off function, they keep track of the energy that is consumed by the devices connected to them;
  • Applying special meters using current transformers;
  • Measuring the power consumption by ourselves (for example, using a wattmeter) and indicating the average value in BARY (this method is completely inaccurate, but it will work out approximate indications).

For all devices except the under-floor heating, I have installed: overhead sockets from Blitzwolf, modules for Shelly 1pm / Aqara Relay Module / Fibaro Double Switch 2 socket boxes. Maybe there was something else, I don’t remember now.
For the under-floor heating, I took readings based on the status of their work and average consumption indicators (the third, not very accurate way).

In the device settings there is a special field for indicating energy consumption (consumer power):


Fig. Configuring the device’s energy consumption parameters

The total power consumption was taken from the input counter using the Wemos D1 board and a simple sketch:

The source code for this sketch
#include <Wire.h> 
#include <EEPROM.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>
#include <ArduinoJson.h>

#define WIFI_SSID "****"
#define WIFI_PASS "****"
#define API_URL "http://192.168.1.33/api/post-data"

volatile unsigned int state = 0;
volatile unsigned int kWh = 0;
volatile unsigned int blinked = 0;

int impulse = 3200;
int eeAddress = 0;
unsigned int lastMillis = 0;
int counter = 0;
int blinkMin = 10;
int timeout = 15000;
int PIN = D8;

void setup()
{
  state = impulse;

  EEPROM.begin(512);
  counter = EEPROM.read(eeAddress);
  EEPROM.write(eeAddress, counter + 1);
  EEPROM.commit();

  pinMode(PIN, INPUT_PULLUP); 
  
  attachInterrupt(digitalPinToInterrupt(PIN), blink, RISING);

  Serial.begin(115200);
  Serial.println(F(" "));

  connectWiFi();
}

void connectWiFi() 
{
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println("WiFi: Waiting for connection");
  }
  Serial.println("WiFi: connected");
}

float roundEx(float value, int digits) 
{
  int newValue = value * pow(10, digits);
  return (float) newValue / pow(10, digits);
}

void loop()
{
  if (blinked >= blinkMin && millis() - lastMillis > timeout) {
    float divider = (float) impulse * (millis() - lastMillis) / 1000 / 3600;
    float power = blinked / divider;
    float kWhFloat = kWh + (float) (impulse - state) / impulse;

    Serial.print(F("sec="));
    Serial.print(millis() / 1000);
    Serial.print(F("; time="));
    Serial.print((millis() - lastMillis) / 1000);
    Serial.print(F("; blinkMin="));
    Serial.print(blinked);
    Serial.print(F("; state="));
    Serial.print(state);
    Serial.print(F("; kWh="));
    Serial.print(kWhFloat, 3);
    Serial.print(F("; power="));
    Serial.print(power, 3);
    Serial.println(F(" "));
    blinked = 0;
    lastMillis = millis();

    if (WiFi.status() == WL_CONNECTED) {
      StaticJsonBuffer<300> JSONbuffer;
      JsonObject& JSONencoder = JSONbuffer.createObject();
      JSONencoder["device"] = "main_counter";
      JSONencoder["function"] = "counter";
      JSONencoder["counter"] = counter;
      JSONencoder["power"] = power;
      JSONencoder["usage"] = kWhFloat;
      char JSONmessageBuffer[300];
      JSONencoder.prettyPrintTo(JSONmessageBuffer, sizeof(JSONmessageBuffer));
      Serial.println(JSONmessageBuffer);

      HTTPClient http;
      http.begin(API_URL);
      http.addHeader("Content-Type", "application/json");
      int httpCode = http.POST(JSONmessageBuffer);
      String payload = http.getString();
      Serial.print(httpCode);
      Serial.print(" ");
      Serial.println(payload);
      http.end();
    } else {
      connectWiFi();
    }
  }
}

void blink()
{
  detachInterrupt(digitalPinToInterrupt(PIN));
  attachInterrupt(digitalPinToInterrupt(PIN), lowInterrupt, FALLING);
  state--;
  if (state == 0 || state > impulse) {
     kWh++;
     state = impulse; 
   }
   blinked++;
}

void lowInterrupt(){
  detachInterrupt(digitalPinToInterrupt(PIN));
  attachInterrupt(digitalPinToInterrupt(PIN),  blink, RISING);
} 


Any electric meter has a pulse output, which is duplicated by LED. When the LED blinks- the pulse has passed. If you connect a device, such as an Arduino, to the pulse output, you can calculate the number of pulses. A sketch every 15 seconds (but not more often than it accumulates a sufficient number of pulses) makes a POST request with the current readings in BARY (Why the device itself creeps onto the server, and not vice versa? I don’t remember, at that moment it seemed convenient). Pulses are read by interruptions, and the strange “attach / detach” scheme is implemented to suppress contact bounce. There were no false positives.

Identification and analysis of other electrical consumers


If the main meter is used in the system, then electricity consumers who do not have meters will be displayed as unknown in the statistics:


Fig. Low-detailed energy statistics

After identifying the obvious main consumers and playing enough with homegrown sketches, I realized that there are too many consumers left in the “Unknown” classification. It was decided to launch heavy artillery: a multi-channel counter WB-MAP12H. It allowed to determine the most “gluttonous” lines and to further differentiate energy consumption.

Most of the expenses were allocated to air conditioning (in summer), under-floor heating (in winter), breather (in winter), computer and multimedia. And yes, the kettle, which always works so noisily and puffs, turned out to be almost the lowest consumer.

The statistics of electricity consumption by category in BARY can be found in the tab “Events” — “Statistics”


Fig. More detailed energy statistics.

It is very convenient: when the consumption for any of the categories exceeds the average, the category is highlighted in red. Like “Air Conditioning” in the picture above. By the occupancy of this line, one can judge the magnitude of the excess as a percentage of the average.

You can also see what statistics are compiled for a particular category:


Fig. Detailed statistics on devices

Avoiding data duplication


If you use a set of devices to analyze power consumption — a counter in the socket + a total counter per line — the readings will be doubled. BARY allows you to build a parent-child hierarchy. This is implemented as follows: for the devices themselves, we set the consumption category and a higher counter (see. Fig. “Configuring the device’s energy consumption parameters”).

A higher counter is needed if one counter reads the entire line and the other counts a specific socket. When viewing statistics, the readings of this socket will be subtracted from the readings of a higher counter, and the data will not be duplicated. If we take readings from the upstream meter and specific points, then part of the costs (the costs of those consumers who belong to the upstream meter line but do not hang on the sockets with a dedicated meter) will be displayed as unknown in the statistics. (see Fig. «Low-detailed energy statistics»)
Nesting itself is not limited in any way. For example, I use a scheme of up to 4 attachments.

And what`s next?


Let`s suppose we are finished with uncertainty, so how can we start saving now? Of course, each smart home will have its own specifics. But here are some general working recommendations.

Scenarios “Leaving Home / Coming Home”


I highly recommend setting up a leaving home scenario! It seems to be obvious, but it works very well. In this scenario we include disabling everything that is possible. The scenario of returning home, respectively, returns everything to working mode.


Fig. A list of devices disconnected when leaving home

“Good Night” Scenario


Have you ever wondered how much devices that are in standby mode consume? Just plugged in? I am. Yeah, I`m obsessed =)

For example, an air conditioner simply left in a wall socket consumes 1.4 Wh * h. In a month it turns out 1.4 W * h * 24 h * 30 days = 1 KW * h, and at least six months a year it does not work.

Of course, the figure is not so big. But optimizing costs with a Smart Home system is worth nothing to us. But there can be not one, and not five of such “waiting” devices in a house. TVs, game consoles, computers and other devices. The more devices- the more expenses.


Fig. A list of devices that are disabled in sleep mode

Temperature mode


We set the temperature regime of warm floors to be the minimum permissible. For example, in the bathroom the temperature is set at 26 ° C, this is a quite acceptable temperature and there is not much energy spent in this mode. If humidity is exceeded (someone takes a shower), we increase the temperature (during a shower, the floors usually have time to warm up by 2-3 degrees).

In the other rooms, we automatically turn off the warm floor using a motion sensor (why would we heat the floors if there is nobody in the room?).

If separate electric heaters are used, then we also connect their work to a temperature sensor (as with an air conditioner). If a breather of the “Tion” type is used, then in summer we try to run as little air as possible (it is hot and this is an extra work for the air conditioner), in winter it is the same with cold air (the breather itself warms it).

Let there be light! But only in the case


If the lighting in bathrooms, dressing rooms, pantries and other similar rooms is still turned on and off manually, we attach it to the motion sensor. So you will never forget to turn off the lights! Well, also you won’t need to look for a switch in the dark kitchen next to the midnight refrigerator. In addition, it is not difficult at all to do this — there are a lot of Wi-Fi / Zigbee / 433 MHz switches on Aliexpress, including those without a zero line.

If you still use incandescent bulbs, halogen and other gluttonous light sources, then you should know:

On November 23, 2009, Federal Law No. 261-ФЗ “On Energy Saving” was issued, which stipulated that incandescent lamps with a capacity of 100 watts or more would be banned from production and sale from January 1, 2011, with a capacity of 75 watts or more being canceled from January 1 2013.

It's time to think about switching to more economical ones — LED and energy-saving.

With the same luminous flux of 1200Lm, an incandescent lamp consumes 100 watts, fluorescent / energy-saving — 25-30 watts, and LED — about 10 watts. Plus, the life of LED and energy-saving lamp is significantly longer than the life of an incandescent one.

Recently, we had an automation case that used incandescent lamps stylized as Edison lamps. Over 40 lamps of 60 watts each. Obtaining the statistics of energy consumption for one month, it was not surprising to find that more than a third of the electricity bill came from these lamps. All lamps were immediately replaced by similar, but already LED ones. They paid off very quickly.

Epilogue


For over 5 years of working on my smart home, many scenarios and automation processes have improved and undergone significant changes. Energy conservation has become a good habit. Now it is difficult to imagine that the warm floors are fried from morning to night, and the air conditioning is constantly buzzing. The weather in the house is comfortable, and payments for light please the eye and the wallet. BARY on guard of saving resources!

I hope this material was useful to you. If you have your own examples of optimizing electricity consumption, share in the comments what and how you managed to automate. And also join our group in VK and telegram!
Tags:
Hubs:
+3
Comments0

Articles

Change theme settings

Information

Website
bary.io
Registered
Founded
Employees
2–10 employees
Location
Россия
Representative
Айдар