IoT / Smart Home

The idea

A few years ago, thanks to a suggestion of a friend, I discovered the world of Arduino & co; if you don't know it, Arduino is a company that designs and manufactures microcontrollers based on open source hardware and software. There are several models which vary according to technical characteristics and dimensions; therefore, the choice is made according to the objectives. These electronic boards (found on many ecommerce websites) allow, writing simple or complex software, to manage inputs and outputs. A very simple example is the firing of a led (OUTPUT) through the use of a button (INPUT). In general, through digital inputs and outputs and software programming you can create real circuits to interface with sensors and actuators.
I don't want to go too far on the subject and I put the link to the official website, where you can eventually go deeper into the topic

Let's get back to main topic...
My first experiment with Arduino was the creation of a GAS sensor. You can find all the details on the relevant post of my blog: First experiment: a simple gas detector.
From that moment on I began to deepen this fascinating world and several ideas flashed through my head, up to my final project: the implementation of a Home Automation System, thanks also to the discovery of the Wifi buttons (see Home Automation System - Discovering sonoff) and ESP8266 microcontrollers, very similar to Arduino but with integrated Wifi, much smaller and much less expensive. All this, enriched by different sensors (temperature, humidity, gas, probes for monitoring energy consumption, etc etc) and thanks to the help of mini computers (such as the famous Raspberry PI) and open source software allowed me to get to the real development of my project, currently still in "work in progress" (the available time is less than the required time...)

What an Home Automation System is

What an Home Automation System is

There are many definitions of Home Automation System around the network. In very simple words, we can define an Home Automation System as an interface to monitor, control and automate the main functions of a so-called "smart home". A set of sensors and actuators that communicate with a central unit, called the Hub, the brain of the system. A classic example of components of an Home Automation System can be given by temperature sensors, switches and virtual buttons, video surveillance and security systems, energy measurement sensors, smart bulbs, etc etc, all interconnected through hubs capable of interfacing with the various communication protocols of the devices, often heterogeneous to each other. Alongside the hub we also have user interface systems, which allow the real use of the system: starting from the wall-mounted panel up to the app on the smartphone, a desktop application or a web interface; last but not least the voice control, which allows us to "use" our Smart Home simply speaking in natural language. Famous examples are Amazon Echo Dot / Alexa and Google Home / Assistant. Another important feature of the Home Automation Systems is remote control: we can manage our devices wherever we are, using the internet. In summary, a Home Automation System allows us to manage home devices, even outside the walls of the house, without the need to physically act on the actuators but simply using a software (smartphone, PC, tablet, wall panel) or even our voice. The last aspect, no less important than the others, that makes our home even smarter is the ability to automate different operations allowing it to take decisions based on the state of the system itself. Examples: the temperature in the living room is above 28°C, so I turn on the air conditioner; the photovoltaic system is producing 2.5Kwh, then I start the washing machine; it's evening, so I turn on the lights in the garden. As you can easily imagine, the only limit is out fantasy.

The design

After all these beautiful words, let's move on to the real things. After studying and carrying out numerous practical experiments I finally reached the definitive project of my Home Automation System, however always in continuous evolution. My system is based on the excellent OpenHAB software, selected from the several Open Source systems of Home Automation on the network. In this post of my blog you can learn more about what led me to make this choice.
Here are the main modules of my current Home Automation system:

  • DHT11
    DHT11 - Humidity / Temperature probe

    Cheap sensor to get humidity and temperature values. It has digital output, easy to use with microcontrollers.

  • DS18B20
    DS18B20 - External temperature probe

    External temperature probe. More precise than DHT11 but more expensive. Can be used several sensors with a single communication bus, using the One Wire interface.

  • PZEM-004t
    PZEM-004t - Multimeter for current and voltage measurements.

    Non-invasive sensor (thanks to the CT current transformer) for measuring electrical powers. It can work standalone with PC software and USB connection, or connected to a microcontroller via serial port.

  • MQ-4
    MQ-4 - GAS sensor

    GAS Sensor, mainly sensitive to methane, propane and butane gas. It has an analog output to obtain a precise value and a triggerable digital output.

  • SONOFF Basic
    SONOFF Basic - WiFi button with single output

    WiFi single output button, based on ESP8266 chip. It allows you to control a load remotely, using APP and / or integrated button.

  • SONOFF Mini
    SONOFF Mini - WiFi button with single output

    WiFi single output button small dimensions, based on ESP8266 chip. It allows you to control a load remotely, using APP and / or integrated button. It's already prepared to be used with an external button / switch and it can works in DIY mode

  • SONOFF Dual
    SONOFF Dual - Wifi button with dual output

    Dual output WiFi button, based on ESP8266 chip. It allows you to control two loads remotely, using APP and / or integrated button.

  • SONOFF 4 Channel
    SONOFF 4 Channel - WiFi button with four output

    WiFi buttons with four outputs, based on ESP8285 chip. It allows you to control four loads remotely, using APP and / or integrated buttons.

    SONOFF B1 - WiFi RGB Smart Bulb

    WiFi RGB Smart Bulb, remote controlled. It is possible to control color, temperature and brightness.

  • Xiaomi Yeelight
    Xiaomi Yeelight RGB - Wifi RGB Smart Bulb

    Xiaomi RGB WiFi bulb controlled by proprietary app (Mi Home) and interfaced in OpenHAB.

  • Xiaomi Mi Robot Vacuum
    Xiaomi Mi Robot Vacuum - Robot vacuum cleaner

    Robot vacuum cleaner remote controlled with room mapping and stair detection features.

    ARDUINO Uno - Microcontroller for DIY.

    One of the most famous microcontrollers with analogic/digital I/O. It works with 5V power adapter.

  • ESP8266
    ESP8266 - Microcontroller for DIY, with built-in WiFi.

    A cheap microcontroller with built-in WiFi. It works with 3.3V power adapter; it has several digital I/O and a single analogic I/O.

  • OPENHAB Basic UI
    OPENHAB Basic UI - Simple web user interface for OpenHAB

    Simple and minimal web user interface to monitor and control OpenHAB Items. It can also be used on Android, iOS and Windows Smartphone / Tablet with the dedicated app.

  • OPENHAB Hab Panel
    OPENHAB Hab Panel - Web interface for touch panel for OpenHAB

    Web interface built on AngularJS framework to design and build user interface optimized for touch panel (for example tablets).

    GRAFANA - Web based software to design and build several dashboards.

    Web based software to design and build several dashboards composed by graphical widget to monitor real time and historical data read from Home Automation System.

    MOSQUITTO MQTT Server - MQTT Broker to publish and consume messages

    MQTT Broker to publish and consume messages among different modules of the system.

  • TASMOTA Firmware
    TASMOTA - ESP8266 Firmware

    Open source and alternative firmware for ESP8266 with web interface.

    INFLUXDB - Time-series RDBMS

    Open source time-series RDBMS.

  • GRAFANA Server
    GRAFANA Server - Data visualization service

    Open Source data visualization service to manage interactive dashboard, easily interfaced with many RDBMS.

  • Google Home Mini
    Google Home Mini

    Google Virtual Assistant

  • Amazon Alexa Echo Dot
    Amazon Alexa Echo Dot

    Amazon Virtual Assistant

  • Samsung Smart TV 4K 49'
    Samsung UE49NU8000T 49' - 4K Ultra HD Smart TV

    4K TV 49 inches

  • Bose Speaker Bluetooth
    BOSE Soundlink Color - Bluetooth Speaker

    Portable Wireless speaker

  • Jam Waterproof Speaker Bluetooth
    JAM Chill Out - Waterproof Bluetooth Speaker

    Portable Wifi Speaker with a good design

  • Samsung Bluetooth Soundbar 2.1
    SAMSUNG Bluetooth Soundbar

    Wifi Soundbar with external subwoofer

  • Google Chromecast
    Google Chromecast

    Turn your old TV in a Smart TV

  • Ubiquity PowerBeam 5AC Gen2
    Ubiquity PowerBeam 5AC Gen2 - 5Ghz PTP Wireless Bridge

    High-performance 5 GHz Point-to-Point (PtP) bridge

  • Linksys WRT54G Wireless Router
    LinkSys WRT54G - Wireless Router

    An old wireless router with DD-WRT firmware, used for the first floor network

  • Belkin F5D7234-4 Wireless Router
    Belkin F5D7234-4 - Wireless Router

    Un old wireless router used for the basement network

  • Tplink Archer C7 Gigabit Wireless Router
    Tplink Archer C7 - Gigabit Wireless Router

    A new wireless router with LAN Gigabit, providing network at ground floor

  • WD My Book World Edition 1TB NAS
    WD My Book World Edition - 1 TB NAS

    An old 1TB NAS with LAN Gigabit but without any RAID setup; it is used to store backup data

  • WD My Cloud EX2 Ultra 4TB NAS
    WD My Cloud EX2 Ultra - 4 TB NAS RAID 1

    A new 4TB NAS with RAID 1 and with LAN Gigabit, used to store backup data

  • Dahua HDCVI Recorder
    Dahua XVR5108HS-4KL-X - HDCVI Recorder

    4K Videorecorder - 8 input

  • Dahua 4MP Mini Dome
    Dahua HAC-HDBW2401R-Z - 4MP Mini Dome Camera

    4MP external camera

  • Dahua 4MP Bullet
    Dahua HAC-HFW2401R-Z-IRE6 - 4MP Bullet Camera

    4MP external camera


The current setup of my Home Automation system includes a number of sensors and actuators integrated in OpenHAB which represent the heart of the system. OpenHAB, in addition to managing the data acquisition with database persistence (InfluxDB - Time Series Database) and sending the action commands, allows its control and visualization through its BasicUI and HabPanel user interfaces, as well as manages the automation rules, another important aspect of a Home Automation system, which cannot be ignored.
Here is my current setup:

First Floor - Night zone
  • 5 lights: camera 1, camera 2, mezzanine, mansard, hallway and a automatic night light
  • 2 temperature / humidity probes: camera 1 and mansard
  • 1 google home mini in camera 1 and 1 speaker JAM Chill Out in the shower box
Ground Floor - Day zone
  • 10 light: RGB Lamp and two spotlight bar in the Living Room, studio, bathroom and entrance and 1 led strip over the sofa as ambient light
  • 5 temperature / humidity probes: kitchen, livingroom, studio and bathroom
  • 1 GAS sensor in the kitchen
  • 1 samsung smart tv, 1 samsung soundbar, 1 google home mini and 1 alexa echo dot in the livingroom and 1 speaker BOSE Soundlink Color in the studio
  • 1 XIAOMI MI robot vacuum in the living room
  • 1 power measurement for the entire floor
  • 1 wall-mounted user interface in the kitchen
  • 1 temperature / humidity probe in the garage
  • 1 google chromecast in tavern, used by a projector
  • 1 power measurement for the entire floor and 1 photovoltaic power measurement attached to the inverter in the garage
Garden / External
  • 7 lights: rose, rockery garden, front of kitchen, gazebo, entrance and 2 automatic light all around the house
  • 1 temperature probe over the gazebo
Anti intrusion system
  • Wired contact and radar sensors linked to an "homemade" interface connected to the GPIO of the Raspberry to monitor the state. The anti intrusion system has its own central unit.
Video surveillance system
  • 3 camera in the garden connected to a local videorecorder to monitor the property borders
  • External house lights: automatic power on during the night
  • Vocal command "Goodnight": all light switched off, night light switched on playing relaxing sound music
  • Power consumption real time monitor: periodic check of energy production and consumption with app and voice notification of exceeded maximum power allowed
  • GAS sensor real time monitor: periodic check of gas sensor with app and voice notification if exceeded threshold


You can find the Work in Progress of the system in my blog, where you can read the main steps of design and build of my Home Automation System

Below there is a list of posts that I consider more relevant than others regarding the fundamentals of the system