Close
0%
0%

Smart Home in the IoT Way

ESP8266 based humidity logging and adaptive fan control, door lock detector, and more...

Similar projects worth following

WiFi based Smart Home system

The system described in this project aims two simple goal:

  • Gather various information from the smart-nodes in the house, and let the user access this data from a smartphone
  • Control some smart devices in the house

Architecture

The current solution implements a mixed LAN / WAN architecture, with the following functions and restrictions:

  • The devices can only be controlled by the mobile clients connected to the local WiFi network.
  • The local client gets the aggregated data from the cloud server
  • If the cloud server in not accessible, the local client can access the devices directly (reading data, sending commands)

Technical details

IoT devices

ESP8266 based devices implementing HTTP client for sending data to the cloud server, and also HTTP server for handling the direct connections.

Cloud server

Custom central server running on node.js + express 4, implementing the following functions:

  • Collecting, aggregating data
  • Serving the mobile clients
  • Authenticating the users (google)

Mobile Client

JavaScript WEB application, capable to run offline (when the cloud server is unreachable) using the state-of-the-art application cache HTML5 function.


The Smart Nodes

Humidity control


Background

Bathrooms can be wet places... usually because of showering or having a bath, which create a lot of humid air. This vapor should be extracted from the room, and usually extractor fans are used for this purpose.

The ordinary fan control in a bathroom is usually connected to the main light switch. However people use the bathroom for reasons other than showering, and in these cases the operation of this fan is unnecessary, and results in avoidable energy consumption and noise production.

Solution

The device simply measures the room humidity, continuously calculating the average level over a predefined time period (over the past hours). It then turns on the fan if the level is 5% higher than the average, and turns it off when the humidity has dropped below the average level plus 2%.

Fancy IoT Functionality

The device can connect to the home automation server to provide the following extra functions:

  • The device continuously reports the values to the IoT server as a data log
  • The user can check the charts of the measurements on the server's web page
  • The user can deliberately override the fan control. One can set a timed and forced operating period regardless of the humidity measurements. It can also be disabled in the same way for a user selected time period.


Door / lock status report

This type of smart node reports the garage door open / closed status, and the lock's locked / unlocked status as well.


Universal Smart Nodes

The smart nodes should support various data acquisition or control functions. They can be powered from AC mains, or some sort of batteries. To achieve flexibility the ESP8266 based MCU board has 2 identical standard peripheral connector. This way different input or output modules can be connected.

The peripheral modules can either communicate on I2C or SPI protocol with the MCU.

The existing modules for the extractor fan control:

  • 1 × ESP8266
  • 1 × BME280

  • Garage door lock-state detection

    x-labz10/04/2016 at 07:51 0 comments

    The door opened / closed state, and the lock locked/unlocked state are detected with simple reed relays and optical gates.

    The signal is transmitted with a 2 wire - industrial like - current loop circuit.

    The optical gate transmitter circuit:

    Using the current loop method it's easy to detect the short circuit and the cable-break states as well.

    And the current-loop interface for the ESP8266 MCU module:

    It uses a simple SPI 8 bit A/D converter from TI. ( ADC084S021 )

  • Comparing ESP8266 antenna types

    x-labz09/18/2016 at 15:43 0 comments

    Here is the result of a quick ESP8266 antenna experiment:

    Same room
    ( ~5m )
    Next room
    ( ~9m )
    Garage, 2 walls, 1 floor diff
    ( ~13-15m )
    ESP 07
    int. + ext. antenna
    -45 dB-56 dB-85 dB
    ESP 07
    only ext. antenna
    -40 dB-54 dB- 85 dB
    ESP 07
    only int. antenna
    -60 dB-74 dBno connection :'(
    ESP 12E
    PCB antenna
    -52 dB-65 dBno connection :'(

  • ESP8266 direct access from web-app

    x-labz08/08/2016 at 10:44 0 comments

    In our case the user interface is implemented as a mobile web application, running on smartphone web browser.

    The mobile client gets the sensor data from the cloud server, where the sensor nodes are sending their measurements. BUT, what if there is no Internet connection, or the cloud server is down? The mobile client is capable to connect directly the end nodes, only the local (WiFi) network is needed.

    An important remark here: The mobile web client is set up to use the HTML5 application cache, so it is able to run off-line as well!

    Each ESP8266 end-node runs a web client to send the sensor data to the cloud server, and a web-server to respond to the direct requests, and receive the commands or other configuration settings.

    To access the ESP8266 web-servers the mobile app issues a so called Cross Domain Request (CORS) and the ESP8266 should respond to it in the proper way.

    The CORS requests have two types:

    • The simple CORS request can be a GET or POST, with Content Type = 'text/plain'

    This requests are served out-of-the-box with the servers implemented with the ESP8266WebServer library, as it automatically includes the response header:

    Access-Control-Allow-Origin: * 
    • In the case of Any other CORS requests, which are not the simple ones, the browser will issue a preflight requerst as well, and these should be responded by the server in the proper way.

    The ESP8266 code:

    server.on("/", HTTP_OPTIONS, []() {
        server.sendHeader("Access-Control-Max-Age", "10000");
        server.sendHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS");
        server.sendHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
        server.send(200, "text/plain", "" );
      });
    
    server.on("/", HTTP_GET, []() {
        String response ;
        // ... some code to prepare the response data...
    
        server.sendHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS");
        server.sendHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
        server.send(200, "text/plain", response.c_str() );
      });
    In the case of non-simple CORS requests, obviously you can handle any other content type than "text/plain" e.g. JSON or XML, but the cost is the preflight request!

    One more key factor: The HTML5 application cache is controlled by the CACHE MANIFEST and to make the CORS requests happen, you need to add the * wildcard in the NETWORK section:

    NETWORK:
    *

  • Mobile client

    x-labz07/25/2016 at 11:46 0 comments

    Here are some screen shots of the mobile web client.

    Showing the data history:

  • Working prototype

    x-labz07/25/2016 at 11:04 0 comments

View all 5 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates