Alexa based lighting and cooling system for router

Adriana Ionita - AAC
E-mail: adriana.ionita2404@stud.acs.upb.ro

Description

The purpose of this project is to create a small system that has lights and a fan and can be controlled with Alexa. The motivation for this project came from the following context: I have a router placed on the wall in a PVC box which has some cut out details in order to allow the air to flow; I also have an Echo Dot. Because of the way the router is placed, the air flow is not the best, so it could use a little help so that it doesn't get too hot inside the box. This is why the project makes use of a fan. As I said, the box has some cut out models, which look nice, and from an aesthetic point of view, lighting the box would also make for a nice feature. So this is why the project includes some lights. Now, because I have an Echo Dot I thought it would be the best if I could control this project using Alexa.

Hardware

The hardware components used for this project are:

  • ESP32 WROOM
  • 12V Fan
  • 12V Power Supply
  • 12V Power Adapter Jack
  • Relay Module
  • DHT11 Temperature and Humidity Module
  • 2 RGB LEDs
  • Resistors

The ESP32 represents the core of the system. It controls the other components and also enables the network connectivity for the project. Because the fan requires 12V to function, I used a 12 power adapter which can be plugged intro a socket and a dedicated jack to accommodate the other end of the adapter. The relay module is needed in order to power the fan on and off. The DHT11 module is used for its temperature sensor. The idea behind this is that the fan should go on only if the temperature goes over a certain value, hence the need to read the temperature. The LEDs and the resistors are used for the lights of the system.

It's important to note that the temperature sensor has been connected and integrated in a low-power manner. Instead of having it connected to a Vcc pin, case in which it would have provided data continuously, it has the Vcc pin connected to a digital pin. By doing this, it's possible to turn it on/off in order to save power.

Software

The code for this project is bare metal and was developed using the Arduino IDE:

  • For GPIO and PWM control I used the functions provided by Arduino (analog/digital read/write).
  • For the WiFi connection I used the “WiFi” library available for the ESP32 board in Arduino.
  • In order to control the lights and fan through Alexa I used the “Espalexa” library available for Arduino.
  • To get data from the temperature sensor I used the “DHT” library corresponding to the used module.

The functionality of the code is described by the diagram below:

As it can bee seen above, when the system gets out of reset it tries to connect to WiFi using the credentials embedded in the code. The status LED on the ESP32 board will blink fast while trying to connect and will signal the fact that the board successfully connected to WiFi with a slower blink. In the setup phase, the pins used by the components are set accordingly as input/output and high/low.

The main loop of the application is split in 2 phases: checking for remote updates and updating the remotes based on local changes. Checking for remote updates means that using the application or the voice commands, the end user can change the state of the LEDs or the fan. If such changes are made, the corresponding callback will be executed in order to update the hardware. Apart from these changes, the system also periodically checks the value of the temperature in order to turn the fan on/off accordingly. After checking the temperature, the new value has to be sent remote, to the application for example, in order to be displayed. This is the second phase of the loop.

Final result

Hardware setup

The project has been successfully implemented and set in position:

alexa_hw_1.jpg

Some wires were hidden to try to make it look nicer:

alexa_hw_2.jpg

Good thing it's all covered up :)

alexa_hw_3.jpg

WiFi Light & WiFi Fan registration

In order to get started, the devices have to be registered using the Alexa App:

After the registration is complete, the 2 devices will be available in the “Lights” section of the application under the names “WiFi Light” and “WiFi Fan”. From there they can be controlled with Alexa.

WiFi Light usage

The Alexa library for Arduino is designed especially for lights. So using it to control the lights of this project was pretty straight forward because it implied to use this library as intended. Functionality for the lights include turning lights on/off, setting the brightness and setting the color:

  • using voice commands given to the Echo Dot.
  • using the Alexa App installed on my phone.

WiFi Fan usage

For the fan on the other hand, I had to adapt these mechanisms available for lights to obtain the functionality I needed. Also, the fan is tightly dependent on the temperature sensor. So this is the behaviour for the fan and the sensor:

  • The sensor can be turned on/off using both the Echo Dot and the Alexa App (with the “normal” on/off commands).
  • The temperature of the sensor is represented as a percentage of brightness, where:
    • 0% brightness = 20°C
    • 100% brightness = 30°C
  • The fan can be controlled by changing its colour:
    • Green (on): always on, regardless of the temperature
    • Blue (cold mode): fan will turn on if the temperature goes over 23°C
    • Red (warm mode): fan will turn on if the temperature goes over 26°C
    • Any other colour: always off, regardless of the temperature

Demo

The functionality of the project is also demonstrated in the video below:

Resources

iothings/proiecte/2021/alexa-system.txt · Last modified: 2022/01/27 02:35 by adriana.ionita2404
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0