0 Comments

Another step to make my home smarter using activity detection and human presence.

1. How IoT can modernize your home security? It will be human-centric, almost nonvisible.

2. Are you tired remember another PIN? You can forget your home-security pin forever.

3. Do you need remotely turn off home security? This is easy, you don’t need to do anything for it.

This picture presenting the full smart home concept, security is just a one part of my smart home environment. The main heart is Raspberry as an IoT device and Azure cloud for information processing, reporting and alerting.

Home IoT project

The idea is to use existing:

1) PIR (passive infrared sensor) and door magnetic proximity sensors to detect human movement by sliding window algorithm and

2) Wi-Fi sniffer to detect by phone MAC-address who is at home (assumption: phone Wi-Fi is turned on).

IR detectors and door proximity sensor together are used to automatically secure on unsecure entire home. It is based on sliding window algorithm as there are clear patterns for entry/exit activities.

The accuracy is not 100%, for example, if someone is leaving and doesn’t close the door afterwards, then you cannot say is he really left or just hanging somewhere close.

Wi-Fi sniffer is just listening what kind of Wi-Fi devices are close and by MAC-address you can easily match this information to names.

Secure/unsecure your home:

If algorithm detects exit pattern, then home is automatically secured. What does it mean “secured”?

“Secure” mean just active alerting by SMS/WhatsApp/e-mail.

Secured home mean that, if PIR or proximity sensors are detecting movement, then you will be alerted by SMS, WhatsApp, e-mail that someone is at your home. You can make whatever you like to do now, call neighbors, friends, police etc.

If the person is known by his/her phone MAC-address, then there will be no alerting and security is basically off.

If your phone Wi-Fi is not turned on and you will get alerted, then you must answer to SMS/WhatsApp/e-mail notification. System automatically recognizes you and taking off active alerting functionality.

0 Comments

What is the biggest cost in your home?

It is heating!

I will be introducing a home controller project, where I will be focusing on minimizing the consumption of home energy .

This project uses Microsoft software technology stack like Windows 10 IoT Core, Azure, IoThub and PowerBI. Hardware used for this project is Raspberry PI, OneWire digital temperature sensors, relays, some resistors and transistors.

IoT HomeController overview

Where did my story begin?

I had an apartment in a very cool region which has lovely architecture from ages 1950-1970. However, I had 3 major problems there:

1. During the winter we sometimes have –30 degrees and the walls of these buildings are quite thin, my monthly expenditure for heating was sometimes 500 EUR/month.

2. I love kayaking, so I need to keep my 6,5m long kayak somewhere. I cannot take it into my sleeping room.

3. I love to live in a quiet place, but there we had some lovely neighbors with a dog Rottweiler, who was barking almost all the time.

So I started to look for a new home which would be free from these problems. Now we have our own home which is quiet, it has a garage to store the kayak but most importantly, my yearly expenditure for heating the whole home is 1000 EUR using a ground based heat pump.

Even though my monthly costs are so small now, I still wanted to reduce it. I figured out 4 ways for optimization.

What to even optimize on a heat pump?

There are three things you can optimize.

1. Homes with heat pumps have some special pumps (motors), which move water inside the pipes that is inside floor. Usually these pumps are working 24/7. It sounds weird, but yes, no heat pump has been produced that would turn these motors off when room temperature is on normal levels and doesn’t need more heating.

This will be my optimization #1

If room temperature is normal and doesn’t need heating, I can safely turn off this motor to save energy consumption.


2. Usually, these homes have another motor for hot water, which enables you to have instant hot water from the shower. This pump is working 24/7 and I haven’t seen a single solution where it is turned off when there’s no demand for hot water.

This will be my optimization #2

If nobody is at home (children are at school and we are at work) or during the night time when everyone is asleep, this pump can be safely turned off to save energy consumption.


3. Heat pumps are working in automated mode, where they measure the outside temperature and the water temperature inside the heating pipes (outgoing and incoming) and based on that information, the heat pump calculates the heating time to keep the temperature constant in a room.

The heat pump doesn’t know anything about energy price.

But I know. Or the Internet knows.

Energy has a market price that will change hourly. The price is very often twice as high in daytime when compared to night time. Take a look at this graph, from 00:00 to 05:00 it has a price of 3,75 s/kWh but at 8:00 or at 18-19:00 the energy price is over 8 s/kWh. It is more than two times higher.

Energy hourly market price

This will be my optimization #3

If energy price is high, my heat pump will be turned off. This is actually the highest energy consumption in my home compared to my other optimizations.


I worked out a special algorithm to avoid a cold home if the energy price is high during the day. My program will calculate 12 cheapest hours during the day and the heat pumps are turned on only during that time. If the energy price is high during the day, I will still calculate the cheapest hours and my heating system will work during that time. The floor is from betony, so it can keep heat for many hours.

Look at the following graph. Green lines will represent 12 cheapest hours during the day, so my heat pump will work actually during periods: 00:00-06:59, 13:00-13:59, 16:00-16:50 and 21:00-23:59, altogether 12 hours in a day.

Energy hourly market price, green is 12 cheapest hours in a day

In order to use this energy price based optimization, you need to have an energy meter which measures your home energy on an hourly basis and you need an hourly based energy contract with your energy provider. I have both, so this optimization has a huge effect on my energy consumption.


What to even optimize with the ventilation system?

My home also has a ventilation system. The ventilation system will ensure that you will have fresh air in your home.

But how do I know the air is fresh? The most important parameter is to measure CO2 level. If this is high, you could turn ventilation on.  There is a proved science behind the CO2 level in rooms.

This will be my optimization #4

If CO2 level is high, my ventilation will be turned on, after CO2 level is back on normal levels, ventilation will be turned off.


Do I need reports on how my home is doing?

Initially I though that getting reports is not needed, but when I started to learn about Azure IoTHub, stream analytics and PowerBI, I figured out that asking for reports is so easily achievable, that it would be really stupid not to.

Microsoft has tons of information on how to send data to Azure through Azure IoTHub. That just required a few lines of code and the creation of an Azure IoTHub and I was ready to send data into Azure.

PowerBI is working just out-of-the-box. What I was missing was how to send data from Azure to PowerBI. That was very easy – stream analytics will do all the job for you. So I just needed to create PowerBI reports to see what’s happening at home.

Finally, I have a good PowerBI dashboard to see all different aspects regarding heating time, temperatures, CO2 levels, ventilation etc.

temperatures, proposed heating time, real heating timeheating and hot water producing time in minutes per dayCO2, humidity level and report about ventilation time in minutes per dayIoT outside temperature graph in last 24 h

0 Comments

HelloBlinky is one of the shortest and easily understandable program which illustrates Raspberry PI GPIO programming.

In the following example we are using Raspberry PI with Windows 10 IoT Core.

https://github.com/LeivoSepp/Lesson1-HelloBlinky

What is GPIO?

GPIO stands for general-purpose input/output and it is a generic pin on a Raspberry/Arduino board. Each pin can be configured to be input or output.

If pin is configured as an input

Use it for buttons, measuring temperature, measuring light,  measuring distance

If pin is configured as an output

Use it for LEDs, motors, relays, lamps

Pin identification number

Each pin has its own personal number. This number is used to communicate with the pin. The pin number to use to communicate has an orange background. Do not try to use the numbers with grey backgrounds! It wont work and you will get an error.

Raspberry PI pinout

Raspberry PI has two special pins which are to control the green and red LED integrated on the board. The green LED’s pin number is 35 and the red’s pin number is 47.

Windows 10

In order to set up Windows 10 IoT Core to your Raspberry, please follow the instructions here: https://developer.microsoft.com/en-us/windows/iot/Docs/GetStarted/rpi2/sdcard/stable/getstartedstep1 

Visual Studio

To start new Raspberry project, use the Visual Studio template “Background Application (IoT)”.

Visual Studio Background Application IoT

If you do not have this project template, then open menu Visual Studio –> Tools –> Extensions and Updates. From there, click online, search for the string “iot” and install “Windows IoT Core Project Templates for VS”.

Visual Studio Tools Extensions and Updates

 

Blinky code and explanation.

Blinky code and explanation


using Windows.ApplicationModel.Background;
using Windows.Devices.Gpio;
using System.Threading.Tasks;
 
namespace HelloBlinky
{
    public sealed class StartupTask : IBackgroundTask
    {
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            int LED_PIN = 35;
            var gpio = GpioController.GetDefault();
             
            GpioPin pin = gpio.OpenPin(LED_PIN);
            pin.SetDriveMode(GpioPinDriveMode.Output);
 
            while(true)
            {
                pin.Write(GpioPinValue.Low);
                Task.Delay(1000).Wait();
                pin.Write(GpioPinValue.High);
                Task.Delay(1000).Wait();
            }
        }
    }
}