How to turn a home thermostat into a smart device: easing the connectivity challenge: Page 5 of 7

May 09, 2017 //By Vikram Ramanna
Consumers are developing a taste for smart home devices, thanks in part to the new sophistication of voice-controlled technologies such as Apple’s Siri Remote and the Alexa Voice Service on Amazon Echo, and of systems for the remote control of home devices such as Google’s Nest products.

The snippet application folder includes a sample application showing how to use the I2C protocol to read the temperature sensor’s value. Basic API calls may then be used to read the room temperature.

The I/Os may be configured in the platform files. The platform.c file includes all the pin-out mappings and their respective configurations. When configuring the I2C pins, it is necessary to verify:

  • the I2C port to which the temperature sensor is connected;
  • the SDA and SCL pins;
  • the driver to be used.

Another application code snippet integrates a 128px x 128px display into the design. By combining the two applications, it is possible to read the temperature of the room over the I2C interface and to show the value on the display.

To write this application, the flow is:

  1. Initialize WICED;
  2. Initialize the I2C device;
  3. Initialize the display;
  4. Read the I2C value from the temperature sensor;
  5. Via SPI or I2C, show the value on the mini display.

Thus far, the system is simply implementing basic, dumb thermometer functions. The next step is to add intelligence: for instance, to compare the desired temperature to the present temperature and, if the room temperature is lower than the desired temperature, to switch on the heating via the relay.

After this, the developer will want to enable the thermometer to connect to a Wi-Fi network in range. Initializing the network stack offers the user a choice of operating modes:

  • STA interface – station-based, in which the thermostat is a client;
  • Soft AP – in which the thermostat hosts a webserver;
  • SoftAP and STA – known as APSTA mode, here the thermostat can operate in both server and client modes.
Design category: